/* ==========================================================================
   Apple-Style Light Theme - Mentora App Admin Panel
   Aesthetics: Minimal, Clean, Soft Shadows, Rounded Borders, Subtle Purple Accents
   Fully Mobile-Friendly & Responsive Layout
   ========================================================================== */

:root {
    --bg-app: #f5f5f7;
    --bg-card: #ffffff;
    --bg-card-glass: rgba(255, 255, 255, 0.92);
    --bg-sidebar: #ffffff;
    --border-subtle: #e5e5ea;
    --border-card: rgba(0, 0, 0, 0.06);
    
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --text-muted: #a1a1a6;
    
    /* Apple Subtle Purple & Modern Accents */
    --accent-purple: #5e5ce6;
    --accent-purple-hover: #4b48d6;
    --accent-purple-subtle: #f0f0ff;
    --accent-purple-border: #d4d3fa;
    
    --accent-blue: #0071e3;
    --accent-green: #34c759;
    --accent-orange: #ff9500;
    --accent-red: #ff3b30;

    --font-system: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 26px;
    
    --shadow-subtle: 0 2px 10px rgba(0, 0, 0, 0.03);
    --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.05), 0 2px 6px -1px rgba(0, 0, 0, 0.02);
    --shadow-hover: 0 10px 25px -4px rgba(0, 0, 0, 0.08), 0 4px 10px -2px rgba(0, 0, 0, 0.03);
    --shadow-floating: 0 14px 34px rgba(94, 92, 230, 0.18);
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: var(--font-system);
    background-color: var(--bg-app);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.015em;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* Layout Structure */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    position: relative;
}

/* Sidebar Desktop Default */
.app-sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    padding: 20px 18px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.sidebar-header .brand-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #7c3aed, #5e5ce6);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 1.15rem;
    box-shadow: 0 4px 12px rgba(94, 92, 230, 0.35);
    flex-shrink: 0;
}

.brand-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin: 0;
    line-height: 1.2;
}

.brand-subtitle {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 10px 14px;
}

.nav-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 16px 12px 6px;
}

.app-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    font-size: 0.86rem;
    font-weight: 500;
    color: #48484a;
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 2px;
    cursor: pointer;
}

.app-nav-link i {
    font-size: 1.05rem;
    color: var(--text-secondary);
    transition: all 0.18s ease;
}

.app-nav-link:hover {
    background-color: #f2f2f7;
    color: var(--text-primary);
}

.app-nav-link:hover i {
    color: var(--accent-purple);
}

.app-nav-link.active {
    background-color: var(--accent-purple-subtle);
    color: var(--accent-purple);
    font-weight: 600;
}

.app-nav-link.active i {
    color: var(--accent-purple);
}

/* Collapsible Submenu Group Styling */
.app-nav-group {
    margin-bottom: 3px;
}

.app-nav-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 9px 12px;
    font-size: 0.86rem;
    font-weight: 500;
    color: #48484a;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    text-align: left;
}

.app-nav-group-toggle:hover {
    background-color: #f2f2f7;
    color: var(--text-primary);
}

.app-nav-group-toggle:hover .group-icon {
    color: var(--accent-purple);
}

.app-nav-group-toggle .group-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-nav-group-toggle .group-icon {
    font-size: 1.05rem;
    color: var(--text-secondary);
    transition: all 0.18s ease;
}

.app-nav-group-toggle .group-chevron {
    font-size: 0.72rem;
    color: #a1a1a6;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-nav-group.is-open .app-nav-group-toggle .group-chevron {
    transform: rotate(90deg);
}

.app-nav-group.active-group .app-nav-group-toggle {
    color: var(--accent-purple);
    font-weight: 600;
}

.app-nav-group.active-group .group-icon {
    color: var(--accent-purple);
}

.app-nav-submenu {
    display: none;
    padding: 3px 0 3px 20px;
    position: relative;
}

.app-nav-submenu::before {
    content: '';
    position: absolute;
    left: 21px;
    top: 4px;
    bottom: 4px;
    width: 1.5px;
    background-color: #e5e5ea;
    border-radius: 1px;
}

.app-nav-group.is-open .app-nav-submenu {
    display: block;
}

