/* =========================================================
   المتغيرات العامة (Design Tokens)
   ========================================================= */
:root {
    /* الألوان الأساسية للعلامة */
    --color-primary: #C5A059;
    --color-primary-hover: #d1b16e;
    --color-primary-active: #a68443;

    /* ألوان الخلفية */
    --color-bg-base: #353535;
    --color-bg-gradient-start: #3d3d3d;
    --color-bg-gradient-end: #1e1e1e;

    /* الزجاجية (Glassmorphism) */
    --glass-bg: rgba(60, 60, 60, 0.45);
    --glass-bg-strong: rgba(45, 45, 45, 0.55);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-highlight: rgba(255, 255, 255, 0.06);

    /* حقول الإدخال */
    --input-bg: rgba(20, 20, 20, 0.4);
    --input-border: rgba(255, 255, 255, 0.12);
    --input-border-focus: var(--color-primary);

    /* النصوص */
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-on-primary: #1a201e;

    /* حالات */
    --color-error-bg: rgba(239, 68, 68, 0.18);
    --color-error-border: rgba(239, 68, 68, 0.45);
    --color-error-text: #fca5a5;

    /* الفوتر */
    --footer-text: #9aa0a0;
    --footer-text-muted: #6a6a6a;

    /* الحدود العامة */
    --border-soft: rgba(255, 255, 255, 0.08);

    /* الأبعاد */
    --stage-max-width: 480px;
    --card-radius: 20px;
    --input-radius: 10px;
    --button-radius: 10px;
}


/* =========================================================
   إعادة الضبط الأساسية (Reset)
   ========================================================= */
* {
    box-sizing: border-box;
}

html, body {
    padding: 0;
    margin: 0;
    min-height: 100vh;
}


/* =========================================================
   الخلفية والتخطيط العام (Layout)
   ========================================================= */
body {
    direction: rtl;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;

    background-color: var(--color-bg-base);
    background-image:
        radial-gradient(circle at 15% 10%, rgba(197, 160, 89, 0.06), transparent 45%),
        radial-gradient(circle at 85% 90%, rgba(197, 160, 89, 0.05), transparent 50%),
        linear-gradient(160deg, var(--color-bg-gradient-start) 0%, var(--color-bg-gradient-end) 100%);
    background-attachment: fixed;
}

.stage {
    width: 100%;
    max-width: var(--stage-max-width);
    display: flex;
    flex-direction: column;
    align-items: center;
}


/* =========================================================
   رأس العلامة (Brand Header)
   ========================================================= */
.brand-header {
    text-align: center;
    margin-bottom: 20px;
}

.brand-logo {
    width: 76px;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.35));
    display: block;
    margin: 0 auto;
}


/* =========================================================
   البطاقة الزجاجية (Glass Card)
   ========================================================= */
.auth-card {
    width: 100%;
    padding: 32px 28px 26px;
    box-sizing: border-box;

    background: var(--glass-bg);
    backdrop-filter: blur(28px) saturate(160%);
    -webkit-backdrop-filter: blur(28px) saturate(160%);

    border: 1px solid var(--glass-border);
    border-radius: var(--card-radius);

    box-shadow:
        0 24px 48px rgba(0, 0, 0, 0.45),
        0 2px 8px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 var(--glass-highlight);
}

.auth-card h2 {
    font-weight: 400;
    font-size: 1.35rem;
    text-align: center;
    margin: 0 0 22px 0;
    color: var(--text-primary);
}


/* =========================================================
   حقول النماذج (Form Fields)
   ========================================================= */
.input-group {
    margin-bottom: 16px;
    width: 100%;
}

.input-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: right;
    cursor: default;
}

.input-group input[type="text"],
.input-group input[type="email"],
.input-group input[type="password"],
.input-group input[type="tel"] {
    display: block;
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--input-radius);
    padding: 11px 14px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    text-align: right;
    box-sizing: border-box;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.input-group input:focus {
    border-color: var(--input-border-focus);
    background: rgba(20, 20, 20, 0.55);
    box-shadow:
        0 0 0 3px rgba(197, 160, 89, 0.2),
        inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.input-group input::placeholder {
    color: rgba(203, 213, 225, 0.4);
}

.login input[type="text"] {
    text-align: right;
}

.totp-input {
    text-align: center !important;
    font-size: 1.6em !important;
    letter-spacing: 6px;
    font-weight: 600;
}

.totp-input::placeholder {
    letter-spacing: 6px;
}


/* =========================================================
   الأزرار (Buttons)
   ========================================================= */
.submit {
    margin: 10px 0 0 0;
}

.button {
    display: block;
    width: 100%;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: var(--button-radius);
    padding: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    color: var(--text-on-primary);
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-active) 100%);
    box-shadow: 0 6px 16px rgba(197, 160, 89, 0.22);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.button:hover {
    background: linear-gradient(135deg, var(--color-primary-hover) 0%, var(--color-primary) 100%);
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(197, 160, 89, 0.32);
    color: var(--text-on-primary);
}

.button-outline {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--color-primary);
    color: var(--color-primary);
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.button-outline:hover {
    background: var(--color-primary);
    color: var(--text-on-primary);
}

.button-outline img {
    max-width: 22px;
    height: auto;
}


