/* =====================================================================
   Barber SaaS — painel administrativo
   Base: couro escuro na lateral, fundo azulejo, superfícies brancas.
   A cor de destaque (--accent) vem das Configurações da barbearia.
   ===================================================================== */

:root {
    /* Menu lateral: --side-bg vem de Configurações › Cor do menu do painel.
       --side-ink (texto) é calculado no servidor para ficar legível. */
    --side-bg: #1f2328;
    --side-ink: #ffffff;
    --side-text: color-mix(in srgb, var(--side-ink) 84%, var(--side-bg));
    --side-muted: color-mix(in srgb, var(--side-ink) 56%, var(--side-bg));
    --side-hover: color-mix(in srgb, var(--side-ink) 9%, var(--side-bg));
    --side-line: color-mix(in srgb, var(--side-ink) 12%, var(--side-bg));
    --tile: #eef1ef;
    --surface: #ffffff;
    --line: #d9dedb;
    --line-soft: #e8ebe9;
    --ink: #1f2421;
    --muted: #5f6b66;
    --pole-red: #b8322a;
    --pole-blue: #2c5a8c;
    --brass: #a8834a;
    --ok: #2f7d4f;
    --accent: #2c5a8c;           /* sobrescrito pelo layout com a cor da barbearia */
    --accent-ink: #ffffff;
    --radius: 10px;
    --radius-sm: 7px;
    --sidebar-w: 248px;

    --bs-body-font-family: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
    --bs-body-color: var(--ink);
    --bs-body-bg: var(--tile);
    --bs-border-color: var(--line);
    --bs-border-radius: var(--radius-sm);
    --bs-link-color: var(--accent);
    --bs-link-hover-color: var(--ink);
    --bs-secondary-color: var(--muted);
}

body { background: var(--tile); font-size: .94rem; -webkit-font-smoothing: antialiased; }

h1, h2, h3, h4, h5, h6, .display-title {
    font-family: "Archivo", sans-serif;
    font-stretch: 78%;
    font-weight: 700;
    letter-spacing: .005em;
    color: var(--ink);
}

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

/* --- Faixa de poste de barbeiro (elemento de assinatura) --- */
.pole-stripe {
    height: 6px;
    background: repeating-linear-gradient(
        -45deg,
        var(--pole-red) 0 10px,
        #f4f4f2 10px 20px,
        var(--pole-blue) 20px 30px,
        #f4f4f2 30px 40px
    );
}

/* --- Lateral --- */
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
    background: var(--side-bg); color: var(--side-text);
    display: flex; flex-direction: column; z-index: 1040;
    transition: transform .22s ease;
}
.sidebar .brand {
    display: flex; align-items: center; gap: .7rem;
    padding: 1.1rem 1.15rem 1rem;
    border-bottom: 1px solid var(--side-line);
    color: var(--side-ink); text-decoration: none;
}
.sidebar .brand img, .sidebar .brand .brand-mark {
    width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
    background: var(--side-hover); color: var(--side-ink); flex: 0 0 40px;
    display: grid; place-items: center;
}
.sidebar .brand strong { font-stretch: 78%; font-size: 1.12rem; line-height: 1.1; }
.sidebar .brand small { display: block; color: var(--side-muted); font-size: .76rem; font-weight: 400; }

.sidebar nav { flex: 1; overflow-y: auto; padding: .6rem 0 1rem; }
.nav-group { padding: .9rem 1.15rem .3rem; color: var(--side-muted); font-size: .78rem; }
.sidebar .nav-link {
    display: flex; align-items: center; gap: .7rem;
    color: var(--side-text); padding: .5rem 1.15rem; margin: 1px .6rem;
    border-radius: var(--radius-sm); font-size: .92rem;
}
.sidebar .nav-link i { font-size: 1.05rem; opacity: .8; width: 1.1rem; text-align: center; }
.sidebar .nav-link:hover { background: var(--side-hover); color: var(--side-ink); }
.sidebar .nav-link.active { background: var(--side-ink); color: var(--side-bg); font-weight: 600; }
.sidebar .nav-link.active i { opacity: 1; }

