/* ========================================
   Modern Admin Dashboard - CSS v2.0
   Mata Shabari Trust Admin Panel
   ======================================== */

:root {
    /* Color Palette */
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --primary-dark: #1e40af;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    /* Neutrals */
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Spacing - Ultra Tightened */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 0.75rem;
    /* Further reduced from 0.875rem */
    --spacing-lg: 1rem;
    /* Further reduced from 1.25rem */
    --spacing-xl: 1.5rem;
    /* Further reduced from 1.75rem */
    --spacing-2xl: 2rem;
    /* Further reduced from 2.5rem */

    /* Border & Radius */
    --border-color: var(--gray-200);
    --border-radius: 0.5rem;
    --border-radius-lg: 0.75rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

    /* Transitions */
    --transition: all 0.3s ease;
}

/* Mobile Spacing Overrides for High Density */
@media (max-width: 640px) {
    :root {
        --spacing-md: 0.5rem;
        /* 8px */
        --spacing-lg: 0.75rem;
        /* 12px */
        --spacing-xl: 1rem;
        /* 16px */
        --spacing-2xl: 1.25rem;
        /* 20px */
    }
}

/* ========================================
   Global Styles
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
    font-size: 0.9375rem;
    overflow-x: hidden;
    width: 100%;
}

/* ========================================
   Admin Wrapper Layout
   ======================================== */

.admin-wrapper {
    display: flex;
    min-height: 100vh;
    background-color: var(--gray-50);
    width: 100%;
    overflow-x: hidden;
    position: relative;
}

/* ========================================
   Sidebar Styling
   ======================================== */

.sidebar {
    width: 260px;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: var(--white);
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
}

.sidebar-header {
    padding: var(--spacing-xl) var(--spacing-lg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    color: var(--white);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.125rem;
    transition: var(--transition);
}

.sidebar-logo:hover {
    opacity: 0.9;
}

.sidebar-logo i {
    font-size: 1.5rem;
}

.sidebar-logo-text {
    display: inline-block;
}

.sidebar-menu {
    list-style: none;
    padding: var(--spacing-sm) 0;
}

.sidebar-menu-item {
    margin: 0;
}

/* Section divider labels (Core / Content / Configuration) */
.sidebar-section-label {
    list-style: none;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.3);
    padding: 1rem var(--spacing-lg) 0.35rem;
    margin-top: 0.25rem;
}

.sidebar-menu-link {
    display: flex;
    align-items: center;
    padding: 0.58rem var(--spacing-lg);
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    transition: var(--transition);
    border-left: 3px solid transparent;
    gap: 0.7rem;
}

.sidebar-menu-link:hover,
.sidebar-menu-link.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--white);
    border-left-color: var(--white);
}

