/**
 * HMCL Management System - Main CSS File
 */

/* Custom Variables */
:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    
    --sidebar-width: 250px;
    --navbar-height: 60px;
    --content-max-width: 1680px; /* wider main content */
    --content-side-pad: 1.25rem; /* base side padding */
}

/* Global Styles */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
}

/* Navigation */
.navbar {
    box-shadow: 0 2px 4px rgba(0,0,0,.1);
    height: var(--navbar-height);
}

.navbar-brand {
    font-weight: bold;
    color: var(--primary-color) !important;
}

.navbar.navbar-dark .navbar-brand,
.navbar.navbar-dark .navbar-brand:focus,
.navbar.navbar-dark .navbar-brand:hover {
    color: #ffffff !important;
    text-shadow: 0 1px 1px rgba(0,0,0,0.15);
}

/* Sidebar */
.sidebar {
    /* Base appearance; layout handled by Bootstrap grid to avoid double offsets */
    position: static;
    z-index: 100;
    padding: 0;
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
    background-color: #fff;
}

/* When authenticated, still rely on grid; no fixed offset */
.has-sidebar .sidebar { padding-top: 0; }

.sidebar-sticky {
    position: relative;
    top: 0;
    height: 100vh;
    padding-top: .5rem;
    overflow-x: hidden;
    overflow-y: auto;
}

.has-sidebar .sidebar-sticky {
    height: 100vh;
}

.sidebar .nav-link {
    color: #333;
    padding: 10px 20px;
    border-radius: 0;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar .nav-link:hover {
    background-color: #f8f9fa;
    color: var(--primary-color);
}

.sidebar .nav-link.active {
    background-color: var(--primary-color);
    color: white;
}

.sidebar .nav-link i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
    flex: 0 0 20px;
}

/* Sidebar Branding */
.sidebar-branding {
    background-color: #fff;
    position: sticky;
    top: 0;
    z-index: 101;
}

.sidebar-logo {
    max-height: 28px;
    width: auto;
}

/* Sidebar User Section */
.sidebar-user .btn {
    width: 100%;
}

.sidebar-user .text-muted {
    font-size: 0.85rem;
}

.sidebar-user {
    position: sticky;
    bottom: 0;
    background-color: #fff;
}

/* Footer */
.app-footer {
    border-top: 1px solid #e9ecef;
    background-color: #fff;
}

.has-sidebar .app-footer {
    margin-left: var(--sidebar-width);
}

@media (max-width: 768px) {
    .has-sidebar .app-footer {
        margin-left: 0;
    }
}

/* Main Content */
main {
    margin-left: 0;
    padding-top: 20px;
}

.has-sidebar main {
    /* Using Bootstrap grid for main area; avoid double-offset to prevent horizontal scroll */
    margin-left: 0;
    padding-right: 1rem; /* slight right padding for balance */
}

/* Inner content wrapper: center within the main column and keep symmetric padding */
.content-wrap {
    max-width: var(--content-max-width);
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--content-side-pad);
    padding-right: var(--content-side-pad);
}

@media (min-width: 1400px) {
    :root { --content-side-pad: 1.5rem; }
}

@media (min-width: 1600px) {
    :root { --content-max-width: 1760px; --content-side-pad: 1.75rem; }
}

@media (min-width: 1920px) {
    :root { --content-max-width: 1840px; --content-side-pad: 2rem; }
}

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    
    main {
        margin-left: 0;
    }
}

/* Cards */
.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    margin-bottom: 1.5rem;
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
}

/* Info Boxes */
.info-box {
    display: block;
    min-height: 90px;
    background: #fff;
    width: 100%;
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
    border-radius: 2px;
    margin-bottom: 15px;
    overflow: hidden;
}

.info-box-icon {
    border-top-left-radius: 2px;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 2px;
    display: block;
    float: left;
    height: 90px;
    width: 90px;
    text-align: center;
    font-size: 45px;
    line-height: 90px;
    background: rgba(0,0,0,0.2);
    color: white;
}

.info-box-content {
    padding: 5px 10px;
    margin-left: 90px;
}

.info-box-text {
    text-transform: uppercase;
    font-weight: bold;
    font-size: 13px;
    color: #666;
}

.info-box-number {
    display: block;
    font-weight: bold;
    font-size: 18px;
    color: #333;
}

