@font-face { font-family: "Vazirmatn"; src: url("../fonts/Vazirmatn-Regular.woff2") format("woff2"); font-style: normal; font-weight: 400; font-display: swap; }
@font-face { font-family: "Vazirmatn"; src: url("../fonts/Vazirmatn-Bold.woff2") format("woff2"); font-style: normal; font-weight: 700; font-display: swap; }

:root, html[data-theme="light"] {
    --service-accent: #48675b;
    --service-hover: #365246;
    --service-soft: #e5ece5;
    --service-section-bg: #c9dbce;
    --service-page: #f2f4f0;
    --service-surface: #fafbf8;
    --service-line: #d5ddd5;
    --service-muted: #5f6c62;
    --service-ink: #29332e;
    --service-gold: #b6a577;
    --service-gold-text: #74694d;
}
html[data-theme="dark"] {
    --service-accent: #b1c9b9;
    --service-hover: #d2e1d7;
    --service-soft: #2e3b33;
    --service-section-bg: #3c5547;
    --service-page: #1c2320;
    --service-surface: #252e29;
    --service-line: #44544a;
    --service-muted: #b8c5bb;
    --service-ink: #e7ece6;
    --service-gold: #c6b990;
    --service-gold-text: #ccc19f;
}
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]):not([data-theme="dark"]) {
    --service-accent: #b1c9b9;
    --service-hover: #d2e1d7;
    --service-soft: #2e3b33;
    --service-section-bg: #3c5547;
    --service-page: #1c2320;
    --service-surface: #252e29;
    --service-line: #44544a;
    --service-muted: #b8c5bb;
    --service-ink: #e7ece6;
    --service-gold: #c6b990;
    --service-gold-text: #ccc19f;
    }
}

/* Tejarat.Chat family: paper surfaces, restrained gold, service-specific ink.
   This layer leaves Django's RTL, sidebar geometry and permissions intact. */
:root, html[data-theme="light"], html[data-theme="dark"] {
    --font-family-primary: "Vazirmatn", Tahoma, Arial, sans-serif;
    --font-family-monospace: ui-monospace, monospace;
    --primary: var(--service-accent);
    --secondary: var(--service-accent);
    --accent: var(--service-gold);
    --primary-fg: #fffdf8;
    --body-bg: var(--service-page);
    --body-fg: var(--service-ink);
    --body-quiet-color: var(--service-muted);
    --body-medium-color: var(--service-muted);
    --body-loud-color: var(--service-ink);
    --header-bg: var(--service-surface);
    --header-color: var(--service-accent);
    --header-branding-color: var(--service-accent);
    --header-link-color: var(--service-accent);
    --breadcrumbs-bg: var(--service-soft);
    --breadcrumbs-fg: var(--service-ink);
    --breadcrumbs-link-fg: var(--service-accent);
    --link-fg: var(--service-accent);
    --link-hover-color: var(--service-hover);
    --link-selected-fg: var(--service-hover);
    --hairline-color: var(--service-line);
    --border-color: var(--service-line);
    --darkened-bg: var(--service-page);
    --selected-bg: var(--service-soft);
    --selected-row: var(--service-soft);
    --button-bg: var(--service-accent);
    --button-hover-bg: var(--service-hover);
    --default-button-bg: var(--service-accent);
    --default-button-hover-bg: var(--service-hover);
    --close-button-bg: #5e6367;
    --close-button-hover-bg: #40464b;
    --delete-button-bg: #a52e30;
    --delete-button-hover-bg: #802023;
    --error-fg: #a52e30;
    --message-success-bg: #e4efe4;
    --message-warning-bg: #fff0cf;
    --message-error-bg: #f9e3e0;
    color-scheme: light;
}

/* The native Django light / dark / system switch controls both palettes. */
html[data-theme="dark"] {
    --primary-fg: #182129;
    --error-fg: #ffa9a5;
    --delete-button-bg: #a52e30;
    --delete-button-hover-bg: #802023;
    --message-success-bg: #253d2f;
    --message-warning-bg: #49391e;
    --message-error-bg: #492c2b;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]):not([data-theme="dark"]) {
        --primary-fg: #182129;
        --error-fg: #ffa9a5;
        --message-success-bg: #253d2f;
        --message-warning-bg: #49391e;
        --message-error-bg: #492c2b;
        color-scheme: dark;
    }
}

