/* الوضع الليلي لشاشات المشترك. النهاري هو الافتراضي، والاختيار يُحفظ على الجهاز (theme.js). */

.theme-toggle {
    display: grid;
    width: 2.3rem;
    height: 2.3rem;
    flex: 0 0 auto;
    place-items: center;
    padding: 0;
    border: 1px solid rgb(255 255 255 / 25%);
    border-radius: 50%;
    color: #fff;
    background: rgb(255 255 255 / 10%);
    cursor: pointer;
    transition: background-color .15s ease, transform .2s ease;
    -webkit-tap-highlight-color: transparent;
}

.theme-toggle:hover {
    background: rgb(255 255 255 / 18%);
}

.theme-toggle:active {
    transform: scale(.92);
}

.theme-toggle:focus-visible {
    outline: 3px solid rgb(255 255 255 / 45%);
    outline-offset: 2px;
}

.theme-toggle svg {
    width: 1.15rem;
    height: 1.15rem;
}

/* القمر في النهاري (للانتقال إلى الليل)، والشمس في الليلي. */
.theme-toggle__sun,
:root[data-theme="dark"] .theme-toggle__moon {
    display: none;
}

:root[data-theme="dark"] .theme-toggle__sun {
    display: block;
}

.header-tools {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: .5rem;
}

/* الشاشات الضيقة: الشعار والأسعار والزر والصورة يتسعون في سطر واحد. */
@media (max-width: 25rem) {
    .header-inner {
        gap: .45rem;
    }

    .header-tools {
        gap: .3rem;
    }

    .theme-toggle,
    .header-tools .user-avatar {
        width: 2rem;
        height: 2rem;
    }

    .brand-logo-badge {
        padding: .25rem .4rem;
    }

    .brand-logo {
        height: 1.6rem;
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --background: #0e1522;
    --surface: #172133;
    --surface-soft: #1c283c;
    --text: #e6ebf4;
    --muted: #9ba8bd;
    --border: #2b3a54;
    /* ألوان النص أفتح لتُقرأ على الخلفية الغامقة، والخلفيات الصلبة تبقى غامقة تحت النص الأبيض. */
    --primary: #86acf5;
    --primary-dark: #a9c5f9;
    --primary-soft: #1c2d4e;
    --primary-solid: #2f66cc;
    --primary-solid-dark: #22519f;
    --success: #4fd39c;
    --success-soft: #11332a;
    --success-solid: #1b8a5f;
    --warning: #f2b75a;
    --warning-soft: #33280f;
    --danger: #ff8a9b;
    --danger-soft: #3b1a23;
    --danger-solid: #c23a51;
    --shadow-sm: 0 .25rem 1rem rgb(0 0 0 / 28%);
    --shadow-md: 0 .75rem 2.5rem rgb(0 0 0 / 40%);
}

:root[data-theme="dark"] .site-header {
    border-bottom-color: rgb(255 255 255 / 8%);
    background: linear-gradient(135deg, #10234a, #1a3a78);
    box-shadow: 0 .25rem 1.25rem rgb(0 0 0 / 35%);
}

:root[data-theme="dark"] .user-avatar {
    border-color: rgb(255 255 255 / 18%);
    background: var(--surface-soft);
}

/* الحقول */
:root[data-theme="dark"] .field input,
:root[data-theme="dark"] .field select,
:root[data-theme="dark"] .field textarea,
:root[data-theme="dark"] .date-display__text {
    border-color: #34476a;
    color: var(--text);
    background: #111a2a;
}

:root[data-theme="dark"] .field input::placeholder,
:root[data-theme="dark"] .field textarea::placeholder {
    color: #6f7d94;
}

:root[data-theme="dark"] .field input:focus,
:root[data-theme="dark"] .field select:focus,
:root[data-theme="dark"] .field textarea:focus {
    box-shadow: 0 0 0 3px rgb(134 172 245 / 22%);
}

:root[data-theme="dark"] .type-option > span {
    border-color: #34476a;
}

:root[data-theme="dark"] .st-switch input {
    background: #3a4a66;
}

/* الأشرطة الثابتة شبه الشفافة */
:root[data-theme="dark"] .sticky-form-action {
    background: rgb(23 33 51 / 94%);
}

:root[data-theme="dark"] .bottom-navigation {
    background: rgb(18 27 42 / 96%);
    box-shadow: 0 -.5rem 1.75rem rgb(0 0 0 / 35%);
}

/* حدود كانت بدرجات فاتحة ثابتة */
:root[data-theme="dark"] .button--secondary,
:root[data-theme="dark"] .operation-card:hover {
    border-color: #36507f;
}

:root[data-theme="dark"] .button--danger,
:root[data-theme="dark"] .danger-zone,
:root[data-theme="dark"] .alert--error,
:root[data-theme="dark"] .tx-actions__delete {
    border-color: #6b2c3a;
}

:root[data-theme="dark"] .valuation-card {
    border-color: #245443;
}

:root[data-theme="dark"] .valuation-card--incomplete,
:root[data-theme="dark"] .duplicate-phone {
    border-color: #6a5220;
}

:root[data-theme="dark"] .valuation-card details {
    border-top-color: rgb(255 255 255 / 8%);
}

:root[data-theme="dark"] .operation-card__meta small {
    color: #7f8ca2;
}

:root[data-theme="dark"] .person-row--archived {
    background: #141c2b;
}

:root[data-theme="dark"] .person-row__valuation--incomplete {
    color: var(--warning);
    background: var(--warning-soft);
}

:root[data-theme="dark"] .trial-banner__action {
    border-color: color-mix(in srgb, var(--tone) 45%, var(--surface));
}

:root[data-theme="dark"] .trial-banner__action:hover {
    background: color-mix(in srgb, var(--tone) 18%, var(--surface));
}

:root[data-theme="dark"] .home-balance {
    box-shadow: 0 1rem 2.5rem rgb(0 0 0 / 35%);
}

/* صور الأشخاص بالحروف: نفس الألوان بدرجات ليلية */
:root[data-theme="dark"] .activity-row__avatar--0 { background: #1c2d4e; color: #9dbcf7; }
:root[data-theme="dark"] .activity-row__avatar--1 { background: #3a2a14; color: #f5b46a; }
:root[data-theme="dark"] .activity-row__avatar--2 { background: #11332a; color: #6fdcaa; }
:root[data-theme="dark"] .activity-row__avatar--3 { background: #3b1a23; color: #ff9aaa; }
:root[data-theme="dark"] .activity-row__avatar--4 { background: #2a2147; color: #b9a2f2; }
:root[data-theme="dark"] .activity-row__avatar--5 { background: #10313a; color: #6fd0e0; }

:root[data-theme="dark"] .icon-button--whatsapp {
    color: #4fd38a;
}

/* دعوة قناة التلغرام في الرئيسية */
:root[data-theme="dark"] .channel-invitation {
    border-color: #2b3f63;
    color: #c4d5f2;
    background: #15233b;
}

:root[data-theme="dark"] .channel-invitation__link {
    border-color: #34507f;
    color: var(--primary);
    background: var(--surface);
}

:root[data-theme="dark"] .channel-invitation__link:hover,
:root[data-theme="dark"] .channel-invitation__close:hover {
    background: #1d3050;
}

:root[data-theme="dark"] .channel-invitation__close {
    color: #93a7c6;
}

:root[data-theme="dark"] .channel-invitation :focus-visible {
    outline-color: var(--primary);
}

:root[data-theme="dark"] .channel-invitation__status {
    color: var(--warning);
}