.sidebar .sidebar-foot { padding: .9rem 1.15rem; border-top: 1px solid var(--side-line); }
.sidebar .sidebar-foot .who { font-size: .82rem; color: var(--side-muted); margin-bottom: .55rem; }
.sidebar .sidebar-foot .who strong { color: var(--side-ink); display: block; font-weight: 600; }
.btn-leave {
    width: 100%; background: transparent; color: var(--side-text);
    border: 1px solid var(--side-line); border-radius: var(--radius-sm);
    padding: .42rem .7rem; font-size: .86rem;
}
.btn-leave:hover { background: var(--side-hover); color: var(--side-ink); }

.sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(20, 15, 12, .45);
    z-index: 1035; display: none;
}

/* --- Área principal --- */
.main { margin-left: var(--sidebar-w); min-height: 100vh; }
.topbar {
    position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: center; gap: .75rem;
    padding: .8rem 1.75rem; background: rgba(238, 241, 239, .92);
    backdrop-filter: blur(6px); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.45rem; margin: 0; }
.topbar .actions { margin-left: auto; display: flex; gap: .5rem; }
.menu-toggle {
    display: none; border: 1px solid var(--line); background: var(--surface);
    border-radius: var(--radius-sm); width: 40px; height: 40px; font-size: 1.25rem;
}
.content { padding: 1.5rem 1.75rem 3rem; max-width: 1360px; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open .sidebar-backdrop { display: block; }
    .main { margin-left: 0; }
    .menu-toggle { display: inline-grid; place-items: center; }
    .topbar { padding: .7rem 1rem; }
    .topbar h1 { font-size: 1.25rem; }
    .topbar .actions .btn span { display: none; }
    .content { padding: 1rem 1rem 3rem; }
}

/* --- Superfícies --- */
.card, .panel {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: none;
}
.panel-head {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    padding: .9rem 1.1rem; border-bottom: 1px solid var(--line-soft);
}
.panel-head h2 { font-size: 1.08rem; margin: 0; }
.panel-body { padding: 1rem 1.1rem; }
.panel-empty { padding: 2rem 1.1rem; text-align: center; color: var(--muted); }
.panel-empty .btn { margin-top: .75rem; }

/* Faixa de números do dashboard (um bloco dividido, não 4 cartões soltos) */
.metrics {
    display: grid; grid-template-columns: repeat(4, 1fr);
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.metric { padding: 1.05rem 1.2rem; border-left: 1px solid var(--line-soft); }
.metric:first-child { border-left: 0; }
.metric .label { color: var(--muted); font-size: .84rem; }
.metric .value { font-stretch: 78%; font-weight: 700; font-size: 1.85rem; line-height: 1.15; margin-top: .15rem; }
.metric .hint { color: var(--muted); font-size: .8rem; }
.metric.lead .value { color: var(--accent); }
@media (max-width: 767.98px) {
    .metrics { grid-template-columns: repeat(2, 1fr); }
    .metric:nth-child(3) { border-left: 0; }
    .metric:nth-child(n+3) { border-top: 1px solid var(--line-soft); }
    .metric .value { font-size: 1.5rem; }
}

/* --- Tabelas --- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead th {
    color: var(--muted); font-weight: 500; font-size: .82rem;
    border-bottom: 1px solid var(--line); background: transparent !important;
    padding-top: .7rem; padding-bottom: .7rem; white-space: nowrap;
}
.table > tbody td { border-color: var(--line-soft); padding-top: .75rem; padding-bottom: .75rem; }
.table-hover > tbody > tr:hover > * { --bs-table-hover-bg: #f6f8f7; }
.card > .table-responsive, .card > .table, .panel > .table-responsive { border-radius: var(--radius); }
.card .table > :not(caption) > * > *:first-child, .panel .table > :not(caption) > * > *:first-child { padding-left: 1.1rem; }
.card .table > :not(caption) > * > *:last-child, .panel .table > :not(caption) > * > *:last-child { padding-right: 1.1rem; }

/* --- Botões --- */
.btn { border-radius: var(--radius-sm); font-weight: 500; }
.btn-dark, .btn-primary {
    --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--side-bg); --bs-btn-hover-border-color: var(--side-bg);
    --bs-btn-active-bg: var(--side-bg); --bs-btn-active-border-color: var(--side-bg);
    --bs-btn-color: var(--accent-ink); --bs-btn-hover-color: var(--side-ink); --bs-btn-active-color: var(--side-ink);
    --bs-btn-disabled-bg: var(--accent); --bs-btn-disabled-border-color: var(--accent);
}
.btn-outline-dark, .btn-outline-secondary {
    --bs-btn-color: var(--ink); --bs-btn-border-color: var(--line);
    --bs-btn-hover-bg: var(--surface); --bs-btn-hover-color: var(--ink);
    --bs-btn-hover-border-color: var(--ink); --bs-btn-bg: var(--surface);
    --bs-btn-active-bg: var(--tile); --bs-btn-active-color: var(--ink);
}
.btn-whatsapp {
    --bs-btn-color: #fff; --bs-btn-bg: #1f8f4e; --bs-btn-border-color: #1f8f4e;
    --bs-btn-hover-bg: #17713d; --bs-btn-hover-border-color: #17713d; --bs-btn-hover-color: #fff;
}
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-grid; place-items: center; }