body, input, textarea, select, button, .button, #header {
    font-family: var(--font-family-primary);
}
body { line-height: 1.65; }
::selection { background: var(--service-accent); color: var(--primary-fg); }
a, button, input, select, textarea { accent-color: var(--service-accent); }
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--service-accent);
    outline-offset: 3px;
}

#header {
    padding: 10px 20px;
    border-bottom: 2px solid var(--service-line);
    gap: 12px;
}
#header #branding #site-name a:link, #header #branding #site-name a:visited { color: var(--service-accent); }
#branding #site-name { margin: 0; font-size: 17px; font-weight: 700; }
#branding #site-name a { display: inline-flex; align-items: center; gap: 10px; }
.admin-service-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border: 1px solid var(--service-line);
    border-radius: 8px;
    background: var(--service-soft);
}
.admin-service-mark img { width: 28px; height: 28px; object-fit: contain; }
.admin-service-label {
    display: block;
    color: var(--service-muted);
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.3px;
    line-height: 1.6;
}
.admin-service-label b { color: var(--service-gold-text); font-weight: 700; }
#user-tools { color: var(--body-quiet-color); line-height: 2; }
#header #user-tools a, #header #logout-form button {
    border-bottom-color: var(--service-line);
}
div.breadcrumbs { padding: 8px 20px; border-bottom: 1px solid var(--service-line); }
#content { padding: 14px 20px; }
#content h1 { color: var(--body-loud-color); font-weight: 700; }

.module, .inline-group, #changelist, #content-related, .card {
    background: var(--service-surface);
    border: 1px solid var(--service-line);
    border-radius: 8px;
}
.module h2, .module caption, .inline-group h2 {
    background: var(--service-soft);
    color: var(--service-accent);
    border-radius: 7px 7px 0 0;
    font-weight: 700;
}
.module caption a.section:link, .module caption a.section:visited {
    color: var(--service-accent);
}
#content-related .module { border: 0; }
#content-related .module h2 { background: var(--service-soft); color: var(--service-accent); }
#nav-sidebar { background: var(--service-surface); }
#nav-sidebar .module { border: 0; border-radius: 0; margin-bottom: 10px; }
/* Section headings have a stronger surface than the selected model row. */
#nav-sidebar .module caption {
    background: var(--service-section-bg);
    color: var(--service-hover);
    border-radius: 0;
    border-block-end: 1px solid var(--service-line);
}
#nav-sidebar .module caption a.section:link,
#nav-sidebar .module caption a.section:visited {
    color: var(--service-hover);
}
#nav-sidebar .current-model { box-shadow: inset -3px 0 var(--service-accent); }
[dir="ltr"] #nav-sidebar .current-model { box-shadow: inset 3px 0 var(--service-accent); }
#nav-sidebar th a { display: block; }
#nav-sidebar tr:hover { background: var(--service-soft); }
#nav-filter { border-radius: 5px; padding: 7px 8px; }

#changelist { border-radius: 8px; }
#changelist #toolbar { background: var(--service-surface); border-radius: 8px 8px 0 0; }
#changelist .actions { box-sizing: border-box; background: var(--service-surface); color: var(--body-quiet-color); }
#changelist table thead th { background: var(--service-soft); color: var(--body-fg); }
#changelist table tbody tr { background: var(--service-surface); }
#changelist table tbody tr:nth-child(even) { background: var(--service-page); }
#changelist table tbody tr.selected { background: var(--selected-row); }
#changelist table tbody tr:hover { background: var(--service-soft); }
#changelist .paginator, .submit-row { background: var(--service-surface); }
#changelist-filter h2 { background: var(--service-accent); color: var(--primary-fg); }
/* Keep the existing filter control reachable above its overlay. */
body.filters-open .admin-filter-toggle {
    position: fixed;
    inset-block-start: 8px;
    inset-inline-end: 10px;
    z-index: 41;
    border: 1px solid var(--service-line);
    background: var(--service-surface);
    color: var(--service-accent);
    padding: 6px 12px;
}
body.filters-open #changelist-filter h2 { padding-inline-end: 75px; }

input[type="text"], input[type="password"], input[type="email"], input[type="url"],
input[type="number"], input[type="tel"], textarea, select, .vTextField {
    background: var(--service-surface);
    color: var(--body-fg);
    border-color: var(--service-line);
    border-radius: 5px;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="email"]:focus,
