/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    /* Color Palette - Premium Dark & Gold */
    --primary-color: #D4AF37;
    /* Metallic Gold */
    --primary-hover: #B5952F;
    --background-dark: #0f172a;
    /* Slate 900 */
    --background-card: #1e293b;
    /* Slate 800 */
    --text-main: #f8fafc;
    /* Slate 50 */
    --text-muted: #94a3b8;
    /* Slate 400 */
    --danger: #ef4444;
    --success: #22c55e;
    --border-color: #334155;
    --input-bg: rgba(0, 0, 0, 0.2);

    /* Spacing & Radius */
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 20px;

    /* Shadows */
    --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-glow: 0 0 15px rgba(212, 175, 55, 0.3);
}

/* Light Mode Overrides */
body.light-mode {
    --background-dark: #f1f5f9;
    /* Slate 100 */
    --background-card: #ffffff;
    --text-main: #0f172a;
    /* Slate 900 */
    --text-muted: #64748b;
    /* Slate 500 */
    --border-color: #cbd5e1;
    /* Slate 300 */
    --input-bg: #ffffff;
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
}

/* Light Mode Specific High Contrast */
body.light-mode .stat-card,
body.light-mode .stat-card h3,
body.light-mode .stat-card .stat-value,
body.light-mode .stat-card p,
body.light-mode .stat-card span {
    color: #000000 !important;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    -webkit-tap-highlight-color: transparent;
    /* Fix flash on click */
}

/* ... existing body style ... */
body {
    background-color: var(--background-dark);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Utilities */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.flex {
    display: flex;
}

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

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

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

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

.grid {
    display: grid;
}

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

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

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

/* Desktop */

@media (max-width: 768px) {
    .grid-cols-3 {
        grid-template-columns: 1fr;
    }

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

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

.mt-4 {
    margin-top: 1rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.p-4 {
    padding: 1rem;
}

.p-6 {
    padding: 1.5rem;
}

.w-full {
    width: 100%;
}

.hidden {
    display: none !important;
}

/* Components */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    cursor: pointer;
    /* FIX: Only transition transform and shadow to avoid ANY color/gradient flash */
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: none;
    text-decoration: none;
    font-size: 1rem;
    position: relative;
    overflow: hidden;
    user-select: none;
    /* Prevent text selection flash */
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: #ffffff;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 25px rgba(212, 175, 55, 0.5);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover {
    background: rgba(212, 175, 55, 0.1);
}

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

.card {
    background-color: var(--background-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    transition: transform 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
}

/* Form Elements */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-main);
    font-size: 1rem;
    transition: border-color 0.3s, background-color 0.3s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.2);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

.modal-content {
    background: var(--background-card);
    padding: 2.5rem;
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 500px;
    position: relative;
    border: 1px solid var(--border-color);
    /* Mobile Scroll Fix */
    max-height: 90vh;
    overflow-y: auto;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.1);
    /* Subtle background for visibility */
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 1010;
    /* Ensure on top */
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-modal:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

/* RTL Modal Close Fix */
.rtl-mode .close-modal {
    right: auto;
    left: 15px;
}

/* Header/Nav */
.navbar {
    background: var(--background-card);
    /* Changed from fixed rgba for better light mode compat */
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 50;
    transition: background-color 0.3s ease;
}

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

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
    letter-spacing: -0.5px;
}

/* Specific Badge/Status */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status-active {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

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

.status-warning {
    background: rgba(234, 179, 8, 0.2);
    color: #eab308;
}

/* Captcha specific */
.captcha-container {
    background: var(--input-bg);
    padding: 10px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.captcha-question {
    font-family: monospace;
    font-size: 1.2rem;
    color: var(--primary-color);
    font-weight: bold;
    letter-spacing: 2px;
}

/* Theme Toggle Button */
.theme-toggle-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    top: auto;
    right: auto;
    z-index: 9999;
    background: var(--background-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.3s;
}

.lang-toggle-btn {
    position: fixed;
    bottom: 20px;
    left: 70px;
    /* 20px left + 40px width + 10px gap */
    top: auto;
    right: auto;
    z-index: 9999;
    background: var(--background-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: bold;
    transition: all 0.3s;
}

.theme-toggle-btn:hover,
.lang-toggle-btn:hover {
    transform: rotate(30deg);
    border-color: var(--primary-color);
}

/* Mobile Overrides */
@media (max-width: 768px) {
    .theme-toggle-btn {
        bottom: 130px !important;
        /* Move up to stack */
        left: 20px !important;
        right: auto !important;
        top: auto !important;
    }

    .lang-toggle-btn {
        bottom: 80px !important;
        /* Under theme button */
        left: 20px !important;
        /* Aligned vertically */
        right: auto !important;
        top: auto !important;
    }
}

/* --- RTL MODE (Arabic) --- */
.rtl-mode {
    direction: rtl;
    text-align: right;
    font-family: 'Cairo', 'Tajawal', sans-serif;
}

.rtl-mode .dashboard-grid {
    grid-template-columns: 1fr 250px;
}

.rtl-mode .sidebar {
    order: 2;
    margin-right: 20px;
    margin-left: 0;
}

/* Floating Buttons Flip */
.rtl-mode .theme-toggle-btn {
    left: auto;
    right: 20px;
}

.rtl-mode .lang-toggle-btn {
    left: auto;
    right: 70px;
}

@media (max-width: 768px) {
    .rtl-mode .dashboard-grid {
        display: flex;
        flex-direction: column;
    }

    .rtl-mode .sidebar {
        order: -1 !important;
        /* Force Top on Mobile */
        margin: 0;
    }

    .rtl-mode .theme-toggle-btn {
        left: 20px;
        right: auto;
    }

    .rtl-mode .lang-toggle-btn {
        left: 20px;
        right: auto;
    }
}