/* =========================================================
   عناصر نصية عامة (Utility Text)
   ========================================================= */
.center {
    text-align: center;
}

.small {
    font-size: 0.85em;
}

.center.small a {
    color: var(--color-primary);
    text-decoration: none;
}

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


/* =========================================================
   رسائل الأخطاء (Error / Alerts)
   ========================================================= */
.error {
    display: block;
    background: var(--color-error-bg);
    border: 1px solid var(--color-error-border);
    color: var(--color-error-text);
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 13px;
    line-height: 1.5;
    text-align: right;
    margin: 0 0 16px 0;
}


/* =========================================================
   روابط الصفحة الرئيسية (Home Links)
   ========================================================= */
.home-links {
    margin-top: 26px;
    padding-top: 22px;
    border-top: 1px solid var(--border-soft);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 20px;
}

.home-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85em;
    transition: color 0.2s ease;
}

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


/* =========================================================
   مربعات الاختيار والراديو (Checkbox / Radio)
   ========================================================= */
.checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
    text-align: right;
    flex-wrap: wrap;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    bottom: 0;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 999px;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    right: 2px;
    top: 2px;
    background: var(--text-primary);
    border-radius: 50%;
    transition: transform 0.2s ease, background 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(-20px);
    background: var(--text-on-primary);
}

.toggle-switch input:focus-visible + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.3);
}


/* =========================================================
   القوائم البريدية (Lists / Subscription)
   ========================================================= */
.lists {
    list-style: none;
    padding: 0;
    margin: 0 0 16px 0;
}

.lists .description {
    color: var(--text-muted);
    font-size: 0.8em;
    line-height: 1.5;
    margin: 2px 0 10px 24px;
}

.lists-block {
    margin: 20px 0;
    text-align: right;
}

.lists-title {
    font-size: 0.95em;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 0 0 10px 0;
}

.optin-lists {
    list-style: none;
    padding: 0;
    margin: 0 0 20px 0;
    text-align: right;
}

.optin-lists li {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--input-radius);
    padding: 11px 14px;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 0.9em;
}

.optin-info {
    color: var(--text-secondary);
    font-size: 0.9em;
    line-height: 1.8;
    text-align: center;
    margin: 0 0 20px 0;
}


/* =========================================================
   الكابتشا والحقول المخفية
   ========================================================= */
.captcha {
    margin: 16px 0;
    display: flex;
    justify-content: center;
}

.form .nonce,
input.nonce {
    display: none;
}


/* =========================================================
   الأرشيف (Archive)
   ========================================================= */
.archive {
    list-style: none;
    padding: 0;
    margin: 0 0 20px 0;
}

.archive li {
    padding: 14px 0;
    border-bottom: 1px solid var(--border-soft);
}

.archive li:last-child {
    border-bottom: none;
}

.archive li a {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.95em;
    display: block;
    margin-bottom: 4px;
    transition: color 0.2s ease;
}

.archive li a:hover {
    color: var(--color-primary);
}

.archive .date {
    display: block;
    color: var(--text-muted);
    font-size: 0.8em;
}

.archive-footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--border-soft);
}

.archive-footer-links a {
    color: var(--color-primary);
    text-decoration: none;
    font-size: 0.85em;
    display: flex;
    align-items: center;
}

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

.archive-footer-links .feed {
    filter: invert(70%) sepia(40%) saturate(400%) hue-rotate(0deg);
    opacity: 0.85;
}


/* =========================================================
   ترقيم الصفحات (Pagination)
   ========================================================= */
.pagination {
    margin-top: 20px;
    text-align: center;
}

.pg-page {
    display: inline-block;
    padding: 0 10px;
    text-decoration: none;
    color: var(--text-secondary);
}

.pg-page.pg-selected {
    color: var(--color-primary);
    font-weight: bold;
    text-decoration: underline;
}


/* =========================================================
   التحقق الثنائي (Two-Factor Auth)
   ========================================================= */
.twofa-help {
    color: var(--text-secondary);
    font-size: 0.9em;
    line-height: 1.6;
    text-align: center;
    margin: 0 0 20px 0;
}


/* =========================================================
   رسائل عامة (Message Pages)
   ========================================================= */
.message-body {
    color: var(--text-secondary);
    font-size: 0.95em;
    line-height: 1.9;
    text-align: center;
}

.message-body a {
    color: var(--color-primary);
}

.message-body a:hover {
    color: var(--color-primary-hover);
}


/* =========================================================
   الفوتر (Footer)
   ========================================================= */
footer {
    margin-top: 44px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--footer-text);
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
}

footer a {
    color: var(--footer-text);
    text-decoration: none;
    transition: color 0.2s ease;
}

footer a:hover {
    color: var(--color-primary);
}

.powered-by {
    font-size: 0.7rem;
    color: var(--footer-text-muted);
}

.powered-by a {
    color: var(--footer-text-muted);
    font-weight: 500;
}

.powered-by a:hover {
    color: var(--color-primary);
}


/* =========================================================
   التوافق مع الشاشات الصغيرة (Responsive)
   ========================================================= */
@media (max-width: 480px) {
    body {
        padding: 20px 12px;
    }

    .auth-card {
        padding: 26px 20px 22px;
        border-radius: 16px;
    }

    .brand-logo {
        width: 64px;
    }
}