input[type="tel"]:focus, textarea:focus, select:focus { border-color: var(--service-accent); }
.button, input[type="submit"], input[type="button"], .submit-row input,
.object-tools a, .admin-filter-toggle { border-radius: 5px; }
.object-tools a:link, .object-tools a:visited {
    background-color: var(--service-accent);
    color: var(--primary-fg);
}
.object-tools a:hover { background-color: var(--service-hover); }
.submit-row { border-color: var(--service-line); border-radius: 8px; }
.admin-page-hint, .help, p.help, .card-body { color: var(--body-quiet-color); }
.card-header { background: var(--service-soft); border-color: var(--service-line); }
.table th, .table td { border-color: var(--service-line); }
.btn { border-color: var(--service-accent); }

/* Existing custom OTP pages use the same theme, without touching their flow. */
body.admin-login {
    box-sizing: border-box;
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--service-page);
    color: var(--service-ink);
    line-height: 1.75;
}
.admin-login *, .admin-login *::before, .admin-login *::after { box-sizing: border-box; }
.admin-login .card, .admin-login .login-container {
    width: 100%;
    max-width: 420px;
    padding: 32px;
    margin: 0;
    text-align: center;
    border: 1px solid var(--service-line);
    border-top: 4px solid var(--service-accent);
    border-radius: 12px;
    background: var(--service-surface);
    box-shadow: 0 14px 40px #211c1510;
}
.admin-login .brand { margin-bottom: 24px; }
.admin-login .brand img, .admin-login .logo img { width: 56px; height: 56px; object-fit: contain; }
.admin-login .logo { margin: 0 auto 20px; }
.admin-login h1, .admin-login .site-name {
    display: block; margin: 12px 0 6px; font-size: 21px; font-weight: 700; color: var(--service-accent);
}
.admin-login .panel-title, .admin-login .subtitle { display: block; margin: 0 0 20px; font-size: 14px; color: var(--service-muted); }
.admin-login .field, .admin-login .form-group { margin-bottom: 16px; text-align: start; }
.admin-login label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 700; }
.admin-login input[type="text"], .admin-login input[type="tel"], .admin-login input[type="password"] {
    width: 100%; padding: 12px; font-size: 16px; direction: ltr; text-align: center;
}
.admin-login .hidden { display: none !important; }
.admin-login .actions { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.admin-login .btn-row { display: flex; gap: 10px; }
.admin-login .btn, .admin-login .btn-submit, .admin-login .btn-secondary {
    width: 100%; padding: 12px; border: 1px solid var(--service-accent); border-radius: 7px;
    font-size: 14px; font-weight: 700; cursor: pointer;
    background: var(--service-accent); color: var(--primary-fg);
}
.admin-login .btn-bale, .admin-login .btn-secondary {
    background: var(--service-surface); color: var(--service-accent);
}
.admin-login .btn:hover, .admin-login .btn-submit:hover {
    background: var(--service-hover); color: var(--primary-fg);
}
.admin-login button:disabled { opacity: 0.55; cursor: not-allowed; }
.admin-login .btn-secondary { margin-top: 12px; }
.admin-login .footer-note, .admin-login .footer, .admin-login .timer {
    margin-top: 20px; color: var(--service-muted); font-size: 12px;
}
.admin-login .timer span { color: var(--error-fg); font-weight: 700; }
.admin-login .mobile-display { margin: 12px 0 20px; direction: ltr; color: var(--service-accent); }
.admin-login .back-link { display: inline-block; margin-top: 16px; font-size: 13px; }
.admin-login .msg, .admin-login .message { padding: 10px 12px; margin-bottom: 16px; border-radius: 6px; font-size: 13px; }
.admin-login .msg-error, .admin-login .error { background: var(--message-error-bg); color: var(--error-fg); }
.admin-login .msg-success, .admin-login .success { background: var(--message-success-bg); }
.admin-login .info { background: var(--service-soft); }

@media (max-width: 767px) {
    #header { padding: 10px 12px; }
    #branding #site-name { font-size: 15px; }
    #content { padding: 12px; }
    div.breadcrumbs { padding: 8px 12px; }
    .admin-service-label { font-size: 9px; }
    .admin-login .card, .admin-login .login-container { padding: 24px 20px; }
}
@media (forced-colors: active) {
    #nav-sidebar .current-model { outline: 2px solid Highlight; }
}

/* Actions use the same palette without resetting the shared dropdown arrow. */
body.rtl-admin #changelist-form .actions select[name="action"] {
    background-color: var(--service-surface);
    border-color: var(--service-line);
    color: var(--body-fg);
}
body.rtl-admin #changelist-form .actions {
    box-sizing: border-box;
    background: var(--service-surface);
    border-color: var(--service-line);
}
