/* =====================================================================
   LOOKLY — Shell do painel
   Sidebar (menu hambúrguer), topbar, banner do PWA e onboarding
   ===================================================================== */

/* ---------------------------------------------------------------
   1. Estrutura
   --------------------------------------------------------------- */
.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-main {
    flex: 1;
    padding: 1.25rem 1rem 3rem;
    transition: margin-left var(--t);
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}
.page-title { font-size: 1.5rem; font-weight: 700; margin: 0; letter-spacing: -.02em; }
.page-subtitle { font-size: .9rem; color: var(--text-muted); margin: .25rem 0 0; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.breadcrumb {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .8rem;
    color: var(--text-subtle);
    margin-bottom: .5rem;
    flex-wrap: wrap;
}
.breadcrumb a { color: var(--text-subtle); }
.breadcrumb a:hover { color: var(--primary); }

/* ---------------------------------------------------------------
   2. Topbar
   --------------------------------------------------------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 900;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: .625rem;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--gray-900);
    text-decoration: none;
    letter-spacing: -.02em;
}
.topbar-brand:hover { color: var(--gray-900); }

.brand-mark {
    width: 34px; height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary) 0%, #A77BFA 100%);
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 800;
    font-size: .95rem;
    box-shadow: var(--shadow-primary);
    flex-shrink: 0;
}

.topbar-spacer { flex: 1; }

.topbar-actions { display: flex; align-items: center; gap: .375rem; }

/* Botão hambúrguer (3 barras) */
.hamburger {
    width: 40px; height: 40px;
    display: grid;
    place-items: center;
    background: none;
    border: 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--gray-700);
    transition: background var(--t-fast);
    flex-shrink: 0;
}
.hamburger:hover { background: var(--gray-100); }

.hamburger-bars {
    width: 20px; height: 14px;
    position: relative;
    display: block;
}
.hamburger-bars span {
    position: absolute;
    left: 0;
    width: 100%; height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform var(--t), opacity var(--t-fast), width var(--t);
}
.hamburger-bars span:nth-child(1) { top: 0; }
.hamburger-bars span:nth-child(2) { top: 6px; width: 70%; }
.hamburger-bars span:nth-child(3) { top: 12px; }

.sidebar-open .hamburger-bars span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.sidebar-open .hamburger-bars span:nth-child(2) { opacity: 0; }
.sidebar-open .hamburger-bars span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Perfil na topbar */
.topbar-user {
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: .3rem .5rem .3rem .3rem;
    border: 0;
    border-radius: var(--radius-full);
    background: none;
    cursor: pointer;
    transition: background var(--t-fast);
}
.topbar-user:hover { background: var(--gray-100); }
.topbar-user-name { font-size: .85rem; font-weight: 600; line-height: 1.2; }
.topbar-user-role { font-size: .72rem; color: var(--text-subtle); line-height: 1.2; }

/* ---------------------------------------------------------------
   3. Sidebar
   --------------------------------------------------------------- */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform var(--t);
    overflow: hidden;
}
.sidebar-open .sidebar { transform: none; }

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    height: var(--topbar-h);
    padding: 0 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: .875rem .625rem 1.5rem;
    -webkit-overflow-scrolling: touch;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 3px; }

.nav-section {
    padding: .875rem .75rem .375rem;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--gray-400);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .625rem .75rem;
    margin-bottom: 2px;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-weight: 550;
    color: var(--gray-700);
    text-decoration: none;
    transition: background var(--t-fast), color var(--t-fast);
    cursor: pointer;
    border: 0;
    background: none;
    width: 100%;
    text-align: left;
}
.nav-item:hover { background: var(--gray-50); color: var(--gray-900); }

.nav-item.is-active {
    background: var(--primary-50);
    color: var(--primary-700);
    font-weight: 650;
}
.nav-item.is-active .nav-icon { color: var(--primary); }

