/* =========================================================
   AutoReply — admin panel
   Mürəkkəb-göy menyu, daş rəngli fon, süet-qəhvəyi aksent.
   1C kodları paltar etiketi (hang-tag) kimi göstərilir.
   ========================================================= */

:root {
    --ink: #1C2533;          /* kənar menyu, əsas mətn */
    --ink-soft: #2A3546;
    --stone: #E9EBE6;        /* səhifə fonu */
    --paper: #FFFFFF;        /* iş səthləri */
    --line: #D5D8D0;         /* incə xətlər */
    --muted: #6A7280;
    --suede: #8A5A3C;        /* aksent: düymələr, etiketlər */
    --suede-dark: #6F4630;
    --suede-tint: #F3ECE6;
    --olive: #557043;        /* uğurlu / aktiv */
    --olive-tint: #E8EEE2;
    --brick: #A8402D;        /* xəta */
    --brick-tint: #F6E5E1;
    --amber: #9A6B12;
    --amber-tint: #F6EEDC;

    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 18px;

    --font: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;

    --bs-body-font-family: var(--font);
    --bs-body-color: var(--ink);
    --bs-body-bg: var(--stone);
    --bs-border-color: var(--line);
    --bs-link-color: var(--suede);
    --bs-link-color-rgb: 138, 90, 60;
    --bs-link-hover-color: var(--suede-dark);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--stone);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--suede); text-decoration: none; }
a:hover { color: var(--suede-dark); text-decoration: underline; }

:focus-visible { outline: 2px solid var(--suede); outline-offset: 2px; }

