/* Dark Mode System for CONSORT Reviewer AI */

/* ===== DARK MODE VARIABLES ===== */
:root {
 /* Light Mode (Default) */
 --bg-primary: #ffffff;
 --bg-secondary: #f8f9fa;
 --text-primary: #212529;
 --text-secondary: #6c757d;
 --border-color: #dee2e6;
 --shadow-color: rgba(0, 0, 0, 0.1);
 
 /* Glass Mode Variables */
 --glass-bg-light: rgba(255, 255, 255, 0.15);
 --glass-bg-dark: rgba(0, 0, 0, 0.15);
 --glass-border-light: rgba(255, 255, 255, 0.2);
 --glass-border-dark: rgba(255, 255, 255, 0.1);
}

/* Dark Mode Variables */
[data-theme="dark"] {
 --bg-primary: #1a1a1a;
 --bg-secondary: #2d2d2d;
 --text-primary: #ffffff;
 --text-secondary: #b0b0b0;
 --border-color: #404040;
 --shadow-color: rgba(0, 0, 0, 0.3);
 
 /* Glass adjustments for dark mode */
 --glass-bg: var(--glass-bg-dark);
 --glass-border: var(--glass-border-dark);
 --glass-hover-bg: rgba(255, 255, 255, 0.1);
 --glass-hover-border: rgba(255, 255, 255, 0.2);
}

/* ===== DARK MODE TOGGLE BUTTON ===== */
.theme-toggle {
 position: fixed;
 top: 20px;
 right: 20px;
 z-index: 1000;
 background: rgba(255, 255, 255, 0.1);
 backdrop-filter: blur(20px);
 border: 1px solid rgba(255, 255, 255, 0.2);
 border-radius: 50px;
 padding: 0.5rem;
 cursor: pointer;
 transition: all 0.3s ease;
 display: flex;
 align-items: center;
 color: white;
 box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.theme-toggle:hover {
 background: rgba(255, 255, 255, 0.2);
 border-color: rgba(255, 255, 255, 0.3);
 transform: translateY(-2px);
 box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}
 gap: 0.5rem;
 color: white;
 font-size: 0.9rem;
 min-width: 120px;
 justify-content: center;
}

.theme-toggle:hover {
 background: var(--glass-hover-bg);
 border-color: var(--glass-hover-border);
 transform: scale(1.05);
}

.theme-toggle i {
 font-size: 1.2rem;
 transition: all 0.3s ease;
}

.theme-toggle.light-mode i.bi-sun-fill {
 color: #ffd700;
 transform: rotate(0deg);
}

.theme-toggle.dark-mode i.bi-moon-fill {
 color: #87ceeb;
 transform: rotate(180deg);
}

