:root {
    /* Light Theme (Default) */
    --primary-color: #6366f1; /* Indigo-500 */
    --primary-hover: #4f46e5; /* Indigo-600 */
    --primary-light: #e0e7ff; /* Indigo-100 */

    --bg-color: #f8fafc; /* Slate-50 */
    --card-bg: #ffffff;
    --sidebar-bg: #ffffff;

    --text-primary: #1e293b; /* Slate-800 */
    --text-secondary: #64748b; /* Slate-500 */
    --text-inverted: #ffffff;

    --border-color: #e2e8f0; /* Slate-200 */
    --input-bg: #ffffff;

    --danger-color: #ef4444;
    --success-color: #22c55e;
    --warning-color: #f59e0b;

    /* Shadows & Radius */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --border-radius: 0.75rem; /* 12px */
    --transition: all 0.3s ease;

    --success-bg: #dcfce7;
    --success-text: #166534;
    --error-bg: #fee2e2;
    --error-text: #991b1b;
    --warning-bg: #fef3c7;
    --warning-text: #92400e;
}

[data-theme="dark"] {
    --primary-color: #818cf8; /* Indigo-400 */
    --primary-hover: #6366f1; /* Indigo-500 */
    --primary-light: #1e1b4b; /* Indigo-950 */

    --bg-color: #0f172a; /* Slate-900 */
    --card-bg: #1e293b; /* Slate-800 */
    --sidebar-bg: #020617; /* Slate-950 */

    --text-primary: #f1f5f9; /* Slate-100 */
    --text-secondary: #94a3b8; /* Slate-400 */
    --text-inverted: #f1f5f9;

    --border-color: #334155; /* Slate-700 */
    --input-bg: #0f172a;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);

    --success-bg: #064e3b;
    --success-text: #dcfce7;
    --error-bg: #7f1d1d;
    --error-text: #fecaca;
    --warning-bg: #451a03;
    --warning-text: #fcd34d;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    display: flex;
    min-height: 100vh; /* Changed to min-height for robustness */
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--text-secondary);
    border-radius: 4px;
    opacity: 0.5;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-primary); }

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease-in-out;
    z-index: 50;
    flex-shrink: 0;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(148, 163, 184, 0.4);
    height: 70px;
}

.sidebar-menu {
    list-style: none;
    padding: 1rem 0;
    overflow-y: auto;
    flex: 1;
}

.menu-item { margin-bottom: 0.25rem; }

.menu-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
    border-left: 3px solid transparent;
}

.menu-link:hover, .menu-link.active {
    color: var(--text-primary);
    background-color: var(--primary-light);
}

.menu-link.active {
    border-left-color: var(--primary-color);
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.1) 0%, transparent 100%);
}

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

/* Submenu */
.submenu-list {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background-color: rgba(148, 163, 184, 0.12);
}

.submenu-list.open {
    max-height: 1000px; /* Increased to allow more items */
    transition: max-height 0.5s ease-in;
}

.menu-category {
    padding: 1.5rem 1rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.menu-category:hover { color: var(--text-primary); }
.menu-category i { transition: transform 0.3s; }
.menu-category.active i { transform: rotate(180deg); }

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    /* overflow: hidden; Removed to allow body scroll if needed */
    position: relative;
    margin-left: 260px; /* Match sidebar width */
    width: calc(100% - 260px);
}

.header {
    height: 70px;
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    transition: background-color 0.3s, border-color 0.3s;
}

.header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.avatar {
    width: 36px;
    height: 36px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.5rem;
    border-radius: 50%;
    transition: color 0.2s, background-color 0.2s;
}

.icon-btn:hover {
    color: var(--primary-color);
    background-color: var(--primary-light);
}

/* Result Areas & Content */
.content-body {
    padding: 2rem;
    flex: 1;
    overflow-y: auto;
}

.result-area {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    animation: fadeIn 0.5s ease-out;
}

.result-box {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-top: 1rem;
}

/* Components */
.card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

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

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    gap: 0.5rem;
    font-size: 0.875rem;
    text-decoration: none;
}

.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
.btn-block { width: 100%; }