.app-nav-sublink {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 12px;
    font-size: 0.82rem;
    font-weight: 500;
    color: #636366;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all 0.15s ease;
    margin-bottom: 1px;
    position: relative;
}

.app-nav-sublink i {
    font-size: 0.85rem;
    color: #8e8e93;
    transition: all 0.15s ease;
}

.app-nav-sublink:hover {
    color: var(--text-primary);
    background-color: #f2f2f7;
}

.app-nav-sublink:hover i {
    color: var(--accent-purple);
}

.app-nav-sublink.active {
    color: var(--accent-purple);
    font-weight: 600;
    background-color: var(--accent-purple-subtle);
}

.app-nav-sublink.active i {
    color: var(--accent-purple);
}


/* Sidebar Backdrop Overlay for Mobile */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1035;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.sidebar-backdrop.show {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Main Content Area */
.app-main {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: calc(100% - 260px);
    transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Topbar */
.app-topbar {
    height: 64px;
    background: var(--bg-card-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
}

.page-breadcrumb-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.02em;
}

.topbar-badge {
    background: #f2f2f7;
    color: var(--text-secondary);
    font-size: 0.78rem;
    padding: 6px 14px;
    border-radius: 999px;
    font-weight: 500;
}

/* Content Container */
.app-content {
    padding: 24px 28px 40px;
    flex: 1;
}

/* Apple Cards */
.apple-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-card);
    box-shadow: var(--shadow-card);
    padding: 22px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-bottom: 20px;
}

.apple-card:hover {
    box-shadow: var(--shadow-hover);
}

.apple-card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 16px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border-subtle);
}

.apple-card-title {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--text-primary);
    margin: 0;
}

.apple-card-subtitle {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 3px;
    margin-bottom: 0;
}

/* Stats Widgets */
.stat-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border-card);
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.stat-icon-wrapper {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 14px;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: -0.01em;
}

/* Buttons */
.btn-apple-primary {
    background: linear-gradient(135deg, #6366f1, #5e5ce6);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    padding: 9px 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 14px rgba(94, 92, 230, 0.25);
    transition: all 0.18s ease;
}

.btn-apple-primary:hover {
    background: linear-gradient(135deg, #4f46e5, #4b48d6);
    color: #ffffff;
    box-shadow: 0 6px 18px rgba(94, 92, 230, 0.35);
    transform: translateY(-1px);
}

.btn-apple-light {
    background: #f2f2f7;
    color: #1d1d1f;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    padding: 8px 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s ease;
}

.btn-apple-light:hover {
    background: #e5e5ea;
    color: #1d1d1f;
}

.btn-apple-outline {
    background: transparent;
    color: var(--accent-purple);
    border: 1.5px solid var(--accent-purple-border);
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    padding: 8px 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s ease;
}

.btn-apple-outline:hover {
    background: var(--accent-purple-subtle);
    border-color: var(--accent-purple);
    color: var(--accent-purple);
}

/* Forms & Inputs */
.form-control, .form-select {
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border-subtle);
    padding: 9px 13px;
    font-size: 0.875rem;
    background-color: #fbfbfd;
    color: var(--text-primary);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus, .form-select:focus {
    background-color: #ffffff;
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(94, 92, 230, 0.15);
    outline: none;
}

.form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #3a3a3c;
    margin-bottom: 5px;
}

/* Apple Modals */
.modal-content {
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-card);
    box-shadow: var(--shadow-floating);
    overflow: hidden;
}

.modal-header {
    border-bottom: 1px solid var(--border-subtle);
    padding: 18px 22px;
    background: #ffffff;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.modal-body {
    padding: 20px 22px;
    background: #ffffff;
}

.modal-footer {
    border-top: 1px solid var(--border-subtle);
    padding: 14px 22px;
    background: #fbfbfd;
}