.sidebar-menu-icon {
    width: 18px;
    text-align: center;
    font-size: 0.82rem;
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.sidebar-menu-link:hover .sidebar-menu-icon,
.sidebar-menu-link.active .sidebar-menu-icon {
    opacity: 1;
}

.sidebar-menu-text {
    font-size: 0.84rem;
    font-weight: 500;
}

/* Logout item – extra top spacing + muted color */
.sidebar-logout-item {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-logout-item .sidebar-menu-link {
    color: rgba(255, 255, 255, 0.45);
}
.sidebar-logout-item .sidebar-menu-link:hover {
    color: #fff;
    background-color: rgba(239, 68, 68, 0.15);
    border-left-color: #ef4444;
}

/* Sidebar Responsive - MOBILE OPTIMIZED */
@media (max-width: 768px) {
    .sidebar {
        width: 260px;
        position: fixed;
        left: -260px;
        top: 0;
        height: 100vh;
        z-index: 1001;
        transition: left 0.3s ease;
    }

    .sidebar.expanded {
        left: 0;
    }

    .sidebar-logo-text {
        display: inline;
    }

    .sidebar-menu-text,
    .sidebar-header {
        display: inline;
    }

    .sidebar.expanded .sidebar-menu-text,
    .sidebar.expanded .sidebar-header {
        display: inline;
    }
}

/* Mobile Overlay for Sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.sidebar-overlay.show {
    display: block;
}

@media (max-width: 768px) {
    .sidebar-overlay.show {
        display: block;
    }
}

/* ========================================
   Top Navigation Bar
   ======================================== */

.topbar {
    position: fixed;
    top: 0;
    left: 260px;
    right: 0;
    height: 66px;
    background-color: var(--white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 var(--spacing-xl);
    z-index: 999;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

@media (max-width: 768px) {
    .topbar {
        left: 0;
        right: 0;
        padding: 0 var(--spacing-md);
        height: 62px;
    }
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

/* ── Hamburger Toggle ── */
.topbar-toggle {
    background: none;
    border: none;
    font-size: 1.15rem;
    color: var(--primary);
    cursor: pointer;
    transition: var(--transition);
    display: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: none;
    align-items: center;
    justify-content: center;
}

.topbar-toggle:hover {
    background: var(--gray-100);
    color: var(--primary-dark);
}

@media (max-width: 768px) {
    .topbar-toggle {
        display: flex;
    }
}

/* ── Brand ── */
.topbar-brand {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    transition: var(--transition);
    white-space: nowrap;
}

.topbar-brand:hover {
    color: var(--primary-dark);
}

@media (max-width: 640px) {
    .topbar-brand { font-size: 0.92rem; }
    .topbar-brand span { display: none; }
}

/* ── Icon Button (notifications bell etc) ── */
.topbar-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--gray-500);
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: background 0.2s, color 0.2s;
}
.topbar-icon-btn:hover {
    background: var(--gray-100);
    color: var(--primary);
}
/* Notification dot (uncomment <span> in nav.php to use) */
.topbar-notif-dot {
    position: absolute;
    top: 6px; right: 7px;
    width: 7px; height: 7px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid #fff;
}

/* ── Dropdown Wrapper (positions menu relative to trigger) ── */
.topbar-dropdown-wrap {
    position: relative;
}

/* ── User Trigger ── */
.topbar-user {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    border-radius: 9px;
    transition: background 0.2s;
    user-select: none;
}

.topbar-user:hover {
    background-color: var(--gray-100);
}

/* ── Avatar ── */
.topbar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    object-fit: cover;
    border: 2px solid var(--primary);
    flex-shrink: 0;
}

/* Fallback letter-avatar */
.topbar-avatar-fallback {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-color: transparent;
    box-shadow: 0 2px 6px rgba(37,99,235,0.3);
}

/* ── Name / Role text (hidden on small screens) ── */
.topbar-user-info {
    display: flex;
    flex-direction: column;
}
.topbar-user-name {
    font-weight: 600;
    color: var(--gray-900);
    font-size: 0.82rem;
    white-space: nowrap;
    line-height: 1.3;
}
.topbar-user-role {
    font-size: 0.7rem;
    color: var(--gray-500);
    white-space: nowrap;
    line-height: 1.3;
}

@media (max-width: 640px) {
    .topbar-user-info { display: none; }
    .topbar-user { padding: 0.3rem; }
}

/* ── Chevron (rotates when dropdown is open) ── */
.topbar-chevron {
    font-size: 0.6rem;
    color: var(--gray-400);
    transition: transform 0.2s ease;
}
.topbar-user.open .topbar-chevron {
    transform: rotate(180deg);
}

/* ── Dropdown Menu ── */
.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background-color: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    min-width: 195px;
    display: none;
    z-index: 1001;
    overflow: hidden;
    padding: 0.4rem 0;
}

.dropdown-menu.show {
    display: flex;
    flex-direction: column;
}

.dropdown-menu a {
    padding: 0.55rem 0.85rem;
    color: var(--gray-800);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.83rem;
}

.dropdown-menu a i {
    width: 15px;
    text-align: center;
    color: var(--gray-400);
    font-size: 0.78rem;
}

.dropdown-menu a:hover {
    background-color: var(--gray-50);
    color: var(--primary);
}
.dropdown-menu a:hover i {
    color: var(--primary);
}

/* Divider line */
.dropdown-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 0.25rem 0;
}

/* Logout row */
.dropdown-logout {
    color: var(--danger) !important;
    margin-top: 0.1rem;
}
.dropdown-logout i {
    color: var(--danger) !important;
}
.dropdown-logout:hover {
    background-color: #fef2f2 !important;
    color: var(--danger) !important;
}

/* ========================================
   Main Content Area
   ======================================== */

.main-content {
    margin-left: 260px;
    margin-top: 66px;
    flex: 1;
    padding: var(--spacing-lg);
    transition: var(--transition);
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
        margin-top: 62px;
        padding: var(--spacing-md);
    }
}