/* ===== THEME TRANSITION ===== */
* {
 transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ===== DARK MODE ADJUSTMENTS ===== */
[data-theme="dark"] body {
 background: var(--bg-primary);
 color: var(--text-primary);
}

[data-theme="dark"] .glass-background {
 background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

[data-theme="dark"] .glass-card {
 background: rgba(255, 255, 255, 0.05);
 border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .glass-card:hover {
 background: rgba(255, 255, 255, 0.1);
 border-color: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .glass-input {
 background: rgba(255, 255, 255, 0.05);
 border-color: rgba(255, 255, 255, 0.1);
 color: white;
}

[data-theme="dark"] .glass-input:focus {
 background: rgba(255, 255, 255, 0.1);
 border-color: rgba(255, 255, 255, 0.3);
}

[data-theme="dark"] .glass-navbar {
 background: rgba(0, 0, 0, 0.2);
 border-bottom-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .glass-table {
 background: rgba(255, 255, 255, 0.05);
 border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .glass-table th {
 background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .glass-table td {
 border-bottom-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .glass-modal {
 background: rgba(0, 0, 0, 0.3);
 border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .glass-dropdown {
 background: rgba(0, 0, 0, 0.3);
 border-color: rgba(255, 255, 255, 0.1);
}

/* ===== DARK MODE BUTTONS ===== */
[data-theme="dark"] .btn {
 background: var(--bg-secondary);
 border-color: var(--border-color);
 color: var(--text-primary);
 transition: all 0.3s ease;
}

[data-theme="dark"] .btn:hover {
 background: var(--border-color);
 border-color: var(--text-secondary);
 transform: translateY(-1px);
 box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .btn-primary {
 background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
 border: none;
 color: white;
}

[data-theme="dark"] .btn-primary:hover {
 background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
 transform: translateY(-2px);
 box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

[data-theme="dark"] .btn-secondary {
 background: rgba(255, 255, 255, 0.1);
 border: 1px solid rgba(255, 255, 255, 0.2);
 color: white;
 backdrop-filter: blur(10px);
}

[data-theme="dark"] .btn-secondary:hover {
 background: rgba(255, 255, 255, 0.2);
 border-color: rgba(255, 255, 255, 0.3);
 transform: translateY(-1px);
}

/* ===== DARK MODE DROPDOWN MENUS ===== */
[data-theme="dark"] .dropdown-menu {
 background: rgba(45, 45, 45, 0.95);
 backdrop-filter: blur(20px);
 border: 1px solid rgba(255, 255, 255, 0.1);
 border-radius: 12px;
 box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
 padding: 0.5rem 0;
}

[data-theme="dark"] .dropdown-item {
 color: var(--text-primary);
 padding: 0.75rem 1rem;
 transition: all 0.2s ease;
 border-radius: 8px;
 margin: 0.25rem 0.5rem;
}

[data-theme="dark"] .dropdown-item:hover {
 background: rgba(255, 255, 255, 0.1);
 color: white;
 transform: translateX(4px);
}

[data-theme="dark"] .dropdown-divider {
 border-color: rgba(255, 255, 255, 0.1);
 margin: 0.5rem 0;
}

[data-theme="dark"] .glass-alert {
 background: rgba(0, 0, 0, 0.2);
 border-color: rgba(255, 255, 255, 0.1);
}

/* ===== DARK MODE GEOMETRIC SHAPES ===== */
[data-theme="dark"] .geometric-shape {
 opacity: 0.05;
}

[data-theme="dark"] .geometric-shape:nth-child(1),
[data-theme="dark"] .geometric-shape:nth-child(2),
[data-theme="dark"] .geometric-shape:nth-child(3),
[data-theme="dark"] .geometric-shape:nth-child(5) {
 background: linear-gradient(45deg, rgba(255,255,255,0.1), transparent);
}

[data-theme="dark"] .geometric-shape:nth-child(4) {
 border-color: rgba(255,255,255,0.1);
}

/* ===== DARK MODE PARTICLES ===== */
[data-theme="dark"] #particles-js {
 background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

/* ===== RESPONSIVE DARK MODE TOGGLE ===== */
@media (max-width: 768px) {
 .theme-toggle {
 top: 15px;
 right: 15px;
 min-width: 100px;
 font-size: 0.8rem;
 padding: 0.4rem;
 }
 
 .theme-toggle i {
 font-size: 1rem;
 }
}

@media (max-width: 576px) {
 .theme-toggle {
 top: 10px;
 right: 10px;
 min-width: 80px;
 padding: 0.3rem;
 }
 
 .theme-toggle span {
 display: none;
 }
}

/* ===== DARK MODE ANIMATIONS ===== */
@keyframes themeSwitch {
 0% { transform: scale(1) rotate(0deg); }
 50% { transform: scale(1.1) rotate(180deg); }
 100% { transform: scale(1) rotate(360deg); }
}

.theme-toggle.switching {
 animation: themeSwitch 0.6s ease-in-out;
}

/* ===== SYSTEM PREFERENCE DETECTION ===== */
@media (prefers-color-scheme: dark) {
 :root {
 --bg-primary: #1a1a1a;
 --bg-secondary: #2d2d2d;
 --text-primary: #ffffff;
 --text-secondary: #b0b0b0;
 --border-color: #404040;
 --shadow-color: rgba(0, 0, 0, 0.3);
 --glass-bg: var(--glass-bg-dark);
 --glass-border: var(--glass-border-dark);
 }
}

/* ===== DARK MODE ACCESSIBILITY ===== */
[data-theme="dark"] .glass-btn:focus,
[data-theme="dark"] .glass-input:focus,
[data-theme="dark"] .glass-nav-link:focus {
 outline: 2px solid rgba(255, 255, 255, 0.5);
 outline-offset: 2px;
}

/* ===== HIGH CONTRAST DARK MODE ===== */
@media (prefers-contrast: high) {
 [data-theme="dark"] .glass-card,
 [data-theme="dark"] .glass-form,
 [data-theme="dark"] .glass-btn {
 border-width: 2px;
 border-color: rgba(255, 255, 255, 0.5);
 }
 
 [data-theme="dark"] .glass-input {
 border-width: 2px;
 border-color: rgba(255, 255, 255, 0.5);
 }
}

/* Fix analyses page background in dark mode */
body.dark-mode .analyses-container,
body.dark-mode .admin-analyses-container {
 background-color: var(--bg-primary) !important;
}

body.dark-mode .card,
body.dark-mode .analysis-card {
 background-color: var(--bg-secondary) !important;
}

/* اصلاح رنگ صفحه analyses در dark mode */
body.dark-mode .admin-content,
body.dark-mode .content-wrapper,
body.dark-mode .main-content,
body.dark-mode #content {
 background-color: var(--bg-primary, #1a1d29) !important;
}

body.dark-mode .analyses-container,
body.dark-mode .admin-analyses-container {
 background-color: transparent !important;
}

body.dark-mode .card,
body.dark-mode .analysis-card {
 background-color: rgba(255, 255, 255, 0.05) !important;
 border-color: rgba(255, 255, 255, 0.1) !important;
}

body.dark-mode .table {
 --bs-table-bg: transparent !important;
 --bs-table-striped-bg: rgba(255, 255, 255, 0.02) !important;
 color: #fff !important;
}

body.dark-mode .table thead th {
 background-color: rgba(255, 255, 255, 0.05) !important;
 border-color: rgba(255, 255, 255, 0.1) !important;
 color: #fff !important;
}

body.dark-mode .table tbody td {
 border-color: rgba(255, 255, 255, 0.1) !important;
 color: #fff !important;
}

/* اصلاح header در analyses */
body.dark-mode .page-header,
body.dark-mode .analyses-header {
 background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
}

/* اصلاح فرم‌ها و input ها */
body.dark-mode .form-control,
body.dark-mode .form-select {
 background-color: rgba(255, 255, 255, 0.05) !important;
 border-color: rgba(255, 255, 255, 0.1) !important;
 color: #fff !important;
}

body.dark-mode .form-control::placeholder {
 color: rgba(255, 255, 255, 0.5) !important;
}
