:root {
    --accent-color: #c9a96e;
    --text-primary: #2d2a26;
    --text-secondary: #5c5650;
    --text-muted: #9a9490;
    --shadow-color: rgba(30, 27, 75, 0.1);
    --gradient-start: #2d2a5e;
    --gradient-mid: #3b3780;
    --gradient-end: #4a45a0;
}

/* Dark mode variables */
[data-theme="dark"] {
    --accent-color: #c9a96e;
    --text-primary: #faf5ef;
    --text-secondary: #d4ccc4;
    --text-muted: #8a8480;
    --shadow-color: rgba(0, 0, 0, 0.4);
    --gradient-start: #2d2a5e;
    --gradient-mid: #3b3780;
    --gradient-end: #4a45a0;
}

/* ===== Background ===== */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-weight: 300;
    line-height: 1.8;
    background: var(--gradient-start);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(124, 58, 237, 0.2) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(49, 46, 129, 0.2) 0%, transparent 50%),
        linear-gradient(160deg, var(--gradient-start) 0%, var(--gradient-mid) 50%, var(--gradient-end) 100%);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    direction: rtl;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

/* Subtle gold particles overlay */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(1.5px 1.5px at 15% 25%, rgba(201, 169, 110, 0.3) 50%, transparent 50%),
        radial-gradient(1px 1px at 45% 65%, rgba(201, 169, 110, 0.2) 50%, transparent 50%),
        radial-gradient(1.5px 1.5px at 75% 15%, rgba(139, 92, 246, 0.2) 50%, transparent 50%),
        radial-gradient(1px 1px at 85% 55%, rgba(201, 169, 110, 0.15) 50%, transparent 50%),
        radial-gradient(1.5px 1.5px at 25% 85%, rgba(139, 92, 246, 0.15) 50%, transparent 50%);
    pointer-events: none;
    z-index: 0;
    opacity: 0.5;
}

/* ===== Header ===== */
.header-gradient {
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-mid) 50%, var(--gradient-end) 100%);
    position: relative;
    padding: 20px 30px;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 20px;
}

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

.logo-link {
    display: block;
}

.header-logo {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.header-text {
    text-align: right;
}

.header-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #f0d080;
    margin: 0 0 4px 0;
}

.header-subtitle {
    font-size: 1.25rem;
    color: #e8c9a0;
    opacity: 0.9;
    margin: 0;
}