/* Buttons */
.btn {
    border-radius: 4px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-group .btn {
    margin-right: 2px;
}

.btn-group .btn:last-child {
    margin-right: 0;
}

/* Tables */
.table {
    background-color: white;
}

.table th {
    border-top: none;
    font-weight: 600;
    color: #495057;
    background-color: #f8f9fa;
}

.table-responsive {
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* DataTables Customization */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    margin-bottom: 10px;
}

.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 5px 10px;
}

/* Forms */
.form-control {
    border-radius: 4px;
    border: 1px solid #ced4da;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Selects and dropdown caret fixes (Bootstrap 5 compatibility)
   Ensure selects styled with legacy .form-control show a chevron like .form-select
   and guarantee dropdown toggle carets are visible even if overridden by custom CSS */

/* Chevron for legacy select.form-control to mimic .form-select */
select.form-control {
    display: block;
    width: 100%;
    padding: 0.375rem 2.25rem 0.375rem 0.75rem;
    -moz-padding-start: calc(0.75rem - 3px);
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

select.form-control:focus {
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Do not show chevron for multiple/size selects */
select.form-control[multiple],
select.form-control[size]:not([size="1"]) {
    padding-right: 0.75rem;
    background-image: none;
}

/* Ensure dropdown caret is visible on toggles */
.dropdown-toggle::after {
    display: inline-block;
    margin-left: .255em;
    vertical-align: .255em;
    content: "";
    border-top: .3em solid;
    border-right: .3em solid transparent;
    border-bottom: 0;
    border-left: .3em solid transparent;
}

.dropdown-toggle:empty::after {
    margin-left: 0;
}

/* Alerts */
.alert {
    border: none;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.alert-dismissible .btn-close {
    padding: 0.75rem 1.25rem;
}

/* Progress Bars */
.progress {
    height: 20px;
    border-radius: 4px;
    background-color: #e9ecef;
}

.progress-bar {
    border-radius: 4px;
}

/* Badges */
.badge {
    font-size: 0.75em;
    font-weight: 500;
    border-radius: 4px;
}

/* Modals */
.modal-content {
    border: none;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.modal-header {
    border-bottom: 1px solid #dee2e6;
    background-color: #f8f9fa;
}

.modal-footer {
    border-top: 1px solid #dee2e6;
    background-color: #f8f9fa;
}

/* Loading States */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Utility Classes */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shadow-sm {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
}

.border-left-primary {
    border-left: 4px solid var(--primary-color) !important;
}

.border-left-success {
    border-left: 4px solid var(--success-color) !important;
}

.border-left-warning {
    border-left: 4px solid var(--warning-color) !important;
}

.border-left-danger {
    border-left: 4px solid var(--danger-color) !important;
}

/* Responsive Adjustments */
@media (max-width: 576px) {
    .info-box-icon {
        width: 70px;
        height: 70px;
        font-size: 35px;
        line-height: 70px;
    }
    
    .info-box-content {
        margin-left: 70px;
    }
    
    .btn-group {
        display: flex;
        flex-wrap: wrap;
    }
    
    .btn-group .btn {
        margin-bottom: 5px;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .navbar,
    .btn,
    .alert {
        display: none !important;
    }
    
    main {
        margin-left: 0 !important;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Sidebar Submenu Styles */
.sidebar .nav-link[data-bs-toggle="collapse"] {
    cursor: pointer;
}

.sidebar .nav-link[data-bs-toggle="collapse"] .fas.fa-chevron-down {
    transition: transform 0.2s ease;
    font-size: 0.8em;
}

.sidebar .nav-link[data-bs-toggle="collapse"][aria-expanded="true"] .fas.fa-chevron-down {
    transform: rotate(180deg);
}

.sidebar .collapse .nav-link {
    padding-left: 2rem;
    font-size: 0.9em;
    color: #6c757d;
}

.sidebar .collapse .nav-link:hover {
    color: var(--primary-color);
    background-color: rgba(0, 123, 255, 0.1);
}

.sidebar .collapse .nav-link.active {
    color: var(--primary-color);
    background-color: rgba(0, 123, 255, 0.15);
    font-weight: 500;
}

.sidebar .collapse .nav-link i {
    font-size: 0.8em;
    width: 16px;
}

/* Submenu Animation */
.sidebar .collapse {
    transition: all 0.3s ease;
}

.sidebar .collapsing {
    transition: height 0.3s ease;
}