/* style.css - Unified Professional Design for Youth Platform */
:root {
    /* Main Palette - Eye Friendly & Modern */
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #eff6ff;
    --secondary: #10b981;
    --secondary-dark: #059669;
    --accent: #f59e0b;
    
    /* Backgrounds - Light Mode (Default) */
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-header: #ffffff;
    --bg-input: #ffffff;
    
    /* Text Colors - Light Mode */
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --text-on-primary: #ffffff;
    
    /* Borders & Dividers */
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
    
    /* Status Colors */
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    
 /* Shadows & Effects */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    
    --bg-surface: #f1f5f9; /* Semantic variable for surfaces like th */
    
    /* Sizing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    /* Transitions */
    --transition: all 0.3s ease;
    
    /* Layout Constants */
    --sidebar-width: 280px;
    --header-height: 70px;
}

/* Dark Mode Overrides */
[data-theme="dark"] {
    --bg-body: #020617; /* Darker background for better contrast */
    --bg-card: #0f172a;
    --bg-sidebar: #0f172a;
    --bg-header: #0f172a;
    --bg-input: #1e293b;
    
    --text-main: #ffffff; /* Pure white for maximum clarity */
    --text-muted: #e2e8f0; /* Even brighter muted text (Slate 200) */
    --text-light: #94a3b8; /* Slate 400 */
    
    --border-color: #1e293b;
    --border-hover: #334155;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.5);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5);
    --primary-light: rgba(37, 99, 235, 0.2);
    --bg-surface: #1e293b;
}

/* RTL Support (Default) */
[dir="rtl"] {
    font-family: 'Cairo', sans-serif;
}

/* LTR Support (English) */
[dir="ltr"] {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

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

img, video, canvas, svg {
    max-width: 100%;
    height: auto;
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    transition: var(--transition);
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-body);
}
::-webkit-scrollbar-thumb {
    background: var(--text-light);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.3;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

/* Layout Components */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    height: 100vh;
    position: fixed;
    top: 0;
    z-index: 1000;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

[dir="rtl"] .sidebar {
    right: 0;
    border-left: 1px solid var(--border-color);
}

[dir="ltr"] .sidebar {
    left: 0;
    border-right: 1px solid var(--border-color);
}

.sidebar-header {
    padding: 30px 20px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    width: 70px;
    height: 70px;
    background: #fff;
    border-radius: 50%;
    margin: 0 auto 15px;
    padding: 8px;
    box-shadow: var(--shadow-md);
    border: 2px solid var(--primary-light);
}

.sidebar-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

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

.nav-item {
    list-style: none;
    margin-bottom: 5px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-weight: 500;
    transition: var(--transition);
}

.nav-link i {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

[dir="rtl"] .nav-link:hover {
    transform: translateX(-5px);
}

[dir="ltr"] .nav-link:hover {
    transform: translateX(5px);
}

.nav-link:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.nav-link.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* Main Content Area */
.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

[dir="rtl"] .main-content {
    margin-right: var(--sidebar-width);
}

[dir="ltr"] .main-content {
    margin-left: var(--sidebar-width);
}

/* Header Styles */
.top-header {
    height: var(--header-height);
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 900;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Search Bar */
.search-wrapper {
    position: relative;
    width: 300px;
}

.search-wrapper input {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-body);
    font-family: inherit;
    transition: var(--transition);
}

[dir="rtl"] .search-wrapper input {
    padding: 10px 40px 10px 15px;
}

[dir="ltr"] .search-wrapper input {
    padding: 10px 15px 10px 40px;
}

.search-wrapper input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.search-wrapper i {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

[dir="rtl"] .search-wrapper i {
    right: 15px;
}

[dir="ltr"] .search-wrapper i {
    left: 15px;
}

/* User Profile in Header */
.user-profile-header {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: var(--radius-md);
}

.user-profile-header:hover {
    background: var(--primary-light);
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
}

.user-info-text {
    text-align: inherit;
}

.user-info-text h4 {
    font-size: 0.9rem;
    color: var(--text-main);
}

.user-info-text span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Content Wrapper */
.content-wrapper {
    padding: 30px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 20px;
    margin-bottom: 30px;
}

@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    .page-header .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 25px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    overflow: hidden;
}

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

/* Dashboard Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 55px;
    height: 55px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-info h3 {
    font-size: 1.8rem;
    margin-bottom: 2px;
}

.stat-info p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    font-family: inherit;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--secondary);
    color: #fff;
}

.btn-secondary:hover {
    background: var(--secondary-dark);
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

.btn-outline:hover {
    background: var(--bg-surface);
    border-color: var(--border-hover);
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

/* Charts */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-body);
    font-family: inherit;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: inherit;
    padding: 15px;
    background: var(--bg-surface);
    color: var(--text-main); /* Changed from text-muted to text-main for better visibility */
    font-weight: 700;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

tr:hover td {
    background: var(--primary-light);
}

/* Status Badges */
.badge {
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.badge-error { background: rgba(239, 68, 68, 0.1); color: var(--error); }
.badge-info { background: rgba(59, 130, 246, 0.1); color: var(--info); }

/* Modals & Popups */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    display: none;
    align-items: flex-start; /* Important for scrolling from top */
    justify-content: center;
    padding: 20px;
    overflow-y: auto; /* Enable vertical scroll */
    backdrop-filter: blur(5px);
    transition: var(--transition);
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    margin: 40px auto; /* Breathing room top/bottom */
    position: relative;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive Adjustments */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 950;
    display: none;
    backdrop-filter: blur(4px);
}

.overlay.active {
    display: block;
}

@media (max-width: 992px) {
    :root {
        --sidebar-width: 260px; /* Reduced width for mobile */
    }
    .sidebar {
        visibility: hidden; /* Hide completely when not active */
        opacity: 0;
    }
    .sidebar-header {
        padding: 20px 15px;
    }
    .sidebar-logo {
        width: 60px;
        height: 60px;
    }
    .sidebar-header h3 {
        font-size: 1.1rem;
    }
    .sidebar-header p {
        font-size: 0.8rem;
    }
    .nav-link {
        padding: 10px 12px;
        font-size: 0.95rem;
    }
    [dir="rtl"] .sidebar {
        transform: translateX(105%); /* Move a bit further than 100% */
        right: 0;
        left: auto;
    }
    [dir="ltr"] .sidebar {
        transform: translateX(-105%);
        left: 0;
        right: auto;
    }
    .sidebar.active {
        visibility: visible;
        opacity: 1;
        transform: translateX(0) !important;
        box-shadow: 0 0 50px rgba(0,0,0,0.3);
    }
    .main-content {
        margin-right: 0 !important;
        margin-left: 0 !important;
        width: 100%;
    }
    .search-wrapper {
        width: 180px;
    }
    #menuToggle {
        display: inline-flex !important;
    }
    .top-header {
        padding: 0 15px;
    }
    .content-wrapper {
        padding: 20px 15px;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .header-search {
        display: none;
    }
    .user-info-text span, .points-badge span:not(#userPoints) {
        display: none;
    }
    .search-wrapper {
        width: 140px;
    }
    .points-badge {
        padding: 5px 10px;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    :root {
        --sidebar-width: 240px; /* Even smaller for very small phones */
    }
    .search-wrapper {
        width: 100px;
    }
    .user-info-text {
        display: none;
    }
    .top-header {
        gap: 10px;
    }
    .header-right {
        gap: 10px;
    }
    .page-header h1 {
        font-size: 1.5rem;
    }
    /* Fix grid overflow on very small screens */
    [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
    .card {
        padding: 15px;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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