/* ===== Login Container ===== */
.login-container {
    background: rgba(255, 252, 247, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 28px;
    padding: 36px;
    max-width: 500px;
    width: 100%;
    box-shadow:
        0 24px 48px var(--shadow-color),
        0 0 0 1px rgba(201, 169, 110, 0.12);
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(201, 169, 110, 0.12);
    margin: 40px auto;
    position: relative;
    z-index: 1;
    animation: loginEntrance 0.6s ease-out both;
}

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

[data-theme="dark"] .login-container {
    background: rgba(15, 10, 46, 0.95);
    border: 1px solid rgba(124, 58, 237, 0.2);
}

/* ===== Login Heading ===== */
.login-heading {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, #2d2a26, #5c4a2a, #8b6914);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0 0 8px 0;
}

.login-subheading {
    color: #5c4a2a;
    font-weight: 300;
    letter-spacing: 0.2px;
    margin: 0;
}

[data-theme="dark"] .login-heading {
    background: linear-gradient(135deg, #e8c9a0, #f0d080, #c9a96e);
    -webkit-background-clip: text;
    background-clip: text;
}

[data-theme="dark"] .login-subheading {
    color: var(--text-secondary);
}

/* ===== Form ===== */
.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #5c4a2a;
    margin-bottom: 8px;
}

[data-theme="dark"] .form-label {
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid rgba(30, 27, 75, 0.08);
    border-radius: 14px;
    font-size: 16px;
    font-weight: 300;
    background: rgba(255, 252, 247, 0.9);
    color: var(--text-primary);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    direction: rtl;
}

[data-theme="dark"] .form-input {
    background: rgba(15, 10, 46, 0.9);
    border: 2px solid rgba(124, 58, 237, 0.2);
    color: var(--text-primary);
}

.form-input:focus {
    border-color: #8b6914;
    box-shadow: 0 0 0 3px rgba(139, 105, 20, 0.1);
    outline: none;
    background: white;
}

/* Select dropdown arrow positioning for RTL */
select.form-input {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b6914' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 16px center;
    padding-left: 40px;
    color: #5c4a2a;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
}

select.form-input option {
    color: #5c4a2a;
    background: #fffcf7;
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    padding: 12px;
}

select.form-input option:checked {
    color: #8b6914;
    font-weight: 500;
}

/* ===== Custom Dropdown ===== */
.custom-select-wrapper {
    position: relative;
    width: 100%;
}

.custom-select-trigger {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid rgba(30, 27, 75, 0.08);
    border-radius: 14px;
    font-size: 16px;
    font-weight: 300;
    font-family: 'Inter', sans-serif;
    background: rgba(255, 252, 247, 0.9);
    color: #5c4a2a;
    cursor: pointer;
    direction: rtl;
    text-align: right;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

.custom-select-trigger::after {
    content: '';
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #8b6914;
}

.custom-select-trigger:hover,
.custom-select-trigger.open {
    border-color: #8b6914;
    box-shadow: 0 0 0 3px rgba(139, 105, 20, 0.1);
}

.custom-select-trigger.placeholder {
    color: #9ca3af;
}

.custom-select-options {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fffcf7;
    border: 2px solid rgba(139, 105, 20, 0.2);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(30, 27, 75, 0.12);
    z-index: 100;
    max-height: 240px;
    overflow-y: auto;
    padding: 6px;
}

.custom-select-options.open {
    display: block;
}

.custom-select-option {
    padding: 12px 16px;
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    color: #5c4a2a;
    cursor: pointer;
    border-radius: 10px;
    transition: background 0.15s ease, color 0.15s ease;
    text-align: right;
}

.custom-select-option:hover {
    background: rgba(139, 105, 20, 0.08);
    color: #8b6914;
}

.custom-select-option.selected {
    background: rgba(139, 105, 20, 0.12);
    color: #8b6914;
    font-weight: 500;
}

[data-theme="dark"] .form-input:focus {
    background: rgba(20, 15, 50, 1);
}

.form-input::placeholder {
    color: var(--text-muted);
    font-weight: 300;
}

/* ===== Submit Button ===== */
.submit-button {
    width: 100%;
    background: linear-gradient(90deg, #8b6914 0%, #c9a96e 50%, #d4b87a 100%);
    color: white;
    border: none;
    padding: 16px 24px;
    border-radius: 16px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 0.3px;
    box-shadow: 0 4px 16px rgba(139, 105, 20, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
}

.submit-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(139, 105, 20, 0.4);
}

.submit-button:active {
    transform: translateY(0);
}

.submit-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 4px 12px rgba(30, 27, 75, 0.2);
}

/* Loading state */
.loading {
    position: relative;
    color: transparent !important;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid #2d2a26;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===== Error Message ===== */
.error-message {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    color: #dc2626;
    border: 1px solid #fecaca;
    border-radius: 14px;
    padding: 12px 16px;
    margin: 12px 0 0;
    font-size: 14px;
    display: none;
    align-items: center;
    gap: 8px;
}

[data-theme="dark"] .error-message {
    background: linear-gradient(135deg, #450a0a 0%, #7f1d1d 100%);
    color: #fca5a5;
    border: 1px solid #991b1b;
}

/* ===== Theme Toggle ===== */
.theme-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(30, 27, 75, 0.8);
    border: 1px solid rgba(201, 169, 110, 0.25);
    color: #faf5ef;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
    z-index: 1000;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: rgba(49, 46, 129, 0.9);
    transform: scale(1.1);
}

/* ===== Disclaimer ===== */
.disclaimer {
    background: rgba(30, 27, 75, 0.04);
    border-radius: 16px;
    margin: 24px 0 0;
    border: 1px solid rgba(30, 27, 75, 0.08);
    text-align: right;
    direction: rtl;
    overflow: hidden;
}

.disclaimer-toggle {
    font-size: 1em;
    font-weight: 500;
    margin: 0;
    padding: 16px 20px;
    color: #5c4a2a;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s ease;
}

.disclaimer-toggle:hover {
    background: rgba(30, 27, 75, 0.03);
}

.disclaimer-toggle::after {
    content: '▼';
    font-size: 0.7em;
    transition: transform 0.3s ease;
    opacity: 0.6;
}

.disclaimer.collapsed .disclaimer-toggle::after {
    transform: rotate(-90deg);
}

[data-theme="dark"] .disclaimer-toggle {
    color: var(--text-secondary);
}

.disclaimer-content {
    padding: 0 20px 16px;
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

.disclaimer.collapsed .disclaimer-content {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

.disclaimer p {
    font-size: 0.8em;
    line-height: 1.8;
    margin-bottom: 10px;
    color: var(--text-secondary);
    font-weight: 300;
}

.disclaimer p:last-child {
    font-weight: 500;
    color: #5c4a2a;
    margin-bottom: 0;
}

/* ===== Footer ===== */
.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 24px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid rgba(30, 27, 75, 0.08);
}

.footer-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s ease;
    cursor: pointer;
}

.footer-link:hover {
    color: #c9a96e;
}

/* ===== Mobile ===== */
@media (max-width: 768px) {
    .login-container {
        margin: 20px;
        padding: 24px;
        border-radius: 20px;
    }

    .header-content {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .header-left {
        flex-direction: column;
        gap: 12px;
    }

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

    .theme-toggle {
        top: 10px;
        left: 10px;
    }

    .footer-links {
        flex-direction: column;
        gap: 16px;
    }
}

@media (max-width: 480px) {
    .login-container {
        margin: 12px;
        padding: 20px;
        border-radius: 16px;
    }

    .login-heading {
        font-size: 1.4rem;
    }

    .login-subheading {
        font-size: 0.85rem;
    }

    .form-input {
        padding: 14px 16px;
        font-size: 16px; /* Prevents iOS zoom on input focus */
        border-radius: 12px;
    }

    .submit-button {
        padding: 14px 20px;
        font-size: 15px;
        border-radius: 14px;
    }

    .form-label {
        font-size: 13px;
    }

    .form-group {
        margin-bottom: 18px;
    }

    .disclaimer-toggle {
        padding: 12px 16px;
        font-size: 0.9em;
    }

    .disclaimer-content {
        padding: 0 16px 12px;
    }

    .disclaimer p {
        font-size: 0.75em;
    }

    .custom-select-trigger {
        padding: 14px 16px;
        font-size: 16px;
        border-radius: 12px;
    }
}

/* ===== Accessibility ===== */
@media (prefers-contrast: high) {
    .login-container {
        border: 2px solid #000;
    }

    .form-input {
        border: 2px solid #000;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== Terms Checkbox ===== */
.terms-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
    padding: 14px 16px;
    background: rgba(139, 105, 20, 0.05);
    border: 1px solid rgba(139, 105, 20, 0.15);
    border-radius: 12px;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.terms-row:has(.terms-checkbox:checked) {
    background: rgba(139, 105, 20, 0.10);
    border-color: rgba(139, 105, 20, 0.35);
}

[data-theme="dark"] .terms-row {
    background: rgba(201, 169, 110, 0.06);
    border-color: rgba(201, 169, 110, 0.15);
}

[data-theme="dark"] .terms-row:has(.terms-checkbox:checked) {
    background: rgba(201, 169, 110, 0.12);
    border-color: rgba(201, 169, 110, 0.35);
}

.terms-checkbox {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 2px;
    appearance: none;
    -webkit-appearance: none;
    border: 2px solid rgba(139, 105, 20, 0.4);
    border-radius: 5px;
    background: white;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
    position: relative;
}

[data-theme="dark"] .terms-checkbox {
    background: rgba(15, 10, 46, 0.9);
    border-color: rgba(201, 169, 110, 0.35);
}

.terms-checkbox:hover {
    border-color: #8b6914;
    transform: scale(1.05);
}

.terms-checkbox:checked {
    background: linear-gradient(135deg, #8b6914, #c9a96e);
    border-color: #8b6914;
}

.terms-checkbox:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 5px;
    width: 5px;
    height: 9px;
    border: 2px solid white;
    border-top: none;
    border-right: none;
    transform: rotate(-45deg) scaleX(-1);
}

.terms-checkbox:focus-visible {
    outline: 3px solid rgba(139, 105, 20, 0.4);
    outline-offset: 2px;
}

.terms-label {
    font-size: 13.5px;
    color: #5c4a2a;
    line-height: 1.6;
    cursor: pointer;
    flex: 1;
}

[data-theme="dark"] .terms-label {
    color: var(--text-secondary);
}

.terms-link {
    background: none;
    border: none;
    padding: 0;
    font-size: inherit;
    font-family: inherit;
    color: #8b6914;
    text-decoration: underline;
    text-decoration-style: dotted;
    cursor: pointer;
    transition: color 0.2s ease;
}

.terms-link:hover {
    color: #c9a96e;
    text-decoration-style: solid;
}

[data-theme="dark"] .terms-link {
    color: #c9a96e;
}

.terms-error {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: #dc2626;
    padding: 8px 12px;
    background: rgba(220, 38, 38, 0.07);
    border: 1px solid rgba(220, 38, 38, 0.2);
    border-radius: 10px;
    margin-bottom: 8px;
}

[data-theme="dark"] .terms-error {
    color: #fca5a5;
    background: rgba(220, 38, 38, 0.12);
    border-color: rgba(220, 38, 38, 0.3);
}

/* ===== Terms Modal ===== */
.terms-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10, 8, 40, 0.75);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

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

.terms-modal-box {
    background: #fffcf7;
    border-radius: 20px;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 24px 64px rgba(10, 8, 40, 0.4);
    border: 1px solid rgba(201, 169, 110, 0.2);
    display: flex;
    flex-direction: column;
    animation: slideUp 0.25s ease;
    max-height: 85vh;
}

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

[data-theme="dark"] .terms-modal-box {
    background: #0f0a2e;
    border-color: rgba(124, 58, 237, 0.25);
}

.terms-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid rgba(139, 105, 20, 0.12);
}

.terms-modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #2d2a26;
    margin: 0;
}

[data-theme="dark"] .terms-modal-header h3 {
    color: #e8c9a0;
}

.terms-modal-close {
    background: none;
    border: none;
    color: #9a9490;
    font-size: 16px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}

.terms-modal-close:hover {
    background: rgba(139, 105, 20, 0.08);
    color: #8b6914;
}

.terms-modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}

.terms-modal-body p {
    font-size: 14px;
    line-height: 1.8;
    color: #5c4a2a;
    margin-bottom: 12px;
    font-weight: 300;
}

.terms-modal-body p:last-child { margin-bottom: 0; }

.terms-emphasis {
    font-weight: 500 !important;
    color: #2d2a26 !important;
}

[data-theme="dark"] .terms-modal-body p { color: var(--text-secondary); }
[data-theme="dark"] .terms-emphasis { color: #e8c9a0 !important; }

.terms-modal-footer {
    display: flex;
    gap: 10px;
    padding: 16px 24px 20px;
    border-top: 1px solid rgba(139, 105, 20, 0.12);
}

.terms-accept-btn {
    flex: 1;
    background: linear-gradient(90deg, #8b6914, #c9a96e);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(139, 105, 20, 0.3);
}

.terms-accept-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(139, 105, 20, 0.4);
}

.terms-cancel-btn {
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    background: none;
    border: 1px solid rgba(139, 105, 20, 0.2);
    color: #5c4a2a;
    transition: background 0.2s, border-color 0.2s;
}

.terms-cancel-btn:hover {
    background: rgba(139, 105, 20, 0.06);
    border-color: rgba(139, 105, 20, 0.35);
}

[data-theme="dark"] .terms-cancel-btn {
    color: var(--text-secondary);
    border-color: rgba(201, 169, 110, 0.2);
}

@media (max-width: 480px) {
    .terms-modal-box { border-radius: 16px; }
    .terms-modal-header,
    .terms-modal-body,
    .terms-modal-footer { padding-right: 18px; padding-left: 18px; }
    .terms-modal-footer { flex-direction: column; }
    .terms-accept-btn, .terms-cancel-btn { width: 100%; justify-content: center; }
}