.nav-icon {
    width: 20px; height: 20px;
    flex-shrink: 0;
    color: var(--gray-500);
    transition: color var(--t-fast);
}
.nav-item:hover .nav-icon { color: var(--gray-700); }

.nav-badge {
    margin-left: auto;
    padding: .1rem .45rem;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    line-height: 1.5;
}
.nav-badge.is-muted { background: var(--gray-200); color: var(--gray-600); }

/* Item com submenu */
.nav-group > .nav-item .nav-chevron {
    margin-left: auto;
    width: 15px; height: 15px;
    color: var(--gray-400);
    transition: transform var(--t);
}
.nav-group.is-open > .nav-item .nav-chevron { transform: rotate(180deg); }

.nav-submenu {
    display: none;
    padding: .125rem 0 .25rem 2.4rem;
}
.nav-group.is-open .nav-submenu { display: block; }

.nav-sublink {
    display: block;
    padding: .45rem .6rem;
    border-radius: 6px;
    font-size: .85rem;
    color: var(--gray-600);
    text-decoration: none;
    transition: background var(--t-fast), color var(--t-fast);
}
.nav-sublink:hover { background: var(--gray-50); color: var(--gray-900); }
.nav-sublink.is-active { color: var(--primary); font-weight: 650; }

/* Rodapé da sidebar: botão de instalação do app */
.sidebar-footer {
    padding: .875rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--surface-alt);
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(31, 36, 48, .45);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--t), visibility var(--t);
}
.sidebar-open .sidebar-backdrop { opacity: 1; visibility: visible; }

/* Desktop: sidebar fixa e recolhível */
@media (min-width: 1024px) {
    .sidebar { transform: none; }
    .sidebar-backdrop { display: none; }
    .app-main { margin-left: var(--sidebar-w); }
    .topbar { padding-left: calc(var(--sidebar-w) + 1rem); }

    /* Estado recolhido, alternado pelo hambúrguer no desktop */
    .sidebar-collapsed .sidebar { transform: translateX(-100%); }
    .sidebar-collapsed .app-main { margin-left: 0; }
    .sidebar-collapsed .topbar { padding-left: 1rem; }
    .sidebar-collapsed .topbar-brand-desktop { display: flex; }

    .topbar-brand-desktop { display: none; }
}

@media (max-width: 1023px) {
    body.sidebar-open { overflow: hidden; }
}

/* ---------------------------------------------------------------
   4. PWA — botão e banner de instalação
   --------------------------------------------------------------- */
