/**
 * SCHOOL CONNECT - Core Application Stylesheet
 * Modern, Clean, Professional School ERP Layout
 */

:root {
    /* Main Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --topbar-height: 64px;
    --content-bg: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    /* Status Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #0ea5e9;
    --secondary-slate: #64748b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body, 'Inter', system-ui, -apple-system, sans-serif);
    font-size: var(--font-body-size, 14px);
    font-weight: var(--font-body-weight, 400);
    line-height: var(--font-line-height, 1.5);
    color: var(--text-main);
    background-color: var(--content-bg);
    overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6,
.heading-font {
    font-family: var(--font-heading, 'Outfit', 'Inter', sans-serif);
    font-weight: var(--font-heading-weight, 600);
    color: #0f172a;
}

h1 {
    font-size: var(--font-heading-size, 24px);
}

h2 {
    font-size: calc(var(--font-heading-size, 24px) * 0.85);
}

h3 {
    font-size: var(--font-subheading-size, 18px);
}

h4 {
    font-size: 16px;
}

h5 {
    font-size: 14px;
}

h6 {
    font-size: 13px;
}

/* Wrapper & Layout */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    position: relative;
    overflow-x: hidden;
}

/* Sidebar Styles */
.app-sidebar {
    width: var(--sidebar-width, 260px);
    background-color: var(--sidebar-bg, #0f172a);
    color: var(--sidebar-text, #94a3b8);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.12);
    user-select: none;
}

.sidebar-header {
    height: var(--topbar-height, 64px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    position: relative;
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: #ffffff;
    text-decoration: none;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    transition: all 0.2s ease;
}

.sidebar-brand-logo {
    width: 34px;
    height: 34px;
    object-fit: contain;
    border-radius: 8px;
    background: #ffffff;
    padding: 2px;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.sidebar-brand-text {
    transition: opacity 0.2s ease, width 0.2s ease;
    white-space: nowrap;
}

.sidebar-pin-btn {
    width: 26px;
    height: 26px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #94a3b8;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.15s ease;
    padding: 0;
}

.sidebar-pin-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem 0.5rem;
}

.sidebar-menu::-webkit-scrollbar {
    width: 4px;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.sidebar-nav-item {
    margin-bottom: 2px;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
    color: var(--sidebar-text, #94a3b8);
    text-decoration: none;
    border-radius: 6px;
    font-size: var(--font-menu-size, 13.5px);
    font-weight: 500;
    transition: all 0.15s ease;
}

.sidebar-nav-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
}

.sidebar-nav-link.active {
    color: #ffffff;
    background: var(--primary, #1e40af);
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(30, 64, 175, 0.4);
}

/* Accordion Nav Groups */
.sidebar-nav-group {
    margin-bottom: 3px;
    position: relative;
}

.sidebar-nav-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
    background: transparent;
    border: none;
    color: var(--sidebar-text, #94a3b8);
    text-align: left;
    border-radius: 6px;
    font-size: var(--font-menu-size, 13.5px);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

.sidebar-nav-toggle:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
}

.sidebar-nav-toggle.active {
    color: #ffffff;
    font-weight: 600;
}

.sidebar-nav-icon {
    width: 20px;
    font-size: 0.95rem;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-nav-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav-arrow {
    font-size: 9.5px;
    color: #64748b;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.sidebar-nav-group.open>.sidebar-nav-toggle .sidebar-nav-arrow {
    transform: rotate(90deg);
    color: #ffffff;
}

.sidebar-submenu {
    padding: 3px 0 3px 1.4rem;
    margin: 2px 0 4px 0;
    position: relative;
}

.sidebar-submenu::before {
    content: '';
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 1.15rem;
    width: 1.5px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 1px;
}

.sidebar-sub-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.38rem 0.6rem;
    color: #94a3b8;
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 450;
    border-radius: 5px;
    transition: all 0.15s ease;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-sub-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
    padding-left: 0.8rem;
}

.sidebar-sub-link.active {
    color: #ffffff;
    background: rgba(30, 64, 175, 0.35);
    font-weight: 600;
    border-left: 2.5px solid #38bdf8;
}

.sub-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #64748b;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.sidebar-sub-link:hover .sub-dot,
.sidebar-sub-link.active .sub-dot {
    background: #38bdf8;
    transform: scale(1.3);
}

/* ======================================================== */
/* COLLAPSED / MINI SIDEBAR (DESKTOP)                      */
/* ======================================================== */
body.sidebar-collapsed .app-sidebar {
    width: 70px !important;
}

body.sidebar-collapsed .sidebar-brand-text,
body.sidebar-collapsed .sidebar-nav-label,
body.sidebar-collapsed .sidebar-nav-arrow {
    display: none !important;
}

body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 0;
}

body.sidebar-collapsed .sidebar-header {
    justify-content: center;
    padding: 0;
}

body.sidebar-collapsed .sidebar-pin-btn {
    display: none !important;
}

body.sidebar-collapsed .sidebar-nav-toggle,
body.sidebar-collapsed .sidebar-nav-link {
    justify-content: center;
    padding: 0.65rem 0;
}

body.sidebar-collapsed .sidebar-nav-icon {
    margin: 0;
    font-size: 1.15rem;
}

body.sidebar-collapsed .app-main {
    margin-left: 70px !important;
    width: calc(100% - 70px) !important;
    max-width: calc(100% - 70px) !important;
}

/* Floating Popout on Hover in Mini Mode */
body.sidebar-collapsed .sidebar-nav-group:hover .sidebar-submenu {
    display: block !important;
    position: absolute;
    left: 70px;
    top: 0;
    width: 230px;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 4px 6px 20px rgba(0, 0, 0, 0.35);
    border-radius: 0 8px 8px 0;
    padding: 0.6rem;
    z-index: 1050;
}

body.sidebar-collapsed .sidebar-nav-group:hover .sidebar-submenu::before {
    display: none;
}

body.sidebar-collapsed .sidebar-nav-group:hover .sidebar-sub-link {
    padding-left: 0.6rem;
}

/* ======================================================== */
/* MAIN CONTENT AREA & TOPBAR                              */
/* ======================================================== */
.app-main {
    flex: 1 1 auto;
    margin-left: var(--sidebar-width, 260px);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    width: calc(100% - var(--sidebar-width, 260px));
    max-width: calc(100% - var(--sidebar-width, 260px));
    background-color: var(--content-bg, #f8fafc);
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1), width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-topbar {
    height: var(--topbar-height, 64px);
    background: #ffffff;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    width: 100%;
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.session-badge {
    background: #e0f2fe;
    color: #0369a1;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.lang-switch-btn {
    border: 1px solid var(--border-color, #e2e8f0);
    background: #f8fafc;
    color: #334155;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}

.lang-switch-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

/* ======================================================== */
/* MOBILE RESPONSIVE DRAWER & OVERLAY                      */
/* ======================================================== */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    z-index: 1035;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        width: 260px !important;
        z-index: 1050;
    }

    .app-sidebar.show {
        transform: translateX(0);
    }

    .app-main {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .sidebar-backdrop.show {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Content Container */
.app-content {
    flex: 1 0 auto;
    padding: 1.5rem;
    width: 100%;
    max-width: 100%;
}

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.page-title {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

/* Cards */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius, 8px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    margin-bottom: 1.25rem;
}

.card-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 0.85rem 1.15rem;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body {
    padding: 1.15rem;
}

/* KPI Summary Cards */
.kpi-card {
    border-radius: var(--border-radius, 8px);
    border: 1px solid var(--border-color);
    background: #ffffff;
    padding: 1.1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}

.kpi-value {
    font-size: 1.45rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    color: #0f172a;
    line-height: 1.2;
}

.kpi-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

    /* Table Typography & Density (Dynamically Bound to Settings) */
    .table,
    table,
    .directory-table {
        font-family: var(--font-table, 'Inter', sans-serif);
        font-size: var(--font-table-size, 11px) !important;
        margin-bottom: 0;
        border-color: var(--border-color, #e2e8f0);
    }

    .table th,
    table th,
    .directory-table th {
        background-color: #f8fafc;
        color: #475569;
        font-weight: 600;
        text-transform: uppercase;
        font-size: calc(var(--font-table-size, 11px) * 0.92) !important;
        letter-spacing: 0.5px;
        padding: var(--table-cell-padding, 0.45rem 0.65rem) !important;
        border-bottom: 2px solid var(--border-color, #e2e8f0);
        vertical-align: middle;
        white-space: nowrap;
    }

    .table td,
    table td,
    .directory-table td {
        padding: var(--table-cell-padding, 0.45rem 0.65rem) !important;
        font-size: var(--font-table-size, 11px) !important;
        vertical-align: middle;
        color: #334155;
        line-height: 1.4;
        border-color: #f1f5f9;
    }

    .table-hover tbody tr {
        transition: background-color 0.15s ease;
    }

    .table-hover tbody tr:hover {
        background-color: #f8fafc;
    }

    .table-striped > tbody > tr:nth-of-type(odd) > * {
        background-color: rgba(248, 250, 252, 0.6);
    }

    /* Forms & Inputs */
    .form-label {
        font-size: var(--font-label-size, 13px);
        font-weight: 600;
        color: #334155;
        margin-bottom: 0.35rem;
    }

    .form-control,
    .form-select {
        font-size: var(--font-input-size, 13.5px);
        border: 1px solid #cbd5e1;
        border-radius: 8px;
        padding: 0.5rem 0.8rem;
        color: #1e293b;
        background-color: #ffffff;
        transition: border-color 0.15s ease, box-shadow 0.15s ease;
    }

    .form-control:focus,
    .form-select:focus {
        border-color: #3b82f6;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
        outline: none;
    }

    .input-group-text {
        background-color: #f8fafc;
        border: 1px solid #cbd5e1;
        border-radius: 8px;
        color: #64748b;
        font-size: 13px;
    }

    /* Professional Buttons */
    .btn {
        font-size: var(--font-button-size, 13px);
        font-weight: 600;
        border-radius: 7px;
        padding: 0.45rem 0.95rem;
        transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.4rem;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    }

    .btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    }

    .btn:active {
        transform: translateY(0);
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    }

    .btn-primary {
        background-color: var(--primary, #1e40af);
        border-color: var(--primary, #1e40af);
        color: #ffffff;
    }

    .btn-primary:hover {
        background-color: var(--primary-hover, #1d4ed8);
        border-color: var(--primary-hover, #1d4ed8);
        color: #ffffff;
    }

    .btn-light {
        background-color: #ffffff;
        border-color: #e2e8f0;
        color: #334155;
    }

    .btn-light:hover {
        background-color: #f8fafc;
        border-color: #cbd5e1;
        color: #0f172a;
    }

    .btn-sm {
        font-size: 12px;
        padding: 0.3rem 0.65rem;
        border-radius: 6px;
    }

    .btn-xs {
        font-size: 10.5px;
        padding: 0.2rem 0.5rem;
        border-radius: 5px;
    }

    /* Modern Subtle Pastel Badges */
    .badge {
        font-weight: 600;
        padding: 0.35em 0.65em;
        border-radius: 6px;
        letter-spacing: 0.3px;
    }

    .bg-primary-subtle {
        background-color: #eff6ff !important;
        color: #1d4ed8 !important;
        border: 1px solid #bfdbfe;
    }

    .bg-success-subtle {
        background-color: #f0fdf4 !important;
        color: #15803d !important;
        border: 1px solid #bbf7d0;
    }

    .bg-danger-subtle {
        background-color: #fef2f2 !important;
        color: #b91c1c !important;
        border: 1px solid #fecaca;
    }

    .bg-warning-subtle {
        background-color: #fffbeb !important;
        color: #b45309 !important;
        border: 1px solid #fde68a;
    }

    .bg-info-subtle {
        background-color: #f0f9ff !important;
        color: #0369a1 !important;
        border: 1px solid #bae6fd;
    }

    .bg-purple-subtle {
        background-color: #faf5ff !important;
        color: #7e22ce !important;
        border: 1px solid #e9d5ff;
    }

    /* Status Indicator Dots */
    .status-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        display: inline-block;
    }

    .status-dot-pulse {
        position: relative;
    }

    .status-dot-pulse::after {
        content: '';
        position: absolute;
        top: -2px;
        left: -2px;
        right: -2px;
        bottom: -2px;
        border-radius: 50%;
        background: inherit;
        opacity: 0.4;
        animation: pulseAnimation 2s infinite cubic-bezier(0.4, 0, 0.6, 1);
    }

    @keyframes pulseAnimation {
        0%, 100% { transform: scale(1); opacity: 0.4; }
        50% { transform: scale(1.6); opacity: 0; }
    }

    /* Modern Dropdown Polish */
    .dropdown-menu {
        border-radius: 10px;
        border: 1px solid #e2e8f0;
        box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
        padding: 0.4rem;
        z-index: 1060 !important;
    }

    .dropdown-item {
        border-radius: 6px;
        padding: 0.45rem 0.85rem;
        font-size: 13px;
        font-weight: 500;
        color: #334155;
        transition: background 0.15s ease, color 0.15s ease;
    }

    .dropdown-item:hover {
        background-color: #f1f5f9;
        color: #0f172a;
    }

    .dropdown-item.active,
    .dropdown-item:active {
        background-color: var(--primary, #1e40af);
        color: #ffffff;
    }

    /* Modern Alerts */
    .alert {
        border-radius: 10px;
        border: 1px solid transparent;
        padding: 0.85rem 1.15rem;
        font-size: 13.5px;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
    }

    .alert-success {
        background-color: #f0fdf4;
        border-color: #bbf7d0;
        border-left: 4px solid #16a34a;
        color: #166534;
    }

    .alert-danger {
        background-color: #fef2f2;
        border-color: #fecaca;
        border-left: 4px solid #dc2626;
        color: #991b1b;
    }

    .alert-warning {
        background-color: #fffbeb;
        border-color: #fde68a;
        border-left: 4px solid #f59e0b;
        color: #92400e;
    }

    .alert-info {
        background-color: #f0f9ff;
        border-color: #bae6fd;
        border-left: 4px solid #0284c7;
        color: #075985;
    }

    /* Custom Sleek Slim Scrollbars */
    * {
        scrollbar-width: thin;
        scrollbar-color: #cbd5e1 transparent;
    }

    *::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }

    *::-webkit-scrollbar-track {
        background: transparent;
    }

    *::-webkit-scrollbar-thumb {
        background-color: #cbd5e1;
        border-radius: 6px;
    }

    *::-webkit-scrollbar-thumb:hover {
        background-color: #94a3b8;
    }

    /* Global Table Dropdown Overflow & Scrollbar Prevention Across ERP */
    .table-responsive,
    .table-container,
    .card,
    .card-body {
        overflow: visible !important;
    }

    /* Footer */
    .app-footer {
        padding: 1rem 1.5rem;
        background: #ffffff;
        border-top: 1px solid var(--border-color);
        font-size: 12px;
        color: var(--text-muted);
        display: flex;
        align-items: center;
        justify-content: space-between;
    }