/* --- Formulários --- */
.form-control, .form-select {
    border-color: var(--line); border-radius: var(--radius-sm); padding: .5rem .75rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.form-label { font-weight: 500; font-size: .86rem; margin-bottom: .3rem; }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }

/* --- Status --- */
.status {
    display: inline-flex; align-items: center; gap: .35rem;
    font-size: .8rem; font-weight: 500; padding: .2rem .55rem; border-radius: 999px;
    background: var(--tile); color: var(--muted); white-space: nowrap;
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-scheduled { color: var(--pole-blue); background: #e7eef6; }
.status-confirmed { color: #6a4fa3; background: #efeaf7; }
.status-completed { color: var(--ok); background: #e6f2eb; }
.status-cancelled { color: var(--muted); background: #eceeed; }
.status-no_show { color: var(--pole-red); background: #f7e8e6; }
.points { color: var(--brass); font-weight: 600; }

.badge { font-weight: 500; }
.alert { border-radius: var(--radius); border-width: 1px; }

/* --- Agenda do dia --- */
.day-strip { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .25rem; scrollbar-width: thin; }
.day-chip {
    flex: 0 0 auto; text-align: center; min-width: 58px;
    padding: .45rem .5rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--ink); text-decoration: none; line-height: 1.15;
}
.day-chip small { display: block; color: var(--muted); font-size: .74rem; }
.day-chip strong { font-stretch: 78%; font-size: 1.15rem; }
.day-chip:hover { border-color: var(--ink); color: var(--ink); }
.day-chip.active { background: var(--side-bg); border-color: var(--side-bg); color: var(--side-ink); }
.day-chip.active small { color: var(--side-muted); }

.appt-row { display: grid; grid-template-columns: 74px 1fr auto; gap: 1rem; align-items: center;
    padding: .85rem 1.1rem; border-top: 1px solid var(--line-soft); }
.appt-row:first-child { border-top: 0; }
.appt-time { font-stretch: 78%; font-weight: 700; font-size: 1.2rem; line-height: 1.1; }
.appt-time small { display: block; font-weight: 400; font-size: .78rem; color: var(--muted); font-stretch: 100%; }
.appt-who strong { display: block; }
.appt-who span { color: var(--muted); font-size: .86rem; }
.appt-actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.appt-row.is-muted .appt-time, .appt-row.is-muted .appt-who strong { color: var(--muted); }
@media (max-width: 575.98px) {
    .appt-row { grid-template-columns: 60px 1fr; }
    .appt-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

/* --- Busca de cliente (autocomplete) --- */
.client-search { position: relative; }
.client-results {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
    max-height: 260px; overflow-y: auto; display: none;
}
.client-results.open { display: block; }
.client-results button {
    display: block; width: 100%; text-align: left; border: 0; background: none;
    padding: .55rem .75rem; border-top: 1px solid var(--line-soft);
}
.client-results button:first-child { border-top: 0; }
.client-results button:hover, .client-results button.focused { background: var(--tile); }
.client-results button span { color: var(--muted); font-size: .84rem; margin-left: .35rem; }
.client-picked {
    display: flex; align-items: center; justify-content: space-between; gap: .5rem;
    padding: .5rem .75rem; border: 1px solid var(--accent); border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--accent) 7%, white);
}

/* --- PDV --- */
.pdv-item {
    width: 100%; text-align: left; background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    padding: .65rem .75rem; display: flex; justify-content: space-between; gap: .5rem; align-items: baseline;
}
.pdv-item:hover { border-color: var(--accent); }
.pdv-item:active { transform: scale(.985); }
.pdv-item small { color: var(--muted); display: block; }
.cart-line { display: flex; justify-content: space-between; gap: .5rem; padding: .55rem 0; border-top: 1px solid var(--line-soft); }
.cart-line:first-child { border-top: 0; }
.qty { display: inline-flex; align-items: center; gap: .4rem; margin-top: .25rem; }
.qty button { width: 26px; height: 26px; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; line-height: 1; }
.cart-total { font-stretch: 78%; font-weight: 700; font-size: 1.7rem; }

/* --- Mensagem de WhatsApp --- */
.wa-preview {
    background: #e7f4ea; border: 1px solid #cfe6d5; border-radius: var(--radius);
    padding: .9rem 1rem; white-space: pre-wrap; font-size: .93rem;
}
.appt-context {
    display: flex; gap: .75rem; align-items: center; padding: .7rem .9rem;
    border: 1px dashed var(--line); border-radius: var(--radius-sm); background: var(--tile);
    font-size: .88rem;
}
.var-chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.var-chips button {
    border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
    font-size: .78rem; padding: .15rem .55rem; color: var(--muted);
}
.var-chips button:hover { border-color: var(--accent); color: var(--accent); }

/* --- Paginação --- */
.pagination { --bs-pagination-color: var(--ink); --bs-pagination-active-bg: var(--side-bg); --bs-pagination-active-color: var(--side-ink);
    --bs-pagination-active-border-color: var(--side-bg); --bs-pagination-border-color: var(--line); }

/* --- Login --- */
.auth-page {
    min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
    background: var(--side-bg);
}
.auth-box { width: 100%; max-width: 380px; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.auth-box .auth-inner { padding: 1.8rem 1.75rem 1.6rem; }
.auth-box h1 { font-size: 1.7rem; margin: 0 0 .2rem; }
.auth-box p.lead-text { color: var(--muted); margin-bottom: 1.4rem; }

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

/* Preço riscado (promoção) */
.price-old { font-weight: 400; color: var(--muted); font-size: .85em; margin-right: .2rem; }

/* Amostras de cor do menu (Configurações) */
.swatches { display: flex; flex-wrap: wrap; gap: .5rem; }
.swatch {
    width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--line);
    cursor: pointer; padding: 0; position: relative;
}
.swatch[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 2px; }
.sidebar-preview {
    display: flex; flex-direction: column; gap: 4px; width: 150px; padding: 10px;
    border-radius: var(--radius-sm); border: 1px solid var(--line);
    background: var(--preview-bg, #1f2328); color: var(--preview-ink, #fff); font-size: .8rem;
}
.sidebar-preview span { padding: 4px 8px; border-radius: 5px; opacity: .8; }
.sidebar-preview span.on { background: var(--preview-ink, #fff); color: var(--preview-bg, #1f2328); opacity: 1; font-weight: 600; }