h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.015em; color: var(--ink); margin: 0; }
h1 { font-size: 1.75rem; line-height: 1.2; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

/* ---------- Karkas ---------- */

.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.rail {
    background: var(--ink);
    color: #C9D0DB;
    padding: 22px 14px;
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column; gap: 4px;
}

.brand {
    display: flex; align-items: center; gap: 10px;
    color: #fff; font-weight: 700; font-size: 1.05rem;
    padding: 4px 10px 22px;
}
.brand:hover { color: #fff; text-decoration: none; }
.brand-mark {
    width: 30px; height: 30px; border-radius: 8px;
    background: var(--suede); color: #fff;
    display: grid; place-items: center; font-size: .9rem;
}

.rail a.nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 12px; border-radius: var(--r-sm);
    color: #C9D0DB; font-weight: 500;
}
.rail a.nav-item svg { width: 18px; height: 18px; opacity: .75; flex: none; }
.rail a.nav-item:hover { background: var(--ink-soft); color: #fff; text-decoration: none; }
.rail a.nav-item.active { background: var(--ink-soft); color: #fff; box-shadow: inset 3px 0 0 var(--suede); }
.rail a.nav-item.active svg { opacity: 1; }

.rail-foot { margin-top: auto; padding: 10px; font-size: .85rem; }
.rail-foot button {
    background: none; border: 1px solid #3A4659; color: #C9D0DB;
    border-radius: var(--r-sm); padding: 6px 12px; width: 100%; cursor: pointer;
}
.rail-foot button:hover { color: #fff; border-color: #56647A; }

.main { padding: 32px 40px 64px; min-width: 0; }
.main-inner { max-width: 1240px; }

.page-head {
    display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
    gap: 16px; margin-bottom: 24px;
}
.page-head p { color: var(--muted); margin: 6px 0 0; max-width: 68ch; }

@media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; }
    .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; }
    .brand { padding: 4px 10px; }
    .rail-foot { margin: 0 0 0 auto; padding: 0; }
    .rail-foot button { width: auto; }
    .main { padding: 20px 16px 48px; }
}

/* ---------- Düymələr ---------- */

.btn-x {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    font: inherit; font-weight: 600; font-size: .9rem;
    padding: 8px 15px; border-radius: var(--r-sm);
    border: 1px solid transparent; cursor: pointer; white-space: nowrap;
    transition: background-color .12s, border-color .12s;
}
.btn-x:hover { text-decoration: none; }
.btn-x:disabled { opacity: .55; cursor: default; }
.btn-x.sm { padding: 5px 11px; font-size: .84rem; }

.btn-primary-x { background: var(--suede); color: #fff; }
.btn-primary-x:hover { background: var(--suede-dark); color: #fff; }
.btn-ink { background: var(--ink); color: #fff; }
.btn-ink:hover { background: var(--ink-soft); color: #fff; }
.btn-line { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn-line:hover { border-color: #AEB3A8; color: var(--ink); }
.btn-ghost { background: none; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); background: rgba(28,37,51,.06); }
.btn-danger-x { background: none; color: var(--brick); }
.btn-danger-x:hover { background: var(--brick-tint); color: var(--brick); }

/* ---------- Formlar ---------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.field > label { font-weight: 600; font-size: .9rem; }
.field .hint { color: var(--muted); font-size: .84rem; }

.input, .select, .textarea {
    font: inherit; color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--line); border-radius: var(--r-sm);
    padding: 9px 12px; width: 100%;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--suede); box-shadow: 0 0 0 3px rgba(138,90,60,.15); }
.textarea { resize: vertical; min-height: 44px; }

.switch { display: flex; align-items: flex-start; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); cursor: pointer; }
.switch:first-of-type { border-top: 0; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
    flex: none; width: 38px; height: 22px; border-radius: 11px; background: #C3C7BE;
    position: relative; transition: background .15s; margin-top: 1px;
}
.switch .track::after {
    content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
    border-radius: 50%; background: #fff; transition: transform .15s;
}
.switch input:checked + .track { background: var(--olive); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--suede); outline-offset: 2px; }
.switch strong { display: block; font-weight: 600; }
.switch span.d { color: var(--muted); font-size: .86rem; }

.radio-row { display: grid; gap: 8px; }
.radio-card {
    display: flex; gap: 12px; align-items: flex-start;
    border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px;
    background: var(--paper); cursor: pointer;
}
.radio-card input { margin-top: 4px; accent-color: var(--suede); }
.radio-card:has(input:checked) { border-color: var(--suede); background: var(--suede-tint); }
.radio-card strong { display: block; font-weight: 600; }
.radio-card span { color: var(--muted); font-size: .86rem; }

/* ---------- Səthlər ---------- */

.sheet { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); }
.sheet-pad { padding: 24px 28px; }
.section-title { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.section-sub { color: var(--muted); font-size: .88rem; margin-bottom: 14px; }

.flash { border-radius: var(--r-md); padding: 11px 16px; margin-bottom: 20px; font-weight: 500; }
.flash.ok { background: var(--olive-tint); color: #354A28; }
.flash.err { background: var(--brick-tint); color: #7A2B1D; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.on { background: var(--olive-tint); color: var(--olive); }
.pill.off { background: #E4E6E1; color: var(--muted); }
.pill.warn { background: var(--amber-tint); color: var(--amber); }
.pill.err { background: var(--brick-tint); color: var(--brick); }

.empty { text-align: center; padding: 56px 24px; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }

/* ---------- Hesablar ---------- */

.accounts { display: grid; gap: 14px; }
.account {
    display: grid; grid-template-columns: 56px 1fr auto; gap: 18px; align-items: center;
    padding: 18px 22px;
}
.avatar { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; background: var(--suede-tint); display: grid; place-items: center; font-weight: 700; color: var(--suede); font-size: 1.2rem; }
.account h3 { font-size: 1.05rem; }
.account .handle { color: var(--muted); font-size: .9rem; }
.account .facts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: .85rem; color: var(--muted); }
.account .facts b { color: var(--ink); font-weight: 600; }
.account .acts { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; align-items: center; }
@media (max-width: 760px) { .account { grid-template-columns: 48px 1fr; } .account .acts { grid-column: 1 / -1; justify-content: flex-start; } }

.dropdown-menu { border-color: var(--line); border-radius: var(--r-md); box-shadow: 0 8px 24px rgba(28,37,51,.12); font-size: .9rem; }
.dropdown-item { padding: 7px 14px; }
.dropdown-item:active { background: var(--suede); }

/* ---------- Postlar ---------- */

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.seg { display: inline-flex; background: #DDE0D9; border-radius: var(--r-sm); padding: 3px; }
.seg a { padding: 5px 12px; border-radius: 4px; color: var(--muted); font-weight: 600; font-size: .86rem; }
.seg a:hover { color: var(--ink); text-decoration: none; }
.seg a.on { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.post { margin-bottom: 22px; }
.post-head {
    display: grid; grid-template-columns: 1fr auto; gap: 16px 24px; align-items: start;
    padding: 20px 24px 16px; border-bottom: 1px solid var(--line);
}
.post-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: .85rem; color: var(--muted); }
.post-type { font-weight: 600; color: var(--ink); }
.post-caption { margin: 6px 0 0; color: var(--ink); max-width: 75ch; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-actions { display: flex; gap: 8px; align-items: center; }
.post-general { display: flex; gap: 10px; align-items: center; padding: 14px 24px; background: #F6F7F4; border-bottom: 1px solid var(--line); }
.post-general label { font-weight: 600; font-size: .88rem; white-space: nowrap; }
.post-general .textarea { max-width: 420px; }
@media (max-width: 760px) { .post-head { grid-template-columns: 1fr; } .post-general { flex-wrap: wrap; } }

.frames { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; padding: 20px 24px 24px; }
.frame { display: flex; flex-direction: column; gap: 10px; }
.frame-img { position: relative; aspect-ratio: 4 / 5; border-radius: var(--r-md); overflow: hidden; background: #DADDD5; }
.frame-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.frame-img .novideo { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: .85rem; }
.frame-no {
    position: absolute; left: 8px; top: 8px; min-width: 28px; height: 28px; padding: 0 8px;
    border-radius: 14px; background: rgba(28,37,51,.82); color: #fff;
    font-weight: 700; font-size: .85rem; display: grid; place-items: center;
}
.frame-count {
    position: absolute; right: 8px; bottom: 8px; padding: 2px 8px; border-radius: 10px;
    background: var(--suede); color: #fff; font-size: .76rem; font-weight: 600;
}
.frame .textarea, .post-general .textarea { font-size: .88rem; min-height: 40px; resize: none; overflow: hidden; }

/* Paltar etiketi: 1C məhsulu */
.tags { display: flex; flex-direction: column; gap: 6px; }
.tag {
    position: relative; display: grid; grid-template-columns: 1fr auto; gap: 1px 10px; align-items: baseline;
    padding: 8px 12px 8px 22px; background: var(--suede-tint);
    border-radius: 4px 10px 10px 4px; font-size: .82rem; line-height: 1.35;
    clip-path: polygon(10px 0, 100% 0, 100% 100%, 10px 100%, 0 50%);
}
.tag::before {
    content: ""; position: absolute; left: 10px; top: 50%; width: 5px; height: 5px;
    margin-top: -2.5px; border-radius: 50%; background: var(--paper);
}
.tag .t-name { grid-column: 1 / -1; font-weight: 600; overflow-wrap: anywhere; }
.tag .t-price { grid-column: 1; grid-row: 2; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tag .t-price s { color: var(--muted); font-weight: 500; margin-right: 4px; }
.tag .t-sizes { grid-column: 1 / -1; color: var(--muted); }
.tag.bad .t-price:empty, .tag.wait .t-price:empty { display: none; }
.tag.bad { background: var(--brick-tint); color: var(--brick); }
.tag.wait { background: #ECEEE9; color: var(--muted); }

/* ---------- Test: söhbət ---------- */

.chat-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 22px; align-items: start; }
@media (max-width: 1080px) { .chat-wrap { grid-template-columns: 1fr; } }

.phone { display: flex; flex-direction: column; height: min(78vh, 760px); overflow: hidden; }
.phone-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.phone-head .avatar { width: 38px; height: 38px; font-size: .95rem; }
.phone-head .who { line-height: 1.25; }
.phone-head .who small { color: var(--muted); }
.phone-head .spacer { flex: 1; }

.thread { flex: 1; overflow-y: auto; padding: 20px 18px; display: flex; flex-direction: column; gap: 6px; background: #FAFAF8; }
.thread .day { align-self: center; color: var(--muted); font-size: .78rem; margin: 4px 0 10px; }

.bubble { max-width: 76%; padding: 9px 14px; border-radius: 20px; white-space: pre-wrap; word-wrap: break-word; }
.bubble.me { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 6px; }
.bubble.bot { align-self: flex-start; background: #ECEEE9; border-bottom-left-radius: 6px; }
.bubble.skip { align-self: flex-start; background: none; border: 1px dashed var(--line); color: var(--muted); font-size: .86rem; }
.bubble.fail { align-self: flex-start; background: var(--brick-tint); color: #7A2B1D; font-size: .86rem; }
.bubble.typing { align-self: flex-start; background: #ECEEE9; color: var(--muted); }
.bubble-meta { font-size: .74rem; color: var(--muted); margin: 0 6px 6px; }
.bubble-meta.right { align-self: flex-end; }
.bubble-meta button { background: none; border: 0; padding: 0; color: var(--suede); font: inherit; cursor: pointer; }

.shared-post { align-self: flex-end; display: flex; gap: 10px; align-items: center; max-width: 76%;
    border: 1px solid var(--line); background: var(--paper); border-radius: 16px; padding: 8px 12px 8px 8px; font-size: .84rem; }
.shared-post img { width: 44px; height: 54px; object-fit: cover; border-radius: 8px; }

.composer { border-top: 1px solid var(--line); padding: 12px 14px; display: flex; gap: 10px; align-items: flex-end; background: var(--paper); }
.composer .textarea { resize: none; border-radius: 20px; padding: 10px 16px; min-height: 44px; max-height: 140px; }
.composer .btn-x { border-radius: 20px; padding: 10px 18px; }

.side { display: flex; flex-direction: column; gap: 16px; }
.side .sheet-pad { padding: 18px 20px; }
.post-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; max-height: 260px; overflow-y: auto; margin-top: 10px; }
.post-pick button { padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: #DADDD5; aspect-ratio: 4/5; cursor: pointer; position: relative; }
.post-pick button img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-pick button.sel { border-color: var(--suede); }
.post-pick button .n { position: absolute; right: 3px; bottom: 3px; background: rgba(28,37,51,.8); color: #fff; font-size: .7rem; border-radius: 6px; padding: 0 5px; }
.post-pick button.none { display: grid; place-items: center; font-size: .75rem; color: var(--muted); background: #ECEEE9; }

.inspect dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: .86rem; }
.inspect dt { color: var(--muted); font-weight: 500; }
.inspect dd { margin: 0; }
.inspect ul { padding-left: 18px; margin: 8px 0 0; font-size: .84rem; }
.inspect pre { white-space: pre-wrap; font-size: .76rem; background: #F4F5F2; border-radius: var(--r-sm); padding: 10px; max-height: 320px; overflow: auto; margin-top: 8px; }
.inspect summary { cursor: pointer; font-weight: 600; font-size: .86rem; margin-top: 12px; }
.cost-line { font-size: .86rem; padding: 10px 12px; border-radius: var(--r-sm); background: var(--olive-tint); color: #354A28; }

/* ---------- Jurnal ---------- */

.log-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.log-table th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; padding: 12px 14px; border-bottom: 1px solid var(--line); background: #F6F7F4; }
.log-table td { padding: 12px 14px; border-bottom: 1px solid #ECEEE9; vertical-align: top; }
.log-table tr:last-child td { border-bottom: 0; }
.log-table .q { color: var(--ink); }
.log-table .a { color: var(--muted); }
.log-table .when { white-space: nowrap; color: var(--muted); }
.table-scroll { overflow-x: auto; }

/* ---------- Giriş ---------- */

.login-page { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-art { background: var(--ink); color: #C9D0DB; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art .quote { font-size: 1.6rem; line-height: 1.3; color: #fff; font-weight: 600; max-width: 18ch; letter-spacing: -0.01em; }
.login-art .tag { max-width: 280px; background: #2A3546; color: #fff; }
.login-art .tag .t-sizes { color: #9AA5B5; }
.login-form { display: grid; place-items: center; padding: 32px 16px; }
.login-form form { width: 100%; max-width: 360px; }
@media (max-width: 820px) { .login-page { grid-template-columns: 1fr; } .login-art { display: none; } }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Hesab ayarları ---------- */
.edit-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 22px; align-items: start; }
.edit-col { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-2 .field { margin-bottom: 14px; }
.save-bar { position: sticky; bottom: 16px; display: flex; gap: 10px; padding: 12px; background: rgba(233,235,230,.92); border-radius: var(--r-md); backdrop-filter: blur(4px); }
@media (max-width: 960px) { .edit-grid { grid-template-columns: 1fr; } }

/* Hesablar səhifəsində tez açarlar */
.quick { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; }
.quick .switch { padding: 0; border: 0; align-items: center; gap: 8px; font-size: .88rem; font-weight: 500; }
.quick .switch .track { width: 32px; height: 18px; border-radius: 9px; }
.quick .switch .track::after { width: 12px; height: 12px; }
.quick .switch input:checked + .track::after { transform: translateX(14px); }
.quick .switch.dim { opacity: .5; }
