/* ==========================================================================
   GLOBAL CSS - QuizMed App
   Shared styles extracted from all templates.
   ========================================================================== */

/* ==========================================================================
   1. THEME VARIABLES
   ========================================================================== */

:root {
    /* Default theme: gradient-main (admin, index) */
    --bg-body: linear-gradient(to left, #00d2ff 0%, #3a7bd5 50%, #8e2de2 100%);
    --bg-overlay: rgba(255,255,255,0.93);
    --card-bg: #ffffff;
    --text-color: #2d3748;
    --text-muted: #718096;
    --border-color: #e2e8f0;
    --icon-gradient-1: linear-gradient(135deg, #00d2ff 0%, #3a7bd5 100%);
    --icon-gradient-2: linear-gradient(135deg, #3a7bd5 0%, #6a3093 100%);
    --icon-gradient-3: linear-gradient(135deg, #6a3093 0%, #8e2de2 100%);
    --icon-gradient-4: linear-gradient(135deg, #00d2ff 0%, #6a3093 100%);
    --card-shadow: 0 4px 20px rgba(0,0,0,0.06);
    --card-hover-shadow: 0 8px 30px rgba(0,0,0,0.1);
}

/* Theme: Purple gradient (question, test, 1, profile) */
.theme-purple {
    --bg-body: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-overlay: rgba(255,255,255,0.95);
    --icon-gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-shadow: 0 10px 40px rgba(0,0,0,0.08);
}

/* Theme: Flat (edit pages, search, admin_user_profile) */
.theme-flat {
    --bg-body: #f8f9fa;
    --bg-overlay: transparent;
    --card-shadow: 0 2px 10px rgba(0,0,0,0.06);
}

/* ==========================================================================
   2. DARK MODE VARIABLES
   ========================================================================== */

[data-bs-theme="dark"] {
    --bg-body: #000000;
    --bg-overlay: #000000;
    --card-bg: #141414;
    --text-color: #e0e0e0;
    --text-muted: #888888;
    --border-color: #333333;
    --card-shadow: none;
    --card-hover-shadow: 0 4px 12px rgba(0,0,0,0.5);
    --icon-gradient-1: linear-gradient(135deg, #5b8def 0%, #7c6fd4 100%);
    --icon-gradient-2: linear-gradient(135deg, #5b8def 0%, #7c6fd4 100%);
    --icon-gradient-3: linear-gradient(135deg, #7c6fd4 0%, #9b6fd4 100%);
    --icon-gradient-4: linear-gradient(135deg, #5b8def 0%, #9b6fd4 100%);
}

[data-bs-theme="dark"] .theme-purple {
    --bg-body: #000000;
    --bg-overlay: #000000;
    --card-bg: #141414;
    --icon-gradient-1: linear-gradient(135deg, #5b8def 0%, #7c6fd4 100%);
    --card-shadow: none;
}

[data-bs-theme="dark"] .theme-flat {
    --bg-body: #121212;
    --bg-overlay: transparent;
    --card-bg: #1e1e1e;
}

/* ==========================================================================
   2b. DESERT MODE
   Warm cream palette inspired by Claude Design System.
   ========================================================================== */

[data-bs-theme="desert"] {
    --bg-body: #EEECEA;
    --bg-overlay: transparent;
    --card-bg: #F8F7F5;
    --text-color: #1A1915;
    --text-muted: #888780;
    --border-color: rgba(0,0,0,.08);
    --card-shadow: none;
    --card-hover-shadow: none;
    --icon-gradient-1: #444441;
    --icon-gradient-2: #444441;
    --icon-gradient-3: #444441;
    --icon-gradient-4: #444441;
}

[data-bs-theme="desert"] .theme-purple {
    --bg-body: #EEECEA;
    --bg-overlay: transparent;
    --icon-gradient-1: #444441;
    --card-shadow: none;
}

[data-bs-theme="desert"] .theme-flat {
    --bg-body: #F5F5F5;
    --bg-overlay: transparent;
    --card-bg: #FFFFFF;
}

/* Desert body */
[data-bs-theme="desert"] body {
    font-weight: 400;
}
[data-bs-theme="desert"] body::before {
    display: none;
}

/* Desert bg-shapes — hide */
[data-bs-theme="desert"] .bg-shapes { display: none !important; }

/* Desert navbar — clean light */
[data-bs-theme="desert"] .navbar-blur {
    background: #FFFFFF !important;
    border-bottom: 1px solid rgba(0,0,0,.06) !important;
    box-shadow: none !important;
    backdrop-filter: none;
}

[data-bs-theme="desert"] .navbar-brand {
    color: #8B5E3C !important;
    background: none !important;
    -webkit-text-fill-color: initial !important;
    text-shadow: none !important;
}

[data-bs-theme="desert"] .navbar-brand i {
    color: #C17D4A !important;
    background: none !important;
    -webkit-text-fill-color: initial !important;
}

/* Desert sidebar — white */
[data-bs-theme="desert"] .sidebar-col {
    background: #FFFFFF !important;
    border-left: 1px solid rgba(0,0,0,.04) !important;
}

[data-bs-theme="desert"] .offcanvas-header {
    background: #FFFFFF !important;
    border-bottom-color: rgba(0,0,0,.04) !important;
}

/* Desert nav squares */
[data-bs-theme="desert"] .nav-square {
    background: #FFFFFF;
    border: 1px solid rgba(0,0,0,.08);
    color: #888780;
}

[data-bs-theme="desert"] .nav-square:hover {
    border-color: #444441;
}

/* Desert buttons — dark solid on light bg */
[data-bs-theme="desert"] .btn-gradient {
    background: #1A1915 !important;
    border: none !important;
    color: #FAFAFA !important;
    border-radius: 8px;
    font-weight: 500;
}

[data-bs-theme="desert"] .btn-gradient:hover {
    background: #2C2C2A !important;
    background-image: none !important;
}
[data-bs-theme="desert"] .btn-gradient::before {
    display: none !important;
}
[data-bs-theme="desert"] .btn-gradient:focus {
    box-shadow: 0 0 0 2px rgba(68,68,65,0.3) !important;
}

/* Desert donation link */
[data-bs-theme="desert"] .donation-link {
    color: #888780 !important;
}
[data-bs-theme="desert"] .donation-link:hover {
    background-color: #F0F0F0 !important;
    color: #444441 !important;
}

/* Desert search input */
[data-bs-theme="desert"] input[type="search"],
[data-bs-theme="desert"] .input-group-text {
    background-color: #F5F5F5 !important;
    border-color: rgba(0,0,0,.08) !important;
    color: #1A1915 !important;
}

/* Desert cards */
[data-bs-theme="desert"] .card,
[data-bs-theme="desert"] .content-card {
    background: #FFFFFF;
    border: 1px solid rgba(0,0,0,.06);
    box-shadow: none;
}

/* Desert section header */
[data-bs-theme="desert"] .section-header {
    border-bottom-color: rgba(0,0,0,.06) !important;
}

/* Desert top controls */
[data-bs-theme="desert"] .top-controls .btn {
    color: #888780 !important;
}
[data-bs-theme="desert"] .top-controls .btn:hover {
    background-color: #F0F0F0 !important;
    color: #1A1915 !important;
}

/* Desert answer options */
[data-bs-theme="desert"] .answer-lbl {
    background: #FFFFFF;
    border-color: rgba(0,0,0,.08);
    color: #1A1915;
}

/* Desert navigation controls */
[data-bs-theme="desert"] .navigation-controls {
    background: #F0EEEB !important;
    border: none !important;
}

/* Desert form controls */
[data-bs-theme="desert"] .form-control,
[data-bs-theme="desert"] .form-select {
    background-color: #FFFFFF !important;
    border: 1px solid rgba(0,0,0,.1) !important;
    color: #1A1915 !important;
}

[data-bs-theme="desert"] .form-control:focus,
[data-bs-theme="desert"] .form-select:focus {
    box-shadow: 0 0 0 2px rgba(0,0,0,0.06) !important;
    border-color: #444441 !important;
}

/* Desert text overrides */
[data-bs-theme="desert"] .text-muted {
    color: #888780 !important;
}

/* Desert badges */
[data-bs-theme="desert"] .badge {
    font-weight: 500;
}

/* Desert toggle switches */
[data-bs-theme="desert"] .form-check-input {
    background-color: #E0DDD8 !important;
    border-color: #D3D1C7 !important;
}
[data-bs-theme="desert"] .form-check-input:checked {
    background-color: #444441 !important;
    border-color: #444441 !important;
}

/* ==========================================================================
   3. BASE BODY STYLES
   ========================================================================== */

* { box-sizing: border-box; }

body {
    min-height: 100vh;
    background: var(--bg-body);
    color: var(--text-color);
    font-family: 'Segoe UI', 'Arial', sans-serif;
    padding-top: 65px;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-overlay);
    z-index: -1;
}

/* ==========================================================================
   4. BACKGROUND SHAPES (floating bubbles)
   ========================================================================== */

.bg-shapes {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    overflow: hidden;
    z-index: -2;
    pointer-events: none;
}

.bg-shapes span {
    position: absolute;
    border-radius: 50%;
    opacity: 0.08;
    animation: float 20s infinite ease-in-out;
}

.bg-shapes span:nth-child(1) { width: 300px; height: 300px; background: #00d2ff; top: 10%; right: 5%; animation-delay: 0s; }
.bg-shapes span:nth-child(2) { width: 250px; height: 250px; background: #3a7bd5; bottom: 20%; left: 40%; animation-delay: -5s; }
.bg-shapes span:nth-child(3) { width: 150px; height: 150px; background: #8e2de2; top: 50%; left: 5%; animation-delay: -10s; }

[data-bs-theme="dark"] .bg-shapes { display: none !important; }

/* ==========================================================================
   5. NAVBAR
   ========================================================================== */

.navbar-blur {
    backdrop-filter: blur(20px);
    background: rgba(255,255,255,0.85) !important;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    box-shadow: 0 4px 30px rgba(0,0,0,0.05);
}

[data-bs-theme="dark"] .navbar-blur {
    background-color: #181818 !important;
    border-bottom: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* Logo - dark mode */
[data-bs-theme="dark"] .navbar-brand {
    background: none !important;
    -webkit-text-fill-color: initial !important;
    color: #38b6ff !important;
    font-weight: 400 !important;
    text-shadow: none !important;
}

[data-bs-theme="dark"] .navbar-brand i {
    background: none !important;
    -webkit-text-fill-color: initial !important;
    color: #38b6ff !important;
}

/* ==========================================================================
   6. DONATION LINK
   ========================================================================== */

.donation-link {
    border: none !important;
    background-color: transparent !important;
    color: #d81b60 !important;
    font-weight: 500 !important;
    padding: 6px 12px !important;
    border-radius: 6px !important;
    box-shadow: none !important;
    transition: background-color 0.2s ease, color 0.2s ease !important;
}

.donation-link:hover {
    background-color: #fce4ec !important;
    color: #c2185b !important;
    transform: none !important;
}

[data-bs-theme="dark"] .donation-link {
    color: #f48fb1 !important;
    border: none !important;
    background-color: transparent !important;
}

[data-bs-theme="dark"] .donation-link:hover {
    background-color: rgba(244, 143, 177, 0.1) !important;
    color: #ffb1c8 !important;
    transform: none !important;
}

/* ==========================================================================
   7. HELP BUBBLE
   ========================================================================== */

.help-bubble {
    position: absolute; z-index: 1080;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff; border-radius: 12px; padding: 12px 16px;
    font-size: 0.82rem; line-height: 1.5; width: 260px;
    box-shadow: 0 8px 32px rgba(102,126,234,0.35);
    animation: helpBubblePop 0.35s cubic-bezier(.34,1.56,.64,1);
}

.help-bubble::after {
    content: ''; position: absolute; top: -8px; left: 50%; transform: translateX(-50%);
    border-left: 8px solid transparent; border-right: 8px solid transparent;
    border-bottom: 8px solid #667eea;
}

.help-bubble .bubble-dismiss {
    display: inline-block; margin-top: 8px; padding: 3px 14px;
    background: rgba(255,255,255,0.25); border: 1px solid rgba(255,255,255,0.4);
    border-radius: 20px; font-size: 0.75rem; cursor: pointer;
    transition: background 0.2s;
}

.help-bubble .bubble-dismiss:hover { background: rgba(255,255,255,0.4); }

.help-bubble-overlay {
    position: fixed; inset: 0; z-index: 1070;
    background: rgba(0,0,0,0.15); backdrop-filter: blur(1px);
}

.help-bubble-target { position: relative; z-index: 1075; }

/* ==========================================================================
   8. BTN-GRADIENT
   ========================================================================== */

.btn-gradient {
    border: none;
    border-radius: 20px;
    padding: 0.5rem 1rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: white;
    background: var(--icon-gradient-2);
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.btn-gradient:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(58, 123, 213, 0.3);
    color: white;
}

.btn-gradient::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.2); opacity: 0; transition: opacity 0.3s;
}

.btn-gradient:hover::before { opacity: 1; }

.btn-gradient.btn-danger-grad {
    background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
}

.btn-gradient.btn-success-grad {
    background: linear-gradient(135deg, #38a169 0%, #2f855a 100%);
}

.btn-gradient.btn-info-grad {
    background: var(--icon-gradient-1);
}

.btn-locked {
    background: #cbd5e0 !important;
    cursor: not-allowed;
}

[data-bs-theme="dark"] .btn-gradient {
    background: #222 !important;
    border: 1px solid #444 !important;
    color: #e0e0e0 !important;
}

[data-bs-theme="dark"] .btn-gradient:hover {
    background: #333 !important;
    border-color: #fff !important;
    color: #fff !important;
}

/* ==========================================================================
   9. SECTION HEADER & PAGE TITLE
   ========================================================================== */

.section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid rgba(0,0,0,0.05);
}

.section-header i {
    font-size: 1.1rem;
}

.section-header h5 {
    font-weight: 700;
    font-size: 1rem;
    margin: 0;
}

[data-bs-theme="dark"] .section-header {
    border-bottom-color: #222 !important;
}

[data-bs-theme="dark"] .section-header h5 {
    color: #fff !important;
}

.page-title {
    font-size: 1.3rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-title i {
    background: var(--icon-gradient-2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ==========================================================================
   10. COMMON DARK MODE OVERRIDES
   ========================================================================== */

/* Search input */
[data-bs-theme="dark"] input[type="search"],
[data-bs-theme="dark"] .input-group-text {
    background-color: #252525 !important;
    border-color: #333 !important;
    color: #fff !important;
}

[data-bs-theme="dark"] input[type="search"]::placeholder {
    color: #888 !important;
}

/* ==========================================================================
   11. ANIMATIONS
   ========================================================================== */

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-30px) rotate(10deg); }
}

@keyframes helpBubblePop {
    0% { opacity: 0; transform: scale(0.8) translateY(8px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ==========================================================================
   12. QUILL EDITOR OVERRIDES (RTL)
   ========================================================================== */

.ql-toolbar {
    direction: ltr;
    text-align: left;
}

.ql-editor {
    direction: rtl;
    text-align: right;
}

.ql-container {
    border-color: var(--bs-border-color) !important;
}

[data-bs-theme="dark"] .ql-toolbar {
    background-color: #1e1e1e !important;
    border-color: #333 !important;
}

[data-bs-theme="dark"] .ql-container {
    border-color: #333 !important;
}

[data-bs-theme="dark"] .ql-editor {
    background-color: #0a0a0a !important;
    color: #e0e0e0 !important;
}

[data-bs-theme="dark"] .ql-toolbar .ql-stroke {
    stroke: #aaa !important;
}

[data-bs-theme="dark"] .ql-toolbar .ql-fill {
    fill: #aaa !important;
}

[data-bs-theme="dark"] .ql-toolbar .ql-picker-label {
    color: #aaa !important;
}