.btn-primary { background-color: var(--primary-color); color: white; }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.7; cursor: not-allowed; }

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}
.btn-secondary:hover {
    background-color: var(--bg-color);
    color: var(--text-primary);
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 0.9rem;
}
.btn-text:hover { text-decoration: underline; }

.form-group { margin-bottom: 1rem; }
.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--input-bg);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.form-input.with-icon { padding-left: 2.5rem; }

.input-icon-wrapper { position: relative; }
.input-icon {
    position: absolute;
    left: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

/* Checkbox */
.checkbox-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.9rem;
}
.checkbox-container input { margin-right: 0.5rem; }

/* Login Styles */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at top right, rgba(99, 102, 241, 0.1), transparent 40%), radial-gradient(circle at bottom left, rgba(99, 102, 241, 0.1), transparent 40%);
}

.login-container {
    background-color: var(--card-bg);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    border-radius: 1.5rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    animation: fadeIn 0.6s ease-out;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    filter: drop-shadow(0 4px 6px rgba(99, 102, 241, 0.3));
}

.login-header h2 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.login-form .form-group {
    margin-bottom: 1.5rem;
}

.login-form .form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.input-icon-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.form-input:focus + .input-icon,
.form-input:focus ~ .input-icon {
    color: var(--primary-color);
}

.form-input.with-icon {
    padding-left: 2.8rem;
}

.btn-block {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.85rem;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.025em;
}

.login-footer {
    margin-top: 2rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
}

.login-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.login-footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.login-error {
    background-color: rgba(239, 68, 68, 0.1);
    border-left: 4px solid var(--danger-color);
    color: var(--danger-color);
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Files Grid (EarnVids) */
.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 1.5rem;
    padding: 1rem 0;
}

.ev-item {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}
.ev-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Toast */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background-color: var(--card-bg);
    color: var(--text-primary);
    padding: 1rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-left: 4px solid var(--primary-color);
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
    width: 300px;
}
.toast.show { transform: translateX(0); }
.toast-success { border-left-color: var(--success-color); }
.toast-success i { color: var(--success-color); }
.toast-error { border-left-color: var(--danger-color); }
.toast-error i { color: var(--danger-color); }

/* Loader */
.loader {
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff;
    border-bottom-color: transparent;
    border-radius: 50%;
    display: none;
    animation: rotation 1s linear infinite;
    margin-right: 0.5rem;
}
@keyframes rotation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Modal Styles */
.modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 99999 !important;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(4px);
    padding: 1rem;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal-container {
    background-color: var(--card-bg);
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    width: 100%;
    max-width: 500px;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-overlay.show .modal-container {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.02);
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.2;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    margin: -0.5rem -0.5rem -0.5rem 0;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.modal-close:hover {
    color: var(--text-primary);
    background-color: rgba(0,0,0,0.05);
}

.modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-body p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin: 0;
}

.modal-body input.form-input {
    width: 100%;
    font-size: 1rem;
    padding: 0.75rem 1rem;
}

.modal-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    background-color: rgba(0,0,0,0.02);
    border-bottom-left-radius: 1rem;
    border-bottom-right-radius: 1rem;
}

.modal-footer .btn {
    min-width: 100px;
}

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

.hidden { display: none !important; }

/* Responsive */
@media (min-width: 769px) {
    .hidden-desktop { display: none !important; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; width: 100%; padding: 1rem; }
    .files-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}

/* Stats Grid */
.stats-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 2rem;
    flex-direction: row; /* Ensure horizontal layout */
    align-items: stretch; /* Make cards same height */
    width: 100%;
}

.stat-card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1 1 250px; /* Grow, shrink, base width */
    min-width: 0; /* Prevent overflow */
}

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

.stat-card.primary { border-left: 4px solid var(--primary-color); }
.stat-card.success { border-left: 4px solid var(--success-color); }
.stat-card.warning { border-left: 4px solid var(--warning-color); }
.stat-card.danger { border-left: 4px solid var(--danger-color); }

.stat-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}
.stat-card.success .stat-icon { color: var(--success-color); }

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}
