/* NAS Group ERP — Global Styles */

:root {
    --sidebar-width: 200px;
    --navbar-height: 42px;
    --primary:       #0d6efd;
    --sidebar-bg:    #0d2626;
    --sidebar-text:  #b2d8d8;
    --sidebar-hover: #1a3d3d;
    --sidebar-active:#14b8a6;
}

body {
    font-family: 'Poppins', sans-serif;
    font-size: 0.8rem;
    background: #f0f2f5;
}

/* ── Navbar ── */
.top-navbar {
    height: var(--navbar-height);
    background: linear-gradient(135deg, #1a2236 0%, #1e3a5f 60%, #1565c0 100%);
    border-bottom: none;
    box-shadow: 0 2px 10px rgba(0,0,0,.25);
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1040;
    display: flex;
    align-items: center;
    padding: 0 .75rem;
    gap: .6rem;
}
.top-navbar .brand {
    font-weight: 700;
    font-size: .85rem;
    color: #fff;
    white-space: nowrap;
    letter-spacing: .01em;
}
.top-navbar .brand i { color: #64b5f6; }
.top-navbar .company-badge {
    font-size: .68rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
}
.top-navbar .btn { font-size: .73rem; padding: .2rem .55rem; }
.top-navbar .btn-outline-secondary {
    color: #cbd5e1;
    border-color: rgba(255,255,255,.25);
    background: rgba(255,255,255,.07);
}
.top-navbar .btn-outline-secondary:hover {
    background: rgba(255,255,255,.15);
    color: #fff;
    border-color: rgba(255,255,255,.4);
}
.top-navbar .btn-light {
    background: rgba(255,255,255,.12);
    border-color: rgba(255,255,255,.2);
    color: #fff;
}
.top-navbar .btn-light:hover {
    background: rgba(255,255,255,.22);
    color: #fff;
}
.top-navbar .dropdown-toggle { color: #e2e8f0 !important; font-size: .73rem; }
.top-navbar .dropdown-toggle:hover { color: #fff !important; }
.top-navbar .dropdown-menu {
    background: #1e293b;
    border: 1px solid rgba(255,255,255,.1);
    box-shadow: 0 8px 24px rgba(0,0,0,.3);
    font-size: .75rem;
}
.top-navbar .dropdown-menu .dropdown-item {
    color: #cbd5e1;
    font-size: .75rem;
    padding: .3rem .9rem;
}
.top-navbar .dropdown-menu .dropdown-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.top-navbar .dropdown-menu .dropdown-item.text-danger { color: #f87171 !important; }
.top-navbar .dropdown-menu .dropdown-divider { border-color: rgba(255,255,255,.1); }

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: var(--navbar-height);
    left: 0; bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1030;
    transition: width .22s ease, transform .25s ease;
    white-space: nowrap;
}
.sidebar .nav-section {
    padding: .35rem .85rem .15rem;
    font-size: .6rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #5f9ea0;
    margin-top: .35rem;
}
.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: .45rem;
    padding: .32rem 1rem;
    color: var(--sidebar-text);
    font-size: .73rem;
    border-radius: 0;
    transition: background .15s, color .15s;
}
.sidebar .nav-link i { width: 14px; text-align: center; font-size: .7rem; }
.sidebar .nav-link:hover { background: var(--sidebar-hover); color: #fff; }

/* Parent toggle active — section is open, a child is the current page */
.sidebar .nav-link.active {
    background: transparent;
    color: var(--sidebar-active);
    border-left: 3px solid rgba(20, 184, 166, 0.45);
    font-weight: 500;
}

/* Child nav-link active — IS the current page ("you are here")
   Brightness ladder: inactive=#b2d8d8 → parent=#14b8a6 → child=#fff (brightest = most prominent)
   White on rgba(255,255,255,0.11) over #0d2626 ≈ 14:1 contrast (WCAG AAA) */
.sidebar .collapse .nav-link.active {
    background: rgb(119 151 124 / 40%);
    color: #ffffff;
    border-left: 3px solid var(--sidebar-active);
    font-weight: 600;
}

/* ── Main content ── */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--navbar-height);
    padding: 1rem 1.1rem;
    min-height: calc(100vh - var(--navbar-height));
    transition: margin-left .22s ease;
}

/* ── Sidebar group toggle chevron ── */
.sidebar .nav-link[data-bs-toggle="collapse"] .fa-chevron-down {
    font-size: .6rem;
    opacity: .6;
    transition: transform .2s ease;
    flex-shrink: 0;
}
.sidebar .nav-link[data-bs-toggle="collapse"][aria-expanded="true"] .fa-chevron-down {
    transform: rotate(-180deg);
}

/* ── Sidebar collapsed (desktop ≥769px only) ── */
@media (min-width: 769px) {
    body.sidebar-collapsed .sidebar { width: 46px; }
    body.sidebar-collapsed .main-content { margin-left: 46px; }

    body.sidebar-collapsed .sidebar .nav-section { display: none; }
    body.sidebar-collapsed .sidebar .collapse { display: none !important; }

    body.sidebar-collapsed .sidebar .nav-link {
        padding: .32rem 0;
        justify-content: center !important;
        gap: 0;
        font-size: 0;
    }
    body.sidebar-collapsed .sidebar .nav-link i {
        font-size: .75rem;
        width: auto;
        margin: 0;
        text-align: center;
        display: block;
    }
    body.sidebar-collapsed .sidebar .nav-link .fa-chevron-down { display: none !important; margin: 0; }
    body.sidebar-collapsed .sidebar .nav-link span { display: none; }
    body.sidebar-collapsed .sidebar .px-3 { display: none; }
}

/* ── Page header ── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .9rem;
}
.page-header h4 {
    font-size: .95rem;
    font-weight: 600;
    margin: 0;
    color: #0d2626;
}

/* ── Cards ── */
.card { border: 0; box-shadow: 0 1px 4px rgba(0,0,0,.08); border-radius: .4rem; }
.card-header {
    background: #fff;
    font-weight: 600;
    font-size: .78rem;
    border-bottom: 1px solid #f0f0f0;
    padding: .5rem .85rem;
}

/* ── Stat cards ── */
.stat-card { border-left: 4px solid var(--primary); }
.stat-card .stat-value { font-size: 1.4rem; font-weight: 700; }
.stat-card .stat-label { font-size: .7rem; color: #6c757d; }

/* ── Tables ── */
table.dataTable thead th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: .73rem;
    white-space: nowrap;
    padding: .4rem .6rem;
}
table.dataTable tbody td {
    font-size: .78rem;
    padding: .35rem .6rem;
}
table.dataTable tfoot input {
    width: 100%;
    padding: .2rem .35rem;
    font-size: .72rem;
    border: 1px solid #dee2e6;
    border-radius: .25rem;
}
.dt-buttons .btn { font-size: .72rem; }
.dataTables_info, .dataTables_length, .dataTables_filter label { font-size: .75rem; }
.dataTables_paginate .page-link { font-size: .73rem; padding: .25rem .5rem; }

/* ── DataTables buttons hidden — export triggered via card-header Bootstrap buttons ── */
.dt-buttons { display: none; }

/* ── Forms ── */
.form-label { font-weight: 500; font-size: .73rem; margin-bottom: .18rem; }
.form-control, .form-select { font-size: .78rem; }
.form-control-sm { font-size: .75rem; padding: .2rem .45rem; }
.form-select-sm { font-size: .75rem; padding-top: .2rem; padding-bottom: .2rem; padding-left: .45rem; }
.form-control:focus, .form-select:focus { border-color: #86b7fe; box-shadow: 0 0 0 .18rem rgba(13,110,253,.15); }
.select2-container--bootstrap-5 .select2-selection { font-size: .75rem; min-height: 28px; }
.select2-container--bootstrap-5 .select2-selection--single { padding: .18rem .45rem; }
.select2-dropdown { font-size: .75rem; }
.input-group-text { font-size: .75rem; padding: .2rem .45rem; }
.btn-sm { font-size: .73rem; padding: .22rem .55rem; }
.badge { font-size: .68rem; }

/* ── Auth page ── */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0d2626 0%, #1a3d3d 100%);
}
.auth-card { width: 100%; max-width: 420px; border-radius: .75rem; }
.auth-logo { font-size: 1.4rem; font-weight: 800; color: #1a2236; letter-spacing: -.5px; }

/* ── Company select ── */
.company-card {
    cursor: pointer;
    transition: transform .15s, box-shadow .15s;
    border-radius: .75rem;
}
.company-card:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.company-icon { font-size: 2.5rem; }

/* ── Scrollbars (always visible in table-responsive) ── */
.table-responsive {
    overflow-x: auto;
}
.table-responsive::-webkit-scrollbar {
    height: 7px;
}
.table-responsive::-webkit-scrollbar-track {
    background: #e9ecef;
    border-radius: 4px;
}
.table-responsive::-webkit-scrollbar-thumb {
    background: #adb5bd;
    border-radius: 4px;
}
.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #6c757d;
}

/* ── Sidebar flyout (collapsed mode) ── */
.sidebar-flyout {
    display: none;
    position: fixed;
    left: 46px;
    background: var(--sidebar-bg);
    min-width: 185px;
    z-index: 1045;
    border-radius: 0 6px 6px 6px;
    box-shadow: 4px 4px 16px rgba(0,0,0,.38);
    padding: 4px 0 6px;
    animation: flyout-in .15s ease-out;
}
@keyframes flyout-in {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: translateX(0); }
}
.sidebar-flyout .flyout-section-title {
    padding: .3rem .85rem .1rem;
    font-size: .6rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #5f9ea0;
}
.sidebar-flyout .flyout-parent-label {
    padding: .28rem 1rem;
    font-size: .73rem;
    color: #b2d8d8;
    font-weight: 600;
    border-bottom: 1px solid rgba(255,255,255,.07);
    margin-bottom: 2px;
}
.sidebar-flyout .flyout-link {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .28rem 1rem;
    color: var(--sidebar-text);
    font-size: .73rem;
    text-decoration: none;
    white-space: nowrap;
    transition: background .12s, color .12s;
}
.sidebar-flyout .flyout-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-flyout .flyout-link.active {
    background: rgb(119 151 124 / 40%);
    color: #ffffff;
    border-left: 3px solid var(--sidebar-active);
    font-weight: 600;
}

/* ── Mobile context bar ── */
.mobile-context-bar {
    display: none;
    position: fixed;
    top: var(--navbar-height);
    left: 0; right: 0;
    height: 28px;
    background: rgba(10, 28, 28, 0.97);
    align-items: center;
    padding: 0 .65rem;
    gap: .45rem;
    z-index: 1038;
    border-bottom: 1px solid rgba(255,255,255,.1);
    flex-wrap: nowrap;
    overflow: hidden;
}
.mobile-context-bar .badge {
    font-size: .64rem;
    white-space: nowrap;
    padding: 3px 7px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .mobile-context-bar { display: flex !important; }

    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
        top: calc(var(--navbar-height) + 28px);
    }
    .sidebar.open { transform: translateX(0); }
    .main-content {
        margin-left: 0 !important;
        margin-top: calc(var(--navbar-height) + 28px) !important;
    }

    .top-navbar { padding: 0 .5rem; gap: .35rem; }
    .top-navbar .brand { font-size: .78rem; }
    .top-navbar .btn  { padding: .18rem .4rem; }
    .top-navbar .dropdown-menu { font-size: .75rem; min-width: 160px; }
}
