/* ==========================================================================
   Grays Motors – admin panel styles
   ========================================================================== */

:root {
    --orange: #f26a1b;
    --orange-dark: #d4550b;
    --orange-soft: #fff1e8;
    --ink: #15171a;
    --sidebar: #17191d;
    --sidebar-line: #262a30;
    --text: #2f343b;
    --muted: #6b7280;
    --line: #e7e8eb;
    --bg: #f4f5f7;
    --card: #ffffff;
    --whatsapp: #25d366;
    --danger: #dc2626;
    --radius: 12px;
    --shadow-sm: 0 1px 2px rgba(17, 24, 39, .05), 0 1px 3px rgba(17, 24, 39, .07);
    --font-head: "Barlow Condensed", "Arial Narrow", sans-serif;
    --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: var(--font-body); font-size: 14.5px; line-height: 1.55; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--orange-dark); text-decoration: none; }
a:hover { color: var(--orange); }
h1, h2, h3 { margin: 0; color: var(--ink); }
img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid rgba(242, 106, 27, .5); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- Layout ---------- */
.admin { display: flex; min-height: 100vh; }
.sidebar { width: 252px; flex-shrink: 0; background: var(--sidebar); color: #a3a9b2; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 30; }
.sidebar__brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px; color: #fff; border-bottom: 1px solid var(--sidebar-line); }
.sidebar__brand:hover { color: #fff; }
.sidebar__mark { width: 40px; height: 40px; border-radius: 10px; background: linear-gradient(135deg, var(--orange), var(--orange-dark)); display: grid; place-items: center; color: #fff; font-size: 1.1rem; flex-shrink: 0; }
.sidebar__brand strong, .auth__brand strong { display: block; font-family: var(--font-head); font-size: 1.35rem; text-transform: uppercase; letter-spacing: .5px; line-height: 1; }
.sidebar__brand small, .auth__brand small { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: 1.5px; color: #7c838d; margin-top: 3px; }
.sidebar__nav { padding: 16px 12px; display: grid; gap: 2px; flex: 1; overflow-y: auto; align-content: start; }
.sidebar__link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: #b9bec6; font-weight: 500; width: 100%; font: inherit; font-weight: 500; text-align: left; }
.sidebar__link i { width: 18px; text-align: center; color: #7c838d; }
.sidebar__link:hover { background: #1f2227; color: #fff; }
.sidebar__link.is-active { background: rgba(242, 106, 27, .14); color: #fff; }
.sidebar__link.is-active i { color: var(--orange); }
.sidebar__link--button { background: none; border: 0; cursor: pointer; }
.sidebar__badge { margin-left: auto; background: var(--orange); color: #fff; font-size: .72rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.sidebar__footer { padding: 12px; border-top: 1px solid var(--sidebar-line); display: grid; gap: 2px; }
.sidebar-backdrop { display: none; }

.admin__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 18px 32px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar__menu { display: none; background: none; border: 1px solid var(--line); border-radius: 8px; width: 40px; height: 40px; cursor: pointer; font-size: 1.1rem; color: var(--ink); }
.topbar__title { flex: 1; min-width: 0; }
.topbar__title h1 { font-family: var(--font-head); font-size: 1.75rem; text-transform: uppercase; letter-spacing: .3px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__title p { margin: 2px 0 0; color: var(--muted); font-size: .9rem; }
.topbar__actions { display: flex; align-items: center; gap: 12px; }
.topbar__user { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--ink); padding-left: 12px; border-left: 1px solid var(--line); }
.admin__content { padding: 28px 32px 48px; max-width: 1400px; width: 100%; }

.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--ink); color: #fff; display: inline-grid; place-items: center; font-weight: 700; flex-shrink: 0; font-size: .9rem; }
.avatar--sm { width: 32px; height: 32px; font-size: .8rem; }
.avatar--lg { width: 52px; height: 52px; font-size: 1.2rem; background: var(--orange); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; font-size: .9rem; padding: 10px 16px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; transition: background .15s, border-color .15s, color .15s; white-space: nowrap; line-height: 1.2; }
.btn--sm { padding: 6px 12px; font-size: .82rem; }
.btn--block { width: 100%; }
.btn--primary { background: var(--orange); color: #fff; }
.btn--primary:hover { background: var(--orange-dark); color: #fff; }
.btn--dark { background: var(--ink); color: #fff; }
.btn--dark:hover { background: #000; color: #fff; }
.btn--ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn--ghost:hover { border-color: #c9ccd2; color: var(--ink); background: #fafafa; }
.btn--whatsapp { background: var(--whatsapp); color: #fff; }
.btn--whatsapp:hover { background: #1ebe5b; color: #fff; }
.btn--danger-ghost { background: transparent; color: var(--danger); border-color: #fecaca; }
.btn--danger-ghost:hover { background: #fef2f2; color: var(--danger); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.stack { display: grid; gap: 10px; }

.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--text); cursor: pointer; font-size: .85rem; }
.icon-btn:hover { border-color: var(--orange); color: var(--orange); }
.icon-btn--wa { color: #16a34a; }
.icon-btn--danger:hover { border-color: var(--danger); color: var(--danger); }
.link { font-weight: 600; font-size: .88rem; }

/* ---------- Flash ---------- */
.flash { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 10px; margin-bottom: 20px; font-weight: 500; }
.flash span { flex: 1; }
.flash button { background: none; border: 0; cursor: pointer; color: inherit; opacity: .7; }
.flash--success { background: #ecfdf3; color: #15803d; border: 1px solid #bbf7d0; }
.flash--error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); margin-bottom: 22px; }
.card--flush { padding: 0; overflow: hidden; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card__head h2 { font-size: 1.02rem; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.card__head h2 i { color: var(--orange); }
.card__head--spaced { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.card h2 { font-size: 1.02rem; }
.narrow { max-width: 640px; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 22px; }
.stat { display: flex; align-items: center; gap: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); color: var(--text); transition: transform .15s, box-shadow .15s; }
.stat:hover { transform: translateY(-2px); box-shadow: 0 10px 24px -14px rgba(0, 0, 0, .3); color: var(--text); }
.stat__icon { width: 50px; height: 50px; border-radius: 12px; display: grid; place-items: center; font-size: 1.25rem; flex-shrink: 0; }
.stat strong { display: block; font-family: var(--font-head); font-size: 2.1rem; line-height: 1; color: var(--ink); }
.stat span { color: var(--muted); font-size: .86rem; }
.stat--orange .stat__icon { background: var(--orange-soft); color: var(--orange); }
.stat--blue .stat__icon { background: #eaf1ff; color: #2563eb; }
.stat--green .stat__icon { background: #e8f8ee; color: #16a34a; }
.stat--dark .stat__icon { background: #ececee; color: var(--ink); }

.dash-grid { display: grid; grid-template-columns: 1fr 360px; gap: 22px; align-items: start; }
.dash-side .card { margin-bottom: 22px; }

.upcoming, .msg-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--text); }
.upcoming:last-child, .msg-row:last-child { border-bottom: 0; }
.upcoming:hover, .msg-row:hover { color: var(--text); background: #fafafa; }
.upcoming__date { width: 46px; text-align: center; border-radius: 8px; background: var(--orange-soft); padding: 4px 0; flex-shrink: 0; }
.upcoming__date strong { display: block; font-family: var(--font-head); font-size: 1.3rem; color: var(--orange-dark); line-height: 1; }
.upcoming__date small { text-transform: uppercase; font-size: .68rem; font-weight: 700; color: var(--orange-dark); }
.upcoming__body, .msg-row__body { flex: 1; min-width: 0; }
.upcoming__body strong, .msg-row__body strong { display: block; color: var(--ink); }
.upcoming__body small, .msg-row__body small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-row time { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.msg-row.is-unread strong::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--orange); margin-left: 6px; vertical-align: middle; }

.card--quick h2 { margin-bottom: 12px; }
.quick { display: grid; gap: 6px; }
.quick a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; background: var(--bg); color: var(--ink); font-weight: 500; }
.quick a:hover { background: var(--orange-soft); color: var(--orange-dark); }
.quick i { color: var(--orange); width: 16px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -22px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; padding: 10px 22px; background: #fafafb; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 14px 22px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fcfcfd; }
.table td strong { color: var(--ink); font-weight: 600; }
.table td small { display: block; color: var(--muted); font-size: .8rem; }
.table td small a { color: var(--muted); }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions form { display: inline; }
.table .actions > * + * { margin-left: 6px; }
.table tr.is-muted td { opacity: .55; }
.ref { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-weight: 600; font-size: .85rem; white-space: nowrap; }

.svc-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--orange-soft); color: var(--orange); display: inline-grid; place-items: center; }
.svc-icon--lg { width: 46px; height: 46px; font-size: 1.2rem; flex-shrink: 0; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.badge--new { background: var(--orange-soft); color: var(--orange-dark); }
.badge--confirmed { background: #eaf1ff; color: #1d4ed8; }
.badge--in_progress { background: #fef6e0; color: #a16207; }
.badge--completed { background: #e8f8ee; color: #15803d; }
.badge--cancelled { background: #f1f2f4; color: #6b7280; }

/* ---------- Tabs / toolbar ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 8px 14px; border-radius: 8px; color: var(--text); font-weight: 600; white-space: nowrap; background: transparent; border: 1px solid transparent; }
.tab span { background: #e7e8eb; color: var(--muted); border-radius: 999px; padding: 0 7px; font-size: .75rem; margin-left: 4px; }
.tab:hover { background: #fff; border-color: var(--line); color: var(--ink); }
.tab.is-active { background: #fff; border-color: var(--line); color: var(--ink); box-shadow: var(--shadow-sm); }
.tab.is-active span { background: var(--orange); color: #fff; }

.toolbar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.search { position: relative; flex: 1; min-width: 220px; }
.search i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { width: 100%; padding: 10px 12px 10px 38px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.search input:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(242, 106, 27, .15); }

/* ---------- Pagination ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 18px; flex-wrap: wrap; }
.pager__info { margin: 0; color: var(--muted); font-size: .85rem; }
.pager__list { list-style: none; display: flex; gap: 4px; margin: 0; padding: 0; }
.pager__link { display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); font-weight: 600; font-size: .85rem; }
.pager__link.is-current { background: var(--orange); border-color: var(--orange); color: #fff; }
.pager__link.is-disabled { color: #c3c6cc; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label, .field-label { display: block; font-weight: 600; color: var(--ink); margin: 0 0 6px; font-size: .88rem; }
.field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), .field select, .field textarea,
.photo__form input, .photo__form select {
    width: 100%; font: inherit; color: var(--ink); padding: 10px 12px; border: 1px solid #d5d8dd; border-radius: 8px; background: #fff; transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .photo__form input:focus, .photo__form select:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(242, 106, 27, .15); }
.field [aria-invalid="true"] { border-color: var(--danger) !important; }
.field-error { color: var(--danger); font-size: .82rem; margin: 6px 0 0; }
.hint { color: var(--muted); font-size: .82rem; margin: 6px 0 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.check { display: flex; align-items: center; gap: 8px; margin: 4px 0 20px; cursor: pointer; }
.check input { accent-color: var(--orange); width: 16px; height: 16px; }

.toggle { display: flex; align-items: flex-start; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle__track { width: 40px; height: 22px; border-radius: 999px; background: #d5d8dd; position: relative; flex-shrink: 0; transition: background .2s; margin-top: 2px; }
.toggle__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.toggle input:checked + .toggle__track { background: var(--orange); }
.toggle input:checked + .toggle__track::after { transform: translateX(18px); }
.toggle input:focus-visible + .toggle__track { outline: 3px solid rgba(242, 106, 27, .4); outline-offset: 2px; }
.toggle strong { display: block; color: var(--ink); font-size: .9rem; }
.toggle small { color: var(--muted); font-size: .8rem; }
.toggle + .btn { margin-top: 8px; }

.icon-input { display: flex; gap: 10px; align-items: center; }
.icon-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 6px; margin-top: 10px; }
.icon-choice { height: 36px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); cursor: pointer; }
.icon-choice:hover { border-color: var(--orange); color: var(--orange); }

.status-picker { display: grid; gap: 6px; }
.status-option { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-weight: 500; }
.status-option input { accent-color: var(--orange); }
.status-option:has(input:checked) { border-color: var(--orange); background: var(--orange-soft); color: var(--ink); }

/* ---------- Detail pages ---------- */
.detail-grid { display: grid; grid-template-columns: 1fr 340px; gap: 22px; align-items: start; }
.detail-main .card:last-child, .detail-side .card:last-child { margin-bottom: 0; }
.detail-side { display: grid; gap: 22px; }
.detail-side .card { margin-bottom: 0; }
.dl { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px 24px; }
.dl dt { font-size: .74rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.dl dd { margin: 0; color: var(--ink); font-weight: 500; }
.label { font-size: .74rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 22px 0 8px; }
.note { background: var(--bg); border-radius: 10px; padding: 14px 16px; color: var(--ink); }
.note--lg { font-size: 1rem; line-height: 1.7; padding: 20px 22px; }
.message-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.message-head strong { display: block; color: var(--ink); font-size: 1.05rem; }
.danger-zone { margin: 0; }

/* ---------- Inbox ---------- */
.inbox-row { display: flex; gap: 14px; padding: 16px 22px; border-bottom: 1px solid var(--line); color: var(--text); align-items: flex-start; }
.inbox-row:last-child { border-bottom: 0; }
.inbox-row:hover { background: #fafafb; color: var(--text); }
.inbox-row__body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.inbox-row__top { display: flex; gap: 10px; align-items: baseline; }
.inbox-row__top strong { color: var(--ink); }
.inbox-row__subject { color: var(--ink); }
.inbox-row__preview { color: var(--muted); font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-row time { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.inbox-row.is-unread { background: #fffaf6; }
.inbox-row.is-unread .inbox-row__subject { font-weight: 700; }
.inbox-row.is-unread .avatar { background: var(--orange); }

/* ---------- Gallery ---------- */
.upload__grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; }
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; border: 2px dashed #d5d8dd; border-radius: 12px; padding: 32px 20px; cursor: pointer; transition: border-color .15s, background .15s; min-height: 180px; }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone i { font-size: 2.2rem; color: var(--orange); }
.dropzone strong { color: var(--ink); }
.dropzone small { color: var(--muted); }
.dropzone:hover, .dropzone.is-drag { border-color: var(--orange); background: var(--orange-soft); }
.dropzone.has-files { border-style: solid; border-color: var(--orange); }
.upload__fields .field:last-of-type { margin-bottom: 14px; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.photo { position: relative; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.photo__img { display: block; aspect-ratio: 4 / 3; background: var(--bg); }
.photo__img img { width: 100%; height: 100%; object-fit: cover; }
.photo__form { padding: 12px; display: grid; gap: 8px; }
.photo__form input, .photo__form select { padding: 7px 10px; font-size: .85rem; }
.photo__row { display: grid; grid-template-columns: 1fr 70px; gap: 8px; }
.photo__actions { display: flex; justify-content: flex-end; }
.photo__delete { position: absolute; top: 8px; right: 8px; }
.photo__delete .icon-btn { background: rgba(255, 255, 255, .92); }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty i { font-size: 2.4rem; color: #c9ccd2; margin-bottom: 10px; }
.empty p { margin: 0 0 14px; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 0%, #2a2219 0%, var(--ink) 55%); }
.auth__panel { width: 100%; max-width: 420px; }
.auth__brand { display: flex; align-items: center; justify-content: center; gap: 12px; color: #fff; margin-bottom: 24px; }
.auth__brand:hover { color: #fff; }
.auth__card { padding: 32px; margin-bottom: 18px; border: 0; }
.auth__card h1 { font-family: var(--font-head); font-size: 2rem; text-transform: uppercase; }
.auth__card > p { margin: 4px 0 22px; }
.auth__back { display: block; text-align: center; color: #9aa1ab; }
.auth__back:hover { color: #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .dash-grid, .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .25s; box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
    .sidebar.is-open { transform: none; }
    .sidebar.is-open + .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 25; }
    .topbar__menu { display: grid; place-items: center; }
    .topbar { padding: 14px 18px; }
    .admin__content { padding: 20px 16px 40px; }
    .upload__grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .stats { grid-template-columns: 1fr; }
    .hide-sm { display: none; }
    .topbar__title h1 { font-size: 1.35rem; }
    .topbar__title p { display: none; }
    .topbar__user { border-left: 0; padding-left: 0; }
    .form-row { grid-template-columns: 1fr; }
    .card { padding: 18px; }
    .table-wrap { margin: 0 -18px; }
    .table th, .table td { padding-left: 18px; padding-right: 18px; }
}