@media (max-width: 640px) {
    .main-content {
        padding: var(--spacing-sm);
    }
}

/* ── Footer Bar ── */
.admin-footer {
    margin-left: 260px;
    padding: 0.7rem var(--spacing-lg);
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
    font-size: 0.72rem;
    color: var(--gray-400);
    text-align: center;
}
@media (max-width: 768px) {
    .admin-footer { margin-left: 0; }
}

.content-wrapper {
    max-width: 100%;
}

/* ========================================
   Page Header
   ======================================== */

.page-header {
    margin-bottom: var(--spacing-xl);
}

@media (max-width: 640px) {
    .page-header {
        margin-bottom: var(--spacing-sm);
        /* Drastically reduce gap on mobile */
    }

    .page-title {
        font-size: 1.5rem;
        /* Slightly smaller title on mobile */
    }
}

.page-title {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: var(--spacing-sm);
}

.page-subtitle {
    font-size: 0.9375rem;
    color: var(--gray-500);
}

/* ========================================
   Grid Layout
   ======================================== */

.grid {
    display: grid;
    gap: var(--spacing-lg);
}

.grid-cols-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
}

.grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 1024px) {
    .grid-cols-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .grid-cols-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .grid {
        gap: var(--spacing-md);
    }

    .grid-cols-2,
    .grid-cols-3 {
        grid-template-columns: 1fr;
    }

    /* Allow 2 columns for stats and quick actions on mobile */
    .grid-cols-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ========================================
   Card Component
   ======================================== */

.card {
    background-color: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    margin-bottom: var(--spacing-lg);
}

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

.card-header {
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.card-body {
    padding: var(--spacing-lg);
}

/* ========================================
   Stat Cards
   ======================================== */

.stat-card {
    background-color: var(--white);
    border-left: 4px solid var(--primary);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

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

.stat-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: rgba(37, 99, 235, 0.1);
    color: var(--primary);
    font-size: 1.5rem;
    margin-bottom: var(--spacing-lg);
}

.stat-card-icon.success {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.stat-card-icon.warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.stat-card-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: var(--spacing-sm);
}

.stat-card-label {
    font-size: 0.875rem;
    color: var(--gray-500);
    font-weight: 500;
}

/* ========================================
   Table Styles
   ======================================== */

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.table thead {
    background-color: var(--gray-100);
    border-bottom: 2px solid var(--border-color);
}

.table th {
    padding: var(--spacing-md) var(--spacing-lg);
    text-align: left;
    font-weight: 600;
    color: var(--gray-900);
}

.table td {
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
}

.table tbody tr:hover {
    background-color: var(--gray-50);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* ========================================
   Button Styles
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--white);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-dark);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: var(--gray-200);
    color: var(--gray-900);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--gray-300);
}

.btn-success {
    background-color: var(--success);
    color: var(--white);
}

.btn-success:hover:not(:disabled) {
    background-color: #059669;
}

.btn-danger {
    background-color: var(--danger);
    color: var(--white);
}

.btn-danger:hover:not(:disabled) {
    background-color: #dc2626;
}

.btn-warning {
    background-color: var(--warning);
    color: var(--white);
}

.btn-warning:hover:not(:disabled) {
    background-color: #d97706;
}

.btn-info {
    background-color: var(--info);
    color: var(--white);
}

.btn-info:hover:not(:disabled) {
    background-color: var(--primary-dark);
}

.btn-sm {
    padding: var(--spacing-xs) var(--spacing-md);
    font-size: 0.8125rem;
}

.btn-lg {
    padding: var(--spacing-lg) var(--spacing-2xl);
    font-size: 1rem;
}

.btn-block {
    width: 100%;
}

/* ========================================
   Form Styles
   ======================================== */

.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 600;
    color: var(--gray-900);
}

.form-control,
.form-select,
textarea {
    width: 100%;
    padding: var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.9375rem;
    transition: var(--transition);
    background-color: var(--white);
    color: var(--gray-900);
    font-family: inherit;
}

.form-control:focus,
.form-select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea {
    resize: vertical;
    min-height: 120px;
}