.pwa-install-card {
    background: linear-gradient(135deg, var(--primary) 0%, #A77BFA 100%);
    border-radius: var(--radius);
    padding: 1rem;
    color: #fff;
    box-shadow: var(--shadow-primary);
}
.pwa-install-card h4 { font-size: .9rem; margin: 0 0 .2rem; color: #fff; }
.pwa-install-card p { font-size: .78rem; opacity: .9; margin: 0 0 .75rem; line-height: 1.4; }
.pwa-install-card .btn {
    background: #fff;
    color: var(--primary-700);
    width: 100%;
    box-shadow: none;
}
.pwa-install-card .btn:hover { background: #F4EEFF; color: var(--primary-700); }

/* Banner discreto na barra de navegação */
.pwa-banner {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .55rem 1rem;
    background: var(--primary-50);
    border-bottom: 1px solid var(--primary-100);
    font-size: .82rem;
    color: var(--primary-700);
}
.pwa-banner .btn { margin-left: auto; }
.pwa-banner-close {
    background: none; border: 0; cursor: pointer;
    color: var(--primary-300); padding: .2rem; line-height: 1;
}
.pwa-banner-close:hover { color: var(--primary-700); }

/* Instruções para iOS (o Safari não dispara beforeinstallprompt) */
.ios-install-steps { counter-reset: step; }
.ios-install-steps li {
    counter-increment: step;
    display: flex;
    gap: .75rem;
    align-items: flex-start;
    padding: .625rem 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: .875rem;
}
.ios-install-steps li:last-child { border-bottom: 0; }
.ios-install-steps li::before {
    content: counter(step);
    flex-shrink: 0;
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--primary-100);
    color: var(--primary-700);
    display: grid;
    place-items: center;
    font-size: .75rem;
    font-weight: 700;
}

/* ---------------------------------------------------------------
   5. Faixa de impersonate (SuperAdmin em modo suporte)
   --------------------------------------------------------------- */
.impersonate-bar {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .5rem 1rem;
    background: var(--warning);
    color: #422006;
    font-size: .82rem;
    font-weight: 600;
    flex-wrap: wrap;
}
.impersonate-bar .btn {
    margin-left: auto;
    background: rgba(0, 0, 0, .15);
    color: #422006;
    box-shadow: none;
}
.impersonate-bar .btn:hover { background: rgba(0, 0, 0, .25); color: #422006; }

/* Aviso do teste grátis: pílula na topbar (desktop) + card no menu lateral */
.trial-pill {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .35rem .75rem;
    background: var(--primary-100);
    color: var(--primary-700);
    border-radius: var(--radius-full);
    font-size: .78rem;
    font-weight: 700;
    white-space: nowrap;
    text-decoration: none;
    transition: background var(--t-fast), transform var(--t-fast);
}
.trial-pill:hover { background: var(--primary-200, #E2D6FD); color: var(--primary-700); transform: translateY(-1px); }
.trial-pill svg { flex-shrink: 0; }

.trial-card {
    display: block;
    background: var(--primary-50);
    border: 1px solid var(--primary-100);
    border-radius: var(--radius);
    padding: .75rem .875rem;
    margin-bottom: .75rem;
    text-decoration: none;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.trial-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.trial-card strong {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .82rem;
    color: var(--primary-700);
}
.trial-card span {
    display: block;
    font-size: .74rem;
    color: var(--text-muted);
    margin-top: .2rem;
}

/* ---------------------------------------------------------------
   6. Onboarding (wizard)
   --------------------------------------------------------------- */
.wizard {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.wizard-header {
    padding: 1.25rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.wizard-steps {
    display: flex;
    align-items: center;
    gap: .25rem;
    max-width: 720px;
    margin: 1rem auto 0;
}

.wizard-step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .375rem;
    position: relative;
}

.wizard-step-dot {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--gray-200);
    color: var(--gray-500);
    display: grid;
    place-items: center;
    font-size: .8rem;
    font-weight: 700;
    z-index: 1;
    transition: background var(--t), color var(--t);
}
.wizard-step.is-active .wizard-step-dot { background: var(--primary); color: #fff; box-shadow: 0 0 0 4px var(--primary-100); }
.wizard-step.is-done .wizard-step-dot { background: var(--success); color: #fff; }

.wizard-step-label {
    font-size: .7rem;
    font-weight: 600;
    color: var(--text-subtle);
    text-align: center;
    line-height: 1.3;
}
.wizard-step.is-active .wizard-step-label { color: var(--primary-700); }

/* Linha ligando os passos */
.wizard-step::after {
    content: '';
    position: absolute;
    top: 15px; left: 50%;
    width: 100%; height: 2px;
    background: var(--gray-200);
    z-index: 0;
}
.wizard-step:last-child::after { display: none; }
.wizard-step.is-done::after { background: var(--success); }

.wizard-body {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem 1rem 3rem;
}
.wizard-card { width: 100%; max-width: 620px; }

.wizard-footer {
    display: flex;
    justify-content: space-between;
    gap: .75rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

@media (max-width: 640px) {
    .wizard-step-label { display: none; }
    .wizard-steps { max-width: 320px; }
}

/* ---------------------------------------------------------------
   7. Blocos específicos do painel
   --------------------------------------------------------------- */

/* Lista de agendamentos do dia no dashboard */
.appointment-row {
    display: flex;
    align-items: center;
    gap: .875rem;
    padding: .875rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    transition: background var(--t-fast);
    text-decoration: none;
    color: inherit;
}
.appointment-row:last-child { border-bottom: 0; }
.appointment-row:hover { background: var(--primary-50); color: inherit; }

.appointment-time {
    flex-shrink: 0;
    width: 56px;
    text-align: center;
    font-size: .95rem;
    font-weight: 700;
    color: var(--gray-800);
    line-height: 1.2;
}
.appointment-time small { display: block; font-size: .68rem; font-weight: 600; color: var(--text-subtle); }

.appointment-bar {
    width: 3px;
    align-self: stretch;
    min-height: 36px;
    border-radius: 2px;
    background: var(--primary);
    flex-shrink: 0;
}

.appointment-info { flex: 1; min-width: 0; }
.appointment-client { font-size: .92rem; font-weight: 650; }
.appointment-service { font-size: .8rem; color: var(--text-muted); }

/* Card de serviço/produto na listagem */
.item-card {
    display: flex;
    gap: .875rem;
    padding: .875rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: box-shadow var(--t), border-color var(--t);
}
.item-card:hover { box-shadow: var(--shadow-sm); border-color: var(--gray-300); }

.item-thumb {
    width: 64px; height: 64px;
    border-radius: var(--radius-sm);
    background: var(--gray-100) center/cover no-repeat;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    color: var(--gray-400);
    overflow: hidden;
}
.item-thumb img { width: 100%; height: 100%; object-fit: cover; }

.item-body { flex: 1; min-width: 0; }
.item-name { font-size: .92rem; font-weight: 650; margin-bottom: .15rem; }
.item-meta { font-size: .8rem; color: var(--text-muted); display: flex; gap: .75rem; flex-wrap: wrap; }
.item-price { font-size: .95rem; font-weight: 700; color: var(--primary); }
.item-price-old { font-size: .8rem; color: var(--text-subtle); text-decoration: line-through; margin-right: .35rem; }

/* Barra de progresso (uso do plano, metas) */
.progress {
    height: 6px;
    background: var(--gray-100);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: var(--radius-full);
    transition: width var(--t);
}
.progress-bar.is-warning { background: var(--warning); }
.progress-bar.is-danger  { background: var(--danger); }

/* Gráfico de barras simples (financeiro/relatórios) */
.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 160px;
    padding-top: 1rem;
}
.chart-bar-col {
    flex: 1;
    /* Precisa de altura definida: sem ela, o "height:X%" das barras não
       resolve e o gráfico fica achatado (todas as barras no mínimo). */
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: .35rem;
    min-width: 0;
}
.chart-bar {
    width: 100%;
    max-width: 34px;
    background: var(--primary-300);
    border-radius: 4px 4px 0 0;
    min-height: 3px;
    transition: background var(--t);
    position: relative;
}
.chart-bar:hover { background: var(--primary); }
.chart-bar-label {
    font-size: .65rem;
    color: var(--text-subtle);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Cards de plano */
.plan-card {
    position: relative;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem 1.5rem;
    display: flex;
    flex-direction: column;
    transition: border-color var(--t), box-shadow var(--t), transform var(--t);
}
.plan-card:hover { box-shadow: var(--shadow); transform: translateY(-3px); }
.plan-card.is-featured {
    border-color: var(--primary);
    box-shadow: var(--shadow-primary);
}
.plan-card.is-current { border-color: var(--success); }

.plan-ribbon {
    position: absolute;
    top: -13px; left: 50%;
    transform: translateX(-50%);
    padding: .25rem .875rem;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    white-space: nowrap;
}
.plan-ribbon.is-current { background: var(--success); }

.plan-name { font-size: 1.15rem; font-weight: 700; margin-bottom: .2rem; }
.plan-tagline { font-size: .82rem; color: var(--text-muted); margin-bottom: 1.25rem; min-height: 2.4em; }

.plan-price { display: flex; align-items: baseline; gap: .25rem; margin-bottom: .25rem; }
.plan-price-currency { font-size: 1rem; font-weight: 600; color: var(--text-muted); }
.plan-price-value { font-size: 2.35rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.plan-price-period { font-size: .85rem; color: var(--text-muted); }
.plan-price-note { font-size: .78rem; color: var(--success); font-weight: 600; margin-bottom: 1.25rem; min-height: 1.2em; }

.plan-features { list-style: none; padding: 0; margin: 0 0 1.5rem; flex: 1; }
.plan-features li {
    display: flex;
    align-items: flex-start;
    gap: .55rem;
    padding: .4rem 0;
    font-size: .85rem;
    color: var(--gray-700);
}
.plan-features svg { flex-shrink: 0; width: 17px; height: 17px; color: var(--success); margin-top: 2px; }

/* Alternador mensal/anual */
.cycle-switch {
    display: inline-flex;
    padding: 4px;
    background: var(--gray-100);
    border-radius: var(--radius-full);
    gap: 2px;
}
.cycle-switch a {
    padding: .45rem 1.1rem;
    border-radius: var(--radius-full);
    font-size: .85rem;
    font-weight: 600;
    color: var(--gray-600);
    text-decoration: none;
    transition: background var(--t-fast), color var(--t-fast);
}
.cycle-switch a.is-active { background: var(--surface); color: var(--primary-700); box-shadow: var(--shadow-xs); }


/* ---------------------------------------------------------------
   Galeria da página pública (Configurações → Página)
   --------------------------------------------------------------- */
.gallery-manage {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: .625rem;
    margin-bottom: 1rem;
}
.gallery-manage-item {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    aspect-ratio: 1;
    border: 1px solid var(--border);
}
.gallery-manage-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.gallery-manage-remove {
    position: absolute;
    top: .35rem;
    right: .35rem;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background var(--t-fast);
}
.gallery-manage-remove:hover { background: var(--danger, #E5484D); }


/* ---------------------------------------------------------------
   Sininho de notificações (topbar do painel)
   --------------------------------------------------------------- */
.bell-btn { position: relative; }
.bell-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--accent, #EC6BAD);
    color: #fff;
    font-size: .64rem;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--surface, #fff);
}
.bell-menu {
    width: min(340px, 92vw);
    padding: 0;
    max-height: 420px;
}
.bell-menu.is-open { display: flex; flex-direction: column; }
.bell-menu .dropdown-header { flex-shrink: 0; }
.bell-list { overflow-y: auto; }
.bell-empty {
    padding: 1.25rem 1rem;
    font-size: .82rem;
    color: var(--gray-500);
    text-align: center;
    line-height: 1.5;
}
.bell-item {
    display: block;
    padding: .625rem .875rem;
    border-top: 1px solid var(--gray-100);
    text-decoration: none;
    color: inherit;
    transition: background var(--t-fast);
}
.bell-item:hover { background: var(--primary-50); }
.bell-item.is-unread { background: var(--primary-50); }
.bell-item.is-unread .bell-item-title::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary);
    margin-right: .4rem;
    vertical-align: 1px;
}
.bell-item-title { font-size: .82rem; font-weight: 700; color: var(--gray-800); }
.bell-item-body  { font-size: .78rem; color: var(--gray-600); line-height: 1.45; margin-top: .15rem; }
.bell-item-time  { font-size: .68rem; color: var(--gray-400); margin-top: .25rem; }

/* Variante "pagamento pendente" do aviso de teste */
.trial-pill.is-due { background: var(--danger-bg); color: var(--danger); }
.trial-pill.is-due:hover { background: var(--danger-bg); filter: brightness(.97); color: var(--danger); }
.trial-card.is-due { background: var(--danger-bg); border-color: rgba(229, 72, 77, .35); }
.trial-card.is-due strong { color: var(--danger); }
.trial-card.is-due:hover { border-color: var(--danger); }
