/* ==========================================================================
   Takavi — tutor & student dashboard layout (desktop)
   Sidebar + page content sit in the same 1200px column as the header:
   left edge = logo, right edge = user menu. Mobile (<993px) is unchanged.
   Loaded last in tutors/common/header.php and students/common/header.php.
   ========================================================================== */

:root {
    --tk-page-bg: #f4f5f9;
    --tk-card-bg: #ffffff;
    --tk-border: #e8eaf0;
    --tk-text: #1f2937;
    --tk-muted: #6b7280;
    --tk-primary: #da0b4e;
    --tk-primary-soft: rgba(218, 11, 78, 0.08);
    --tk-radius: 16px;
    --tk-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.06);
    --tk-col: 1360px;          /* dashboards use a wider column; the header follows (see .nav-container below) */
    --tk-gutter: 20px;         /* same side padding as .nav-container → aligns with the logo */
    --tk-nav-h: 90px;
    --tk-gap: 24px;
    --tk-sidebar-w: 240px;
}

@media (min-width: 993px) {

    body { background: var(--tk-page-bg); }

    /* header uses the same wider column, so the logo and the user menu still line up with sidebar and content */
    .navbar .nav-container { max-width: var(--tk-col) !important; padding: 0 var(--tk-gutter) !important; box-sizing: border-box; }

    /* ---------- the column ---------- */
    .dashboard-wrapper {
        display: flex;
        align-items: flex-start;
        gap: var(--tk-gap);
        max-width: var(--tk-col);
        margin: 0 auto;
        padding: calc(var(--tk-nav-h) + var(--tk-gap)) var(--tk-gutter) 48px;
        min-height: 100vh;
        background: transparent;
        box-sizing: border-box;
    }

    /* ---------- sidebar: a card that stays in view ---------- */
    .dashboard-sidebar {
        position: sticky;
        top: calc(var(--tk-nav-h) + var(--tk-gap));
        left: auto;
        bottom: auto;
        flex: 0 0 var(--tk-sidebar-w);
        width: var(--tk-sidebar-w);
        max-height: calc(100vh - var(--tk-nav-h) - 2 * var(--tk-gap));
        overflow-y: auto;
        transform: none !important;
        background: var(--tk-card-bg);
        border: 1px solid var(--tk-border);
        border-radius: var(--tk-radius);
        box-shadow: var(--tk-shadow);
        padding: 0 0 12px;
        z-index: 5;
    }
    .dashboard-sidebar::-webkit-scrollbar { width: 4px; }
    .dashboard-sidebar::-webkit-scrollbar-thumb { background: #d6d9e2; }

    /* profile block */
    .dashboard-sidebar .sidebar-header {
        padding: 22px 20px 18px;
        margin: 0 0 8px;
        border-bottom: 1px solid var(--tk-border);
        background: linear-gradient(180deg, var(--tk-primary-soft), transparent);
        border-radius: var(--tk-radius) var(--tk-radius) 0 0;
    }
    .dashboard-sidebar .tutor-info { gap: 12px; }
    .dashboard-sidebar .tutor-avatar-large {
        width: 48px; height: 48px; flex: 0 0 48px;
        border-radius: 50%;
        padding: 2px;
        background: linear-gradient(135deg, #da0b4e, #4f46e5);
        border: 0;
        overflow: hidden;
    }
    .dashboard-sidebar .tutor-avatar-large img {
        width: 100%; height: 100%; object-fit: cover;
        border-radius: 50%; border: 2px solid #fff; background: #fff;
    }
    .dashboard-sidebar .tutor-details h4 {
        font-family: 'Poppins', sans-serif;
        font-size: 15px; font-weight: 600; color: var(--tk-text);
        margin: 0 0 2px; line-height: 1.25;
    }
    .dashboard-sidebar .tutor-details p { font-size: 12px; color: var(--tk-muted); margin: 0; }
    .dashboard-sidebar .tutor-details p i { color: #10b981; font-size: 8px; vertical-align: middle; margin-right: 4px; }

    /* menu */
    .dashboard-sidebar .sidebar-menu { padding: 0 12px; margin: 0; list-style: none; }
    .dashboard-sidebar .sidebar-menu-item { margin: 2px 0; }
    .dashboard-sidebar .sidebar-menu-link {
        display: flex; align-items: center; gap: 12px;
        padding: 10px 12px;
        border-radius: 10px;
        border-left: 0 !important;
        font-family: 'Poppins', sans-serif;
        font-size: 14px; font-weight: 500;
        color: #4b5563;
        line-height: 1.3;
        transition: background .15s ease, color .15s ease;
    }
    .dashboard-sidebar .sidebar-menu-link i {
        width: 20px; text-align: center; font-size: 15px; color: #9aa1ae;
        transition: color .15s ease;
    }
    .dashboard-sidebar .sidebar-menu-link:hover { background: #f5f6fa; color: var(--tk-text); }
    .dashboard-sidebar .sidebar-menu-link:hover i { color: var(--tk-primary); }
    .dashboard-sidebar .sidebar-menu-link.active {
        background: var(--tk-primary-soft);
        color: var(--tk-primary);
        font-weight: 600;
    }
    .dashboard-sidebar .sidebar-menu-link.active i { color: var(--tk-primary); }

    .dashboard-sidebar .menu-section-title {
        padding: 0 12px;
        margin: 4px 0 6px;
        font-family: 'Poppins', sans-serif;
        font-size: 11px; font-weight: 600;
        letter-spacing: .08em; text-transform: uppercase;
        color: #a0a6b3;
    }
    .dashboard-sidebar .sidebar-divider { height: 1px; background: var(--tk-border); margin: 12px 0; }

    /* Sessions sub-menu */
    .dashboard-sidebar .sidebar-dropdown-menu { padding: 2px 0 4px 20px; margin: 0; }
    .dashboard-sidebar .sidebar-dropdown-link {
        display: flex; align-items: center; gap: 10px;
        padding: 7px 12px; border-radius: 8px;
        font-size: 13px; color: var(--tk-muted);
    }
    .dashboard-sidebar .sidebar-dropdown-link i { width: 16px; text-align: center; font-size: 12px; color: #b0b5c0; }
    .dashboard-sidebar .sidebar-dropdown-link:hover,
    .dashboard-sidebar .sidebar-dropdown-link.active { background: #f5f6fa; color: var(--tk-primary); }
    .dashboard-sidebar .sidebar-dropdown-link.active i { color: var(--tk-primary); }

    /* ---------- content ---------- */
    .dashboard-main {
        flex: 1 1 auto;
        min-width: 0;            /* wide tables scroll inside their card, not the page */
        width: auto;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* page title banners and cards line up with the sidebar card */
    .dashboard-main > :first-child { margin-top: 0 !important; }

    /* stat tiles inside the page banners: share the narrower column instead of overflowing it */
    .dashboard-main .stats-grid > *,
    .dashboard-main .stat-card-modern { min-width: 0; }
    .dashboard-main .stats-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important; gap: 14px !important; }

    /* wide tables scroll inside their card */
    .dashboard-main .table-responsive,
    .dashboard-main .payh-table-container,
    .dashboard-main .dataTables_wrapper { overflow-x: auto !important; max-width: 100%; }
}

/* very wide screens: a touch more air between sidebar and content */
@media (min-width: 993px) and (max-width: 1399px) {
    :root { --tk-gutter: 24px; }
}

/* ==========================================================================
   Spacing & grids — one rhythm on every dashboard page (all screen sizes)
   24px between sections · 20px between tiles · labels stay on one line
   ========================================================================== */
.dashboard-main > :not(script):not(style):not(link):not([class*="modal"]):not([class*="overlay"]):not([class*="toast"]) {
    margin-top: 0 !important;
    margin-bottom: 24px !important;
}
.dashboard-main > :last-child { margin-bottom: 0 !important; }

/* tile / card grids */
.dashboard-main .td-stats-grid,
.dashboard-main .td-stats-row-2,
.dashboard-main .td-metrics-grid,
.dashboard-main .td-charts-grid,
.dashboard-main .td-actions-grid,
.dashboard-main .stats-grid,
.dashboard-main .card-grid,
.dashboard-main .tax-stats,
.dashboard-main .reward-stats,
.dashboard-main .profile-grid,
.dashboard-main .charts-row,
.dashboard-main .payment-grid {
    gap: 20px !important;
    margin-bottom: 24px;
}
/* number tiles: as many per row as fit at ≥220px each (4 → 2×2 when the column is narrow) */
.dashboard-main .td-stats-grid,
.dashboard-main .td-stats-row-2,
.dashboard-main .td-metrics-grid,
.dashboard-main .tax-stats,
.dashboard-main .reward-stats {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
}
/* chart cards: at least 320px each */
.dashboard-main .td-charts-grid,
.dashboard-main .td-actions-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)) !important;
}
.dashboard-main .stats-grid > *,
.dashboard-main .td-stats-grid > *,
.dashboard-main .td-stats-row-2 > *,
.dashboard-main .td-metrics-grid > * { min-width: 0; }

/* short labels on tiles, tabs and chips never break onto two lines */
.dashboard-main [class*="stat"] [class*="label"],
.dashboard-main [class*="stat-info"] p,
.dashboard-main [class*="stat-info"] span,
.dashboard-main [class*="stat-card"] p,
.dashboard-main [class*="stat-title"],
.dashboard-main [class*="tab"] > a,
.dashboard-main [class*="tab"] > button,
.dashboard-main button[class*="tab"],
.dashboard-main [class*="chip"] {
    white-space: nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* phones: tiles are narrow, so their labels may wrap instead of running out of the tile */
@media (max-width: 600px) {
    .dashboard-main [class*="stat"] [class*="label"],
    .dashboard-main [class*="stat-info"] p,
    .dashboard-main [class*="stat-info"] span,
    .dashboard-main [class*="stat-card"] p,
    .dashboard-main [class*="stat-title"] {
        white-space: normal !important;
        overflow-wrap: normal !important;
        word-break: normal !important;
        letter-spacing: .02em !important;
    }
    .dashboard-main [class*="stat-info"],
    .dashboard-main [class*="stat-card"] > div { min-width: 0 !important; }
}

/* inner parts never push the page wider than its column */
.dashboard-main [class*="tab-content"],
.dashboard-main [class*="tab-pane"] { max-width: 100%; min-width: 0; }
@media (min-width: 993px) {
    .dashboard-main { flex: 1 1 0% !important; width: auto !important; max-width: none !important; }
}
/* profile settings: rows use -12px side margins, give the tab pane matching padding */
.dashboard-main .profs-tab-pane { padding-left: 12px; padding-right: 12px; box-sizing: border-box; }
@media (min-width: 993px) {
    /* loaders that sit next to sidebar/main must not take a column (and a gap) of their own */
    .dashboard-wrapper > .preloader,
    .dashboard-wrapper > [class*="loader"] { position: fixed !important; }
}
/* tab bars: one row; on narrow screens they scroll sideways instead of wrapping */
.dashboard-main .tabs-navigation,
.dashboard-main [class*="tabs-nav"],
.dashboard-main [class*="tab-list"] {
    display: flex !important; flex-wrap: nowrap !important; gap: 6px !important;
    overflow-x: auto; scrollbar-width: none;
}
.dashboard-main .tabs-navigation::-webkit-scrollbar { display: none; }
.dashboard-main .tabs-navigation > .tab-btn { flex: 0 0 auto !important; padding: 8px 14px !important; }