.form-check {
    display: flex;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.form-check-input {
    margin-right: var(--spacing-md);
    cursor: pointer;
}

.form-check-label {
    cursor: pointer;
    user-select: none;
}

/* ========================================
   Alert Messages
   ======================================== */

.alert {
    padding: var(--spacing-lg);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-lg);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.alert-success {
    background-color: #d1fae5;
    border-left: 4px solid var(--success);
    color: #065f46;
}

.alert-danger {
    background-color: #fee2e2;
    border-left: 4px solid var(--danger);
    color: #7f1d1d;
}

.alert-warning {
    background-color: #fef3c7;
    border-left: 4px solid var(--warning);
    color: #78350f;
}

.alert-info {
    background-color: #dbeafe;
    border-left: 4px solid var(--info);
    color: #0c2340;
}

/* ========================================
   Badge Styles
   ======================================== */

.badge {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-primary {
    background-color: rgba(37, 99, 235, 0.2);
    color: var(--primary);
}

.badge-success {
    background-color: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.badge-danger {
    background-color: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.badge-warning {
    background-color: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

/* ========================================
   Utility Classes
   ======================================== */

.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.mb-0 {
    margin-bottom: 0;
}

.mb-1 {
    margin-bottom: var(--spacing-sm);
}

.mb-2 {
    margin-bottom: var(--spacing-md);
}

.mb-3 {
    margin-bottom: var(--spacing-lg);
}

.mb-4 {
    margin-bottom: var(--spacing-xl);
}

.mb-5 {
    margin-bottom: var(--spacing-2xl);
}

.mt-0 {
    margin-top: 0;
}

.mt-1 {
    margin-top: var(--spacing-sm);
}

.mt-2 {
    margin-top: var(--spacing-md);
}

.mt-3 {
    margin-top: var(--spacing-lg);
}

.mt-4 {
    margin-top: var(--spacing-xl);
}

.mt-5 {
    margin-top: var(--spacing-2xl);
}

.p-2 {
    padding: var(--spacing-md);
}

.p-3 {
    padding: var(--spacing-lg);
}

.p-4 {
    padding: var(--spacing-xl);
}

.text-muted {
    color: var(--gray-500);
}

.text-danger {
    color: var(--danger);
}

.text-success {
    color: var(--success);
}

.text-warning {
    color: var(--warning);
}

.text-info {
    color: var(--info);
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.justify-start {
    justify-content: flex-start;
}

.justify-end {
    justify-content: flex-end;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-around {
    justify-content: space-around;
}

.items-start {
    align-items: flex-start;
}

.items-end {
    align-items: flex-end;
}

.items-center {
    align-items: center;
}

.items-baseline {
    align-items: baseline;
}

.items-stretch {
    align-items: stretch;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gap-1 {
    gap: var(--spacing-sm);
}

.gap-2 {
    gap: var(--spacing-md);
}

.gap-3 {
    gap: var(--spacing-lg);
}

.gap-4 {
    gap: var(--spacing-xl);
}

/* ========================================
   Loading & Animations
   ======================================== */

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* ========================================
   Section Styles
   ======================================== */

.section {
    margin-bottom: var(--spacing-xl);
}

.section-header {
    margin-bottom: var(--spacing-xl);
}

.section-header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
}

.section-body {
    background-color: var(--white);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-sm);
}

/* ========================================
   Print Styles
   ======================================== */

@media print {

    .sidebar,
    .topbar,
    .btn,
    .form-control {
        display: none;
    }

    .main-content {
        margin-left: 0;
        margin-top: 0;
    }
}

/* ========================================
   Scrollbar Styling
   ======================================== */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

/* ========================================
   Dashboard Specific & Utilities
   ======================================== */

.w-10 {
    width: 2.5rem;
}

.h-10 {
    height: 2.5rem;
}

.rounded-full {
    border-radius: 9999px;
}

/* Dashboard Colors */
.bg-green-100 {
    background-color: #dcfce7;
}

.text-green-600 {
    color: #16a34a;
}

.bg-blue-100 {
    background-color: #dbeafe;
}

.text-blue-600 {
    color: #2563eb;
}

.bg-purple-100 {
    background-color: #f3e8ff;
}

.text-purple-600 {
    color: #9333ea;
}

.bg-orange-100 {
    background-color: #ffedd5;
}

.text-orange-600 {
    color: #ea580c;
}

/* Text Utilities */
.text-lg {
    font-size: 1.125rem;
}

.text-sm {
    font-size: 0.875rem;
}

.text-gray-700 {
    color: var(--gray-700);
}

.font-medium {
    font-weight: 500;
}

.font-semibold {
    font-weight: 600;
}

.text-decoration-none {
    text-decoration: none;
}

/* Hover Effects */
.hover\:shadow-md:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.transition-shadow {
    transition-property: box-shadow;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 300ms;
}

/* Mobile Optimizations */
@media (max-width: 640px) {
    .page-header.flex-between {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .page-header .text-right {
        text-align: left;
        width: 100%;
    }
}

/* ========================================
   Vibrant UI Components
   ======================================== */

/* Vibrant Status Badges */
.badge-status {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.85rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.badge-status.active,
.badge-status.success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.badge-status.inactive,
.badge-status.danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.badge-status.warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.badge-status.info {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.badge-status.primary {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Vibrant Action Buttons */
.btn-action {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.9rem;
    background-color: #f3f4f6;
    color: #6b7280;
    text-decoration: none;
    border: none;
    cursor: pointer;
}

.btn-action:hover {
    text-decoration: none;
}

.btn-action.edit {
    background-color: #eff6ff;
    color: #3b82f6;
}

.btn-action.edit:hover {
    background-color: #3b82f6;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.4);
}

.btn-action.delete {
    background-color: #fef2f2;
    color: #ef4444;
}

.btn-action.delete:hover {
    background-color: #ef4444;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.4);
}

.btn-action.view {
    background-color: #f5f3ff;
    color: #8b5cf6;
}

.btn-action.view:hover {
    background-color: #8b5cf6;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(139, 92, 246, 0.4);
}

.btn-action.success {
    background-color: #ecfdf5;
    color: #10b981;
}

.btn-action.success:hover {
    background-color: #10b981;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.4);
}

/* ========================================
   Input Group (compat layer)
   ======================================== */

.input-group {
    display: flex;
    align-items: center;
    border: 1px solid var(--gray-300);
    border-radius: 9px;
    overflow: hidden;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.input-group:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.input-group-prepend {
    display: flex;
    align-items: center;
}
.input-group .input-group-text {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    min-width: 38px;
    background: var(--gray-50);
    border-right: 1px solid var(--gray-200);
    color: var(--gray-400);
    font-size: 0.78rem;
    height: 100%;
    padding: 0;
}
.input-group .form-control,
.input-group .form-select {
    border: none;
    border-radius: 0;
    outline: none;
    box-shadow: none;
    padding: 0.55rem 0.6rem;
    font-size: 0.84rem;
    flex: 1;
    min-width: 0;
}
.input-group .form-control:focus,
.input-group .form-select:focus {
    border: none;
    box-shadow: none;
}

/* ========================================
   Utility Helpers
   ======================================== */
.rounded-pill { border-radius: 9999px !important; }
.shadow-sm  { box-shadow: var(--shadow-sm); }
.shadow-md  { box-shadow: var(--shadow-md); }
.shadow-lg  { box-shadow: var(--shadow-lg); }
.shadow-2xl { box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25); }
.border-0   { border: none !important; }
.border-b   { border-bottom: 1px solid var(--border-color) !important; }
.sticky-top { position: sticky; top: 76px; }

/* ========================================
   Mobile Form Polish (prevent iOS zoom)
   ======================================== */
@media (max-width: 640px) {
    .form-control,
    .form-select {
        font-size: 0.9rem;
        padding: 0.6rem 0.65rem;
    }
    .input-group .form-control,
    .input-group .form-select {
        font-size: 0.9rem;
    }
    .btn {
        font-size: 0.85rem;
    }
}
/* ========================================
   Extended Modern Components (From Gallery/Team)
   ======================================== */

/* -- Modern Card Header (Gradient) -- */
.card-header-gradient {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid var(--gray-200);
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-title-modern {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin: 0;
}
.card-title-modern i { color: var(--primary); font-size: 1.25rem; }

/* -- Section Title -- */
.section-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.section-title i { color: var(--primary); font-size: 1rem; }

/* -- Form Grid -- */
.form-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
@media (max-width: 768px) { .form-grid-2 { grid-template-columns: 1fr; } }

/* -- File Upload -- */
.file-upload-wrapper { position: relative; }
.file-upload-label {
    display: flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, var(--gray-50) 0%, var(--gray-100) 100%);
    border: 2px dashed var(--gray-300); border-radius: 8px;
    cursor: pointer; transition: all 0.2s ease;
    font-size: 0.875rem; color: var(--gray-600);
}
.file-upload-label:hover { background: linear-gradient(135deg, var(--gray-100) 0%, var(--gray-200) 100%); border-color: var(--primary); color: var(--primary); }
.file-upload-label i { font-size: 1.125rem; }
.file-upload-wrapper input[type='file'] { position: absolute; opacity: 0; pointer-events: none; }

.current-image-preview {
    margin-top: 0.75rem; padding: 0.75rem;
    background: var(--gray-50); border-radius: 8px;
    border: 1px solid var(--gray-200);
    display: flex; align-items: center; gap: 0.75rem;
}
.current-image-preview img { width: 80px; height: 80px; border-radius: 8px; object-fit: cover; border: 2px solid var(--gray-300); }
.current-image-info { font-size: 0.8rem; color: var(--gray-500); }

/* -- Modern Table (Gradient Header + Responsive Stack) -- */
.modern-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.modern-table thead { background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%); }
.modern-table thead th { padding: 1rem 1.25rem; text-align: left; font-size: 0.75rem; font-weight: 700; color: var(--gray-700); text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 2px solid var(--gray-200); white-space: nowrap; }
.modern-table tbody tr { transition: all 0.2s ease; border-bottom: 1px solid var(--gray-100); }
.modern-table tbody tr:hover { background-color: var(--gray-50); }
.modern-table tbody td { padding: 1rem 1.25rem; font-size: 0.875rem; color: var(--gray-700); vertical-align: middle; }

/* Responsive Table */
@media (max-width: 768px) {
    .modern-table thead { display: none; }
    .modern-table tbody tr { display: block; margin-bottom: 1rem; border: 1px solid var(--gray-200); border-radius: 8px; background: white; }
    .modern-table tbody td { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 1rem; border-bottom: 1px solid var(--gray-100); }
    .modern-table tbody td:last-child { border-bottom: none; }
    .modern-table tbody td::before { content: attr(data-label); font-weight: 700; color: var(--gray-700); font-size: 0.75rem; text-transform: uppercase; }
}

/* -- Search Wrapper -- */
.search-wrapper { position: relative; width: 280px; }
.search-icon { position: absolute; left: 0.875rem; top: 50%; transform: translateY(-50%); color: var(--gray-400); font-size: 0.875rem; pointer-events: none; }
.search-input { width: 100%; padding: 0.625rem 0.875rem 0.625rem 2.5rem; border: 1px solid var(--gray-300); border-radius: 8px; font-size: 0.875rem; transition: all 0.2s ease; }
.search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
@media (max-width: 768px) { .search-wrapper { width: 100%; } }

/* -- Thumbnails -- */
.list-thumb { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; border: 2px solid var(--gray-200); }
.list-info { display: flex; flex-direction: column; gap: 0.25rem; }
.list-name { font-weight: 600; color: var(--gray-900); }
.list-excerpt { font-size: 0.75rem; color: var(--gray-500); max-width: 200px; }


/* -- YouTube Video Specifics -- */
.yt-thumb-wrapper { position: relative; width: 120px; height: 68px; border-radius: 8px; overflow: hidden; border: 2px solid var(--gray-200); flex-shrink: 0; }
.yt-thumb-wrapper img { width: 100%; height: 100%; object-fit: cover; }
.yt-play-icon {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 32px; height: 32px; border-radius: 50%;
    background: rgba(239,68,68,0.85); display: flex; align-items: center; justify-content: center;
    color: white; font-size: 0.75rem;
}
.url-input-wrapper { position: relative; }
.url-prefix {
    position: absolute; left: 0; top: 0; bottom: 0;
    display: flex; align-items: center; padding: 0 0.75rem;
    background: var(--gray-100); border-right: 1px solid var(--gray-300);
    border-radius: 8px 0 0 8px; color: #ef4444; font-size: 0.875rem;
}
.url-input-wrapper .form-control { padding-left: 2.75rem; border-radius: 0 8px 8px 0; }
.video-id-link {
    font-family: 'Courier New', monospace; font-size: 0.75rem; color: var(--primary);
    background: #eff6ff; padding: 0.25rem 0.5rem; border-radius: 4px; border: 1px solid #bfdbfe;
    text-decoration: none; transition: all 0.2s; display: inline-flex; align-items: center; gap: 0.25rem;
}
.video-id-link:hover { background: var(--primary); color: white; }

/* -- Responsive Video Table -- */
@media (max-width: 768px) {
    .yt-thumb-wrapper { width: 90px; height: 52px; }
}