/* Status Badges */
.badge-pill-apple {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 999px;
    letter-spacing: 0.02em;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.badge-pill-active {
    background-color: #e3faea;
    color: #1b873f;
    border: 1px solid #c3f3d0;
}

.badge-pill-inactive {
    background-color: #f2f2f7;
    color: #636366;
    border: 1px solid #e5e5ea;
}

.badge-tag-ultra {
    background-color: #fef0e6;
    color: #d95300;
    border: 1px solid #fcdcc6;
}

.badge-tag-important {
    background-color: #fdf3d8;
    color: #996500;
    border: 1px solid #fae6a8;
}

.badge-tag-normal {
    background-color: #f0f0f5;
    color: #55555c;
    border: 1px solid #e0e0e8;
}

/* DataTables Apple Styling */
.table-responsive {
    border-radius: var(--radius-md);
    -webkit-overflow-scrolling: touch;
}

table.dataTable {
    border-collapse: separate !important;
    border-spacing: 0 !important;
    width: 100% !important;
}

table.dataTable thead th {
    background-color: #fafafc !important;
    color: var(--text-secondary) !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    padding: 12px 14px !important;
    border-bottom: 1px solid var(--border-subtle) !important;
    border-top: none !important;
    white-space: nowrap;
}

table.dataTable tbody td {
    padding: 12px 14px !important;
    font-size: 0.875rem !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid #f2f2f7 !important;
    vertical-align: middle !important;
}

table.dataTable tbody tr:hover {
    background-color: #fbfbfd !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--accent-purple) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: var(--radius-sm) !important;
    font-weight: 600 !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: #f2f2f7 !important;
    color: var(--text-primary) !important;
    border: none !important;
    border-radius: var(--radius-sm) !important;
}

/* Action Icon Buttons */
.action-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-subtle);
    background: #ffffff;
    color: var(--text-secondary);
    transition: all 0.15s ease;
    cursor: pointer;
    flex-shrink: 0;
}

.action-btn:hover {
    background: var(--accent-purple-subtle);
    color: var(--accent-purple);
    border-color: var(--accent-purple-border);
}

.action-btn.btn-delete:hover {
    background: #feeceb;
    color: var(--accent-red);
    border-color: #fcc2be;
}

/* ==========================================================================
   📱 Mobile & Responsive Viewport Rules (Strict Overrides)
   ========================================================================== */

@media (max-width: 991.98px) {
    /* Hide sidebar completely offscreen to the left */
    .app-sidebar {
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 275px !important;
        max-width: 85vw !important;
        transform: translateX(-100%) !important;
        box-shadow: 6px 0 25px rgba(0, 0, 0, 0.18) !important;
        z-index: 9999 !important;
        display: flex !important;
    }

    /* When class added via JS toggle, slide-in sidebar */
    .app-sidebar.sidebar-mobile-open {
        transform: translateX(0) !important;
    }

    /* Main container full width */
    .app-main {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .app-topbar {
        padding: 0 16px !important;
        height: 60px !important;
    }

    .page-breadcrumb-title {
        font-size: 1rem !important;
    }

    .app-content {
        padding: 16px 12px 30px !important;
    }

    .apple-card {
        padding: 16px 14px !important;
        border-radius: var(--radius-md) !important;
        margin-bottom: 16px !important;
    }

    .stat-card {
        padding: 16px !important;
        border-radius: var(--radius-md) !important;
    }

    .stat-value {
        font-size: 1.45rem !important;
    }

    .stat-icon-wrapper {
        width: 38px !important;
        height: 38px !important;
        font-size: 1.1rem !important;
        margin-bottom: 10px !important;
    }

    /* Modal adjustments on mobile */
    .modal-dialog {
        margin: 10px !important;
    }

    .modal-content {
        border-radius: var(--radius-lg) !important;
    }

    .modal-header, .modal-body, .modal-footer {
        padding: 14px 16px !important;
    }

    /* DataTables controls responsive wrap */
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        float: none !important;
        text-align: left !important;
        margin-bottom: 10px !important;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        margin-left: 0 !important;
    }

    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        float: none !important;
        text-align: center !important;
        margin-top: 10px !important;
    }
}

@media (max-width: 575.98px) {
    .apple-card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .apple-card-header .btn {
        width: 100%;
    }

    /* Resource row stacking on mobile */
    .resource-row {
        flex-direction: column;
        align-items: stretch !important;
        gap: 8px !important;
    }

    .resource-row > div {
        flex: 1 1 100% !important;
        width: 100% !important;
    }
}
