/*
 * DraJoyce — Shared Stylesheet
 * Versão consolidada: utilitários + componentes reutilizáveis
 * Complementa o CSS inline do index.html e evita repetição nos templates
 */

/* ─────────────────────────────────────────────────────────────
   LAYOUT UTILITÁRIOS
───────────────────────────────────────────────────────────── */

.d-flex          { display: flex; }
.d-grid          { display: grid; }
.d-block         { display: block; }
.d-none          { display: none; }

.flex-col        { flex-direction: column; }
.flex-1          { flex: 1; min-width: 0; }
.flex-shrink-0   { flex-shrink: 0; }
.flex-wrap       { flex-wrap: wrap; }

.items-center    { align-items: center; }
.items-start     { align-items: flex-start; }
.items-end       { align-items: flex-end; }
.justify-center  { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }

.gap-xs  { gap: 0.25rem; }
.gap-sm  { gap: 0.4rem; }
.gap-md  { gap: 0.75rem; }
.gap-lg  { gap: 1rem; }
.gap-xl  { gap: 1.5rem; }

.w-full  { width: 100%; }
.h-full  { height: 100%; }

.overflow-hidden  { overflow: hidden; }
.overflow-y-auto  { overflow-y: auto; }
.text-center      { text-align: center; }
.text-right       { text-align: right; }

.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sticky-top {
    position: sticky;
    top: 1rem;
}

/* ─────────────────────────────────────────────────────────────
   SPACING UTILITÁRIOS
───────────────────────────────────────────────────────────── */

.mt-0  { margin-top: 0; }
.mt-sm { margin-top: 0.5rem; }
.mt-md { margin-top: 1rem; }
.mt-lg { margin-top: 1.5rem; }

.mb-0  { margin-bottom: 0; }
.mb-xs { margin-bottom: 0.25rem; }
.mb-sm { margin-bottom: 0.5rem; }
.mb-md { margin-bottom: 1rem; }
.mb-lg { margin-bottom: 1.25rem; }
.mb-xl { margin-bottom: 1.75rem; }

.p-sm  { padding: 0.75rem; }
.p-md  { padding: 1rem; }
.p-lg  { padding: 1.5rem; }

/* ─────────────────────────────────────────────────────────────
   TIPOGRAFIA
───────────────────────────────────────────────────────────── */

/* Label de seção — uppercase pequeno (8x repetido) */
.label-section {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-soft);
}

.label-section-mb {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-soft);
    margin-bottom: 0.5rem;
    display: block;
}

/* Tamanhos de texto */
.text-2xs  { font-size: 0.62rem; }
.text-xs   { font-size: 0.72rem; }
.text-sm   { font-size: 0.78rem; }
.text-base { font-size: 0.85rem; }
.text-md   { font-size: 0.9rem; }
.text-lg   { font-size: 1rem; }
.text-xl   { font-size: 1.1rem; }

.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }

.text-soft    { color: var(--text-soft); }
.text-rose    { color: var(--rose); }
.text-success { color: #059669; }
.text-warning { color: #D97706; }
.text-danger  { color: #DC2626; }
.text-info    { color: #3B82F6; }
.text-gold    { color: #F59E0B; }
.text-white   { color: white; }

.italic { font-style: italic; }

.section-heading {
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    color: var(--text);
}

/* ─────────────────────────────────────────────────────────────
   CARTÕES E SUPERFÍCIES
───────────────────────────────────────────────────────────── */

/* Card padrão com padding — 10x repetido */
.surface-card {
    background: var(--surface);
    border-radius: 16px;
    border: 1px solid var(--border);
    padding: 1.5rem;
}

/* Card padrão sem padding (para tabelas dentro) — 6x repetido */
.surface-card-flush {
    background: var(--surface);
    border-radius: 16px;
    border: 1px solid var(--border);
    overflow: hidden;
}

/* Card compacto */
.surface-card-sm {
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 1rem;
    margin-bottom: 0.75rem;
}

/* Item de lista dentro de card */
.list-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.list-item:last-child { border-bottom: none; }

/* ─────────────────────────────────────────────────────────────
   CABEÇALHOS DE SEÇÃO DENTRO DOS CARDS
───────────────────────────────────────────────────────────── */

/* Cabeçalho com título + ação — 7x repetido */
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.card-header-sm {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.card-header-gap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

/* ─────────────────────────────────────────────────────────────
   EMPTY STATE
───────────────────────────────────────────────────────────── */

.empty-state-lg {
    text-align: center;
    padding: 3rem;
    color: var(--text-soft);
}

.empty-icon {
    font-size: 2.5rem !important;
    display: block;
    margin-bottom: 0.75rem;
    opacity: 0.25;
}

.empty-icon-sm {
    font-size: 2rem !important;
    display: block;
    margin-bottom: 0.5rem;
    opacity: 0.3;
}

/* ─────────────────────────────────────────────────────────────
   BADGES E STATUS
───────────────────────────────────────────────────────────── */

.badge-success { background: #ECFDF5; color: #065F46; }
.badge-warning { background: #FFF7ED; color: #D97706; }
.badge-danger  { background: #FEF2F2; color: #DC2626; }
.badge-info    { background: #EFF6FF; color: #3B82F6; }
.badge-gold    { background: #FEF9EE; color: #92400E; }
.badge-neutral { background: var(--surface2); color: var(--text-soft); }

/* ─────────────────────────────────────────────────────────────
   AVATARES (tamanhos padronizados)
───────────────────────────────────────────────────────────── */

.avatar-xs,
.avatar-sm,
.avatar-md {
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--rose);
    color: white;
    font-weight: 600;
    flex-shrink: 0;
}

.avatar-xs { width: 26px; height: 26px; font-size: 0.65rem; }
.avatar-sm { width: 34px; height: 34px; font-size: 0.75rem; }
.avatar-md { width: 42px; height: 42px; font-size: 0.85rem; }

/* ─────────────────────────────────────────────────────────────
   SPINNERS DE LOADING
───────────────────────────────────────────────────────────── */

.spinner-centered {
    display: block;
    margin: 0 auto;
    border-color: rgba(44,36,32,0.15);
    border-top-color: var(--rose);
}

.loading-block {
    text-align: center;
    padding: 3rem;
}

/* ─────────────────────────────────────────────────────────────
   ÍCONE DE PROTOCOLO
───────────────────────────────────────────────────────────── */

.protocol-icon {
    width: 42px;
    height: 42px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.protocol-icon-sm {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────────────
   FORMULÁRIOS
───────────────────────────────────────────────────────────── */

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-row   { display: grid; gap: 0.75rem; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ─────────────────────────────────────────────────────────────
   BARRA DE PROGRESSO (adesão)
───────────────────────────────────────────────────────────── */

.progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}

/* ─────────────────────────────────────────────────────────────
   GRIDS DE STATS (KPIs)
───────────────────────────────────────────────────────────── */

.stats-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.stats-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.stats-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* ─────────────────────────────────────────────────────────────
   LINHAS DE CONSULTAS (appointments)
───────────────────────────────────────────────────────────── */

.appt-row {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.12s;
}

.appt-row:hover { background: var(--surface2); }

.appt-time { flex-shrink: 0; text-align: center; width: 42px; }
.appt-time-main { font-size: 0.92rem; font-weight: 700; color: var(--text); }
.appt-time-sub  { font-size: 0.62rem; color: var(--text-soft); }

/* ─────────────────────────────────────────────────────────────
   BADGE DE PROTOCOLO (tag colorida)
───────────────────────────────────────────────────────────── */

.protocol-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.72rem;
    padding: 1px 7px;
    border-radius: 999px;
    font-weight: 500;
}

.protocol-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

/* ─────────────────────────────────────────────────────────────
   TIMELINE (histórico)
───────────────────────────────────────────────────────────── */

.timeline {
    position: relative;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 18px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background: var(--border);
    border-radius: 1px;
}

.timeline-item {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    position: relative;
}

.timeline-dot {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    z-index: 1;
    border: 2px solid var(--surface);
}

.timeline-card {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.875rem 1rem;
    min-width: 0;
}

/* ─────────────────────────────────────────────────────────────
   MODAIS
───────────────────────────────────────────────────────────── */

.modal-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.modal-actions .btn-outline { flex: 1; justify-content: center; }
.modal-actions .btn-primary { flex: 2; justify-content: center; }

.modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-body-sm { padding: 1.25rem; }

/* ─────────────────────────────────────────────────────────────
   DIVIDER
───────────────────────────────────────────────────────────── */

.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1rem 0;
}

/* ─────────────────────────────────────────────────────────────
   RESPONSIVO
───────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .stats-grid-4  { grid-template-columns: repeat(2, 1fr); }
    .stats-grid-3  { grid-template-columns: repeat(2, 1fr); }
    .stats-grid-2  { grid-template-columns: 1fr; }
    .form-row-2    { grid-template-columns: 1fr; }
    .form-row-3    { grid-template-columns: 1fr; }
    .surface-card  { padding: 1rem; }
}

/* ─────────────────────────────────────────────────────────────
   SEGUNDA RODADA — padrões identificados nos templates
───────────────────────────────────────────────────────────── */

/* Flex row com gap (9x, 7x, 6x) */
.row-center-xs  { display: flex; align-items: center; gap: 0.25rem; }
.row-center-sm  { display: flex; align-items: center; gap: 0.4rem; }
.row-center     { display: flex; align-items: center; gap: 0.5rem; }
.row-center-md  { display: flex; align-items: center; gap: 0.6rem; }
.row-center-lg  { display: flex; align-items: center; gap: 0.75rem; }
.row-center-xl  { display: flex; align-items: center; gap: 1rem; }

/* Justify-between com gap (9x) */
.row-between-sm { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.row-between    { display: flex; align-items: center; justify-content: space-between; }

/* Flex col com gap */
.col-gap-sm { display: flex; flex-direction: column; gap: 0.4rem; }
.col-gap-md { display: flex; flex-direction: column; gap: 0.75rem; }
.col-gap-lg { display: flex; flex-direction: column; gap: 1rem; }

/* Flex col com gap + padding (5x) */
.col-pad { display: flex; flex-direction: column; gap: 1rem; padding: 1.5rem; }

/* Subtexto padrão (8x: color:text-soft + font-size:0.75rem + margin-top:2px) */
.meta-text {
    font-size: 0.75rem;
    color: var(--text-soft);
    margin-top: 2px;
}

.meta-text-xs {
    font-size: 0.68rem;
    color: var(--text-soft);
    margin-bottom: 1px;
}

.meta-text-italic {
    font-size: 0.75rem;
    color: var(--text-soft);
    font-style: italic;
    margin-top: 3px;
}

/* Empty state paddings (6x) */
.empty-lg { text-align: center; padding: 3rem; color: var(--text-soft); }
.empty-md { text-align: center; padding: 2rem; color: var(--text-soft); }

/* Truncate com peso (4x) */
.truncate-semibold {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.truncate-medium {
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Grid 2 colunas (4x) */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-2-sm { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

/* Stat number (KPI valor grande) */
.stat-value {
    font-family: 'Playfair Display', serif;
    font-size: 2.4rem;
    font-weight: 400;
    color: var(--text);
    line-height: 1;
}

/* Dot colorido de protocolo (3x: border-radius:50% + w8 + h8) */
.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

.dot-sm {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

/* Spinner padrão dentro de cards (5x) */
.spinner-card {
    display: block;
    margin: 0 auto;
    width: 24px;
    height: 24px;
    border-color: rgba(44,36,32,0.2);
    border-top-color: var(--rose);
}

/* Imagem de cobertura (4x: width:100% height:100% object-fit:cover) */
.img-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Card de item de lista com borda e gap (3x) */
.item-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
}

/* Row de contato com ícone (3x: flex + text-soft + font-size:0.75rem) */
.contact-row {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.75rem;
    color: var(--text-soft);
}

/* Appt time column (3x: flex-shrink:0 + text-center + width:36px) */
.appt-time-col {
    flex-shrink: 0;
    text-align: center;
    width: 36px;
}

/* Appt time column larger */
.appt-time-col-lg {
    flex-shrink: 0;
    text-align: center;
    width: 44px;
}

/* Cursor pointer + flex + font (6x) */
.clickable-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
}

/* ─────────────────────────────────────────────────────────────
   TERCEIRA RODADA — últimos padrões
───────────────────────────────────────────────────────────── */

/* flex:1 + min-width:0 (22x — o mais repetido restante) */
.flex-min { flex: 1; min-width: 0; }

/* Texto soft com tamanhos (15x, 11x, 10x, 8x, 7x, 6x) */
.text-soft-xs  { font-size: 0.62rem; color: var(--text-soft); }
.text-soft-sm  { font-size: 0.68rem; color: var(--text-soft); }
.text-soft-md  { font-size: 0.72rem; color: var(--text-soft); }
.text-soft-base{ font-size: 0.75rem; color: var(--text-soft); }
.text-soft-lg  { font-size: 0.78rem; color: var(--text-soft); }
.text-soft-xl  { font-size: 0.8rem;  color: var(--text-soft); }
.text-soft-2xl { font-size: 0.82rem; color: var(--text-soft); }

/* Texto com peso (12x, 6x) */
.text-medium    { font-size: 0.85rem; font-weight: 500; }
.text-medium-md { font-size: 0.82rem; font-weight: 500; }
.text-medium-lg { font-size: 0.9rem;  font-weight: 500; }
.text-semibold  { font-size: 0.9rem;  font-weight: 600; }
.text-semibold-sm { font-size: 0.82rem; font-weight: 600; }

/* Heading de modal/card — Playfair 1.2rem (6x) */
.heading-card {
    font-family: 'Playfair Display', serif;
    font-size: 1.2rem;
    font-weight: 500;
}

/* Row com margin-bottom:1.25rem (6x) */
.card-header-gap-lg {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

/* Avatar xs dimensões (4x: w26 h26 font-size:0.65rem) */
.avatar-26 {
    width: 26px;
    height: 26px;
    font-size: 0.65rem;
    flex-shrink: 0;
}

/* Padding centered (4x: padding:2rem + text-align:center) */
.center-pad { text-align: center; padding: 2rem; }

/* Margin-bottom comuns (repetidos como single-prop) */
.mb-875 { margin-bottom: 0.875rem; }
.mb-125 { margin-bottom: 1.25rem; }

/* font-size inline mais repetidos como classes utilitárias simples */
.fs-09  { font-size: 0.9rem; }
.fs-088 { font-size: 0.88rem; }
.fs-085 { font-size: 0.85rem; }
.fs-082 { font-size: 0.82rem; }
.fs-080 { font-size: 0.8rem; }
.fs-078 { font-size: 0.78rem; }
.fs-075 { font-size: 0.75rem; }
.fs-072 { font-size: 0.72rem; }
.fs-070 { font-size: 0.7rem; }
.fs-068 { font-size: 0.68rem; }
.fs-065 { font-size: 0.65rem; }
.fs-062 { font-size: 0.62rem; }
.fs-1   { font-size: 1rem; }

/* grid-column full width (8x) */
.col-full { grid-column: 1 / -1; }

/* accent-color para inputs (6x) */
.accent-rose { accent-color: var(--rose); }

/* label-section sem margin (para casos sem mb) */
.label-section-inline {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-soft);
    display: inline-block;
}
/* ─────────────────────────────────────────────────────────────
   RESPONSIVIDADE — ADMIN PANEL
   breakpoints: tablet ≤1024px | mobile ≤768px | small ≤480px
───────────────────────────────────────────────────────────── */

/* Tabela com scroll horizontal */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Cards stat em 2 colunas no tablet */
@media (max-width: 1024px) {
    .stats-grid-4 { grid-template-columns: repeat(2, 1fr); }
    .stats-grid-3 { grid-template-columns: repeat(2, 1fr); }
    .stats-grid-5 { grid-template-columns: repeat(3, 1fr); }
}

/* ── Mobile geral ── */
@media (max-width: 768px) {

    /* Stats */
    .stats-grid-4  { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
    .stats-grid-3  { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
    .stats-grid-2  { grid-template-columns: 1fr; gap: 0.75rem; }
    .stat-card     { padding: 1rem; }
    .stat-value    { font-size: 2rem; }

    /* Grids de conteúdo viram coluna única */
    .grid-2        { grid-template-columns: 1fr; }
    .grid-2-sm     { grid-template-columns: 1fr; }
    .form-row-2    { grid-template-columns: 1fr; }
    .form-row-3    { grid-template-columns: 1fr; }

    /* Cards com menos padding */
    .surface-card    { padding: 1rem; }
    .surface-card-sm { padding: 0.875rem; }

    /* Modal ocupa tela inteira */
    .modal-box     {
        max-width: 100% !important;
        max-height: 95vh;
        border-radius: 18px 18px 0 0;
        margin-top: auto;
    }
    .modal-overlay {
        align-items: flex-end;
    }

    /* Tabelas com scroll */
    .data-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .data-table      { min-width: 500px; }

    /* Topbar search menor */
    .search-input  { width: 120px !important; }

    /* card-header empilha em telas muito pequenas */
    .card-header-stack {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}

/* ── Small mobile ── */
@media (max-width: 480px) {
    .stats-grid-4  { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .stats-grid-3  { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .stat-card     { padding: 0.75rem; }
    .stat-value    { font-size: 1.8rem; }

    /* Ações inline viram coluna */
    .mobile-col    { flex-direction: column; align-items: flex-start !important; }
    .mobile-hide   { display: none !important; }
    .mobile-full   { width: 100%; justify-content: center; }

    /* Modais ocupam tela toda */
    .modal-box     { border-radius: 14px 14px 0 0; }
    .modal-box-lg  { max-width: 100% !important; }
    .modal-box-xl  { max-width: 100% !important; }
}

/* Dashboard 3-col body → 1 col on mobile */
.dashboard-body-grid {
    display: grid;
    grid-template-columns: 1fr 1.4fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    .dashboard-body-grid { grid-template-columns: 1fr 1fr; }
    .dashboard-body-grid > div:first-child { grid-column: 1 / -1; }
}

@media (max-width: 768px) {
    .dashboard-body-grid { grid-template-columns: 1fr; }
    .stats-grid-5 { grid-template-columns: repeat(2, 1fr) !important; }
}

/* Appointments sidebar → stacks on mobile */
.appointments-grid {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 900px) {
    .appointments-grid {
        grid-template-columns: 1fr;
    }
    .appointments-grid > div:first-child {
        position: static !important;
    }
}

/* Reports filters → stacks on mobile */
.reports-filter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr auto;
    gap: 1rem;
    align-items: flex-end;
}

@media (max-width: 900px) {
    .reports-filter-grid {
        grid-template-columns: 1fr 1fr;
    }
    .reports-filter-grid > div:last-child { grid-column: 1 / -1; }
    .reports-filter-grid > button { width: 100%; justify-content: center; }
}

@media (max-width: 600px) {
    .reports-filter-grid { grid-template-columns: 1fr; }
}

/* Reports feedback grid (1fr 2fr) → stack */
.reports-feedback-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
}

@media (max-width: 768px) {
    .reports-feedback-grid { grid-template-columns: 1fr; }
}

/* Stats 5-col → 3 → 2 */
.stats-grid-5 {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 1024px) {
    .stats-grid-5 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 600px) {
    .stats-grid-5 { grid-template-columns: repeat(2, 1fr); }
}

/* Expiry cards → smaller on mobile */
@media (max-width: 600px) {
    .item-card { flex-wrap: wrap; }
    .item-card > div:last-child { width: 100%; justify-content: flex-end; }
}

/* ═══════════════════════════════════════════════════════════
   MOBILE OVERHAUL — sheet bottom + cards
   ═══════════════════════════════════════════════════════════ */

/* ── Sheet bottom modal ─────────────────────────────────── */
@media (max-width: 768px) {
    .modal-overlay {
        align-items: flex-end !important;
        padding: 0 !important;
    }
    .modal-box,
    .modal-box-lg,
    .modal-box-xl {
        max-width: 100% !important;
        width: 100% !important;
        border-radius: 20px 20px 0 0 !important;
        max-height: 92vh !important;
        overflow-y: auto;
        animation: slideUp 0.28s ease !important;
    }
    @keyframes slideUp {
        from { transform: translateY(100%); opacity: 0.6; }
        to   { transform: translateY(0);    opacity: 1; }
    }
    /* Handle bar no topo do sheet */
    .modal-header::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: var(--border);
        border-radius: 2px;
        margin: -0.5rem auto 0.75rem;
    }
}

/* ── Mobile cards (substituem tabelas) ──────────────────── */
/* Classe no <table>: ng-hide em mobile, substituída por .mobile-cards */
.mobile-cards { display: none; }
.product-card-actions { display: none; }

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--border);
    color: var(--text-soft);
    font-size: 0.8rem;
}

.pagination-bar .btn-outline {
    padding: 0.35rem 0.65rem;
    min-height: 36px;
}

.pagination-bar-compact {
    padding: 0.6rem 0 0;
    border-top: none;
}

@media (max-width: 768px) {
    .mobile-hide-table { display: none !important; }
    .mobile-cards      { display: flex !important; flex-direction: column; gap: 0.625rem; }
    .mobile-card {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 0.875rem 1rem;
        display: flex;
        align-items: center;
        gap: 0.75rem;
        cursor: pointer;
        transition: background 0.12s;
    }
    .mobile-card:active { background: var(--surface2); }
    .mobile-card-body   { flex: 1; min-width: 0; }
    .mobile-card-title  { font-size: 0.88rem; font-weight: 600; color: var(--text); }
    .mobile-card-sub    { font-size: 0.75rem; color: var(--text-soft); margin-top: 2px; }
    .mobile-card-right  { text-align: right; flex-shrink: 0; }
    .mobile-card-badge  { font-size: 0.68rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
    .mobile-card-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 0.35rem 0.75rem;
        color: var(--text-soft);
        font-size: 0.72rem;
        padding-left: 0.1rem;
    }
    .mobile-card-meta span {
        display: inline-flex;
        align-items: center;
    }
    .mobile-card-meta span + span::before {
        content: '';
        width: 4px;
        height: 4px;
        margin-right: 0.45rem;
        border-radius: 999px;
        background: var(--border2);
    }
    .mobile-card-note {
        color: var(--text-soft);
        font-size: 0.74rem;
        font-style: italic;
        line-height: 1.35;
        padding: 0.55rem 0.65rem;
        border-radius: 8px;
        background: var(--surface2);
    }
}

@media (max-width: 768px) {
    .mobile-card-actions {
        display: flex;
        gap: 0.45rem;
        justify-content: flex-end;
        flex-wrap: wrap;
        padding-top: 0.6rem;
        border-top: 1px solid var(--border);
    }

    .mobile-card-actions .btn-outline,
    .mobile-card-actions .btn-danger,
    .mobile-card-actions .btn-primary,
    .mobile-card-actions a {
        min-height: 44px;
        justify-content: center;
        padding: 0.48rem 0.7rem !important;
        font-size: 0.76rem !important;
    }

    .admin-list-tools {
        width: 100%;
        flex-direction: column;
        align-items: stretch !important;
    }

    .admin-list-tools .form-input {
        width: 100% !important;
        min-height: 44px;
    }

    .btn-primary,
    .btn-outline,
    .btn-danger,
    .btn-gold {
        min-height: 44px;
    }

    .form-input,
    select.form-input,
    textarea.form-input {
        min-height: 44px;
    }

    .patient-detail-modal {
        height: 92vh !important;
        max-height: 92vh !important;
    }

    .patient-detail-header {
        padding: 1rem 1rem 0 !important;
        min-width: 0;
    }

    .patient-detail-top {
        gap: 0.75rem !important;
        margin-bottom: 0.875rem !important;
    }

    .patient-detail-identity {
        align-items: flex-start !important;
        gap: 0.75rem !important;
        min-width: 0;
    }

    .patient-detail-identity > div:first-child {
        width: 48px !important;
        height: 48px !important;
    }

    .patient-detail-name {
        min-width: 0;
    }

    .patient-detail-name .modal-title {
        font-size: 1.05rem !important;
        white-space: normal;
        overflow-wrap: anywhere;
        line-height: 1.15;
    }

    .patient-detail-actions {
        gap: 0.35rem !important;
        flex-shrink: 0;
    }

    .patient-detail-actions .btn-outline {
        width: 36px;
        padding: 0 !important;
    }

    .patient-detail-tabs {
        margin: 0 -1rem;
        padding: 0 1rem;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        scroll-padding-inline: 1rem;
    }

    .patient-detail-tabs::-webkit-scrollbar {
        display: none;
    }

    .patient-detail-tabs button {
        flex: 0 0 auto;
        padding: 0.72rem 0.85rem !important;
        font-size: 0.75rem !important;
    }

    .patient-detail-content {
        padding: 1rem !important;
    }

    .patient-timeline-line,
    .patient-timeline-dot {
        display: none !important;
    }

    .timeline-item {
        gap: 0 !important;
        margin-bottom: 0.75rem;
    }

    .patient-timeline-card {
        width: 100%;
    }

    .patient-timeline-card-head {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.35rem !important;
    }

    .patient-timeline-card-head > span:last-child {
        order: -1;
        font-size: 0.68rem !important;
    }
}

/* ── Dashboard fixes ────────────────────────────────────── */
@media (max-width: 768px) {
    /* KPIs linha 2 — 3 cols → 2 cols + 1 embaixo */
    .kpi-row-3 {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.75rem !important;
    }
    .kpi-row-3 > div:last-child {
        grid-column: 1 / -1;
    }
    /* Agenda + chart stack */
    .dashboard-body-grid {
        grid-template-columns: 1fr !important;
    }
    /* Calendar + vencimentos stack */
    .dash-cal-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ── Appointments page ──────────────────────────────────── */
@media (max-width: 768px) {
    .appointments-grid {
        grid-template-columns: 1fr !important;
    }
    /* Filtro sidebar vira accordion collapsed */
    .appt-sidebar-mobile {
        border-radius: 12px;
        border: 1px solid var(--border);
        overflow: hidden;
    }
}

/* ── Reports ────────────────────────────────────────────── */
@media (max-width: 768px) {
    .reports-filter-grid {
        grid-template-columns: 1fr 1fr !important;
    }
    .reports-filter-grid > div:nth-child(3),
    .reports-filter-grid > div:nth-child(4),
    .reports-filter-grid > button {
        grid-column: 1 / -1;
    }
    .reports-filter-grid > div:nth-child(3) { grid-column: 1; }
    .reports-filter-grid > div:nth-child(4) { grid-column: 2; }
    .reports-tabs { overflow-x: auto; width: 100%; }
    .reports-tabs > button { white-space: nowrap; font-size: 0.72rem; padding: 0.35rem 0.75rem; }
    .reports-feedback-grid { grid-template-columns: 1fr !important; }
    .stats-grid-5 { grid-template-columns: repeat(2, 1fr) !important; }
    .stats-grid-5 > div:first-child { grid-column: 1 / -1; }
    .report-kpi-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.75rem !important;
        margin-bottom: 1rem !important;
    }
    .report-kpi-grid > div:first-child {
        grid-column: 1 / -1;
    }
}

.report-kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.question-sort-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.question-sortable-item {
    position: relative;
    border: 1px solid #EDE5D8;
    border-radius: 10px;
    padding: 0.8rem;
    background: white;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s, background 0.15s, opacity 0.15s;
}

.question-sortable-item:hover {
    border-color: var(--border2);
    box-shadow: 0 4px 16px rgba(44, 36, 32, 0.06);
}

.question-drag-handle {
    width: 24px;
    height: 28px;
    margin-top: -2px;
    border: 0;
    background: transparent;
    color: var(--soft);
    cursor: grab;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    touch-action: none;
    flex-shrink: 0;
}

.question-drag-handle:hover,
.question-drag-handle:focus-visible {
    color: var(--rose);
    background: var(--rose-soft);
    outline: none;
}

.question-drag-handle:disabled {
    opacity: 0.35;
    cursor: default;
}

.question-sort-active {
    user-select: none;
}

.question-sort-active .question-drag-handle {
    cursor: grabbing;
}

.question-sort-active .question-sortable-item {
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.question-sortable-item.question-is-dragging {
    opacity: 0.68;
    transform: scale(0.985);
    border-color: var(--rose);
    background: #FFF8F6;
    box-shadow: 0 10px 26px rgba(201, 137, 122, 0.16);
}

.question-sortable-item.question-drop-target:not(.question-is-dragging) {
    border-color: rgba(201, 137, 122, 0.5);
    background: #FFFCFA;
    box-shadow: inset 0 0 0 1px rgba(201, 137, 122, 0.18);
}

.question-sortable-item.question-drop-before::before,
.question-sortable-item.question-drop-after::after {
    content: "";
    position: absolute;
    left: 42px;
    right: 14px;
    height: 3px;
    border-radius: 999px;
    background: var(--rose);
    box-shadow: 0 0 0 3px rgba(201, 137, 122, 0.13);
    pointer-events: none;
    z-index: 2;
}

.question-sortable-item.question-drop-before::before {
    top: -7px;
}

.question-sortable-item.question-drop-after::after {
    bottom: -7px;
}

/* ── Products modal (questionário + pacientes) ──────────── */
@media (max-width: 768px) {
    .product-modal-grid {
        grid-template-columns: 1fr !important;
        max-height: none !important;
    }
    .product-modal-col {
        max-height: 300px;
        overflow-y: auto;
    }
}

/* ── Expiry cards ───────────────────────────────────────── */
@media (max-width: 600px) {
    .expiry-card-row {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    .expiry-card-row > div:first-child { width: 100%; }
    .expiry-card-row > div:last-child  { width: 100%; justify-content: space-between; }
}

/* ── Topbar melhorias ───────────────────────────────────── */
@media (max-width: 480px) {
    .topbar-date { display: none !important; }
    .topbar-search { flex: 1; max-width: 180px; }
}

/* Topbar date hidden on mobile */
@media (max-width: 768px) {
    .mobile-hide-tablet { display: none !important; }
    .topbar-search-mobile input { width: 150px !important; }
}
@media (max-width: 480px) {
    .topbar-search-mobile input { width: 120px !important; }
}

/* Page header button full width on mobile */
@media (max-width: 600px) {
    .page-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }
    .page-header .btn-primary,
    .page-header .btn-outline {
        width: 100% !important;
        justify-content: center !important;
    }
}

/* Product modal grid → stack on mobile */
@media (max-width: 768px) {
    .product-modal-grid {
        grid-template-columns: 1fr !important;
        height: auto !important;
        overflow: visible !important;
    }
    .product-modal-col {
        max-height: 280px;
        overflow-y: auto;
        border-right: none !important;
        border-bottom: 1px solid var(--border);
    }
    .product-modal-col:last-child { border-bottom: none; }
    .products-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }
    .product-card-actions {
        display: flex;
        margin-top: 0.8rem;
    }
}

/* Reports tabs full width scrollable */
@media (max-width: 768px) {
    .reports-tabs {
        width: 100% !important;
    }
}

/* Guided tours */
.tour-help-btn {
    padding: 0.42rem 0.75rem;
    flex-shrink: 0;
}

.tour-layer {
    position: fixed;
    inset: 0;
    z-index: 260;
    pointer-events: none;
}

.tour-dim {
    position: absolute;
    inset: 0;
    background: transparent;
    pointer-events: auto;
}

.tour-spotlight {
    position: fixed;
    border-radius: 14px;
    box-shadow: 0 0 0 9999px rgba(44, 36, 32, 0.58), 0 12px 44px rgba(0,0,0,0.22);
    border: 2px solid rgba(255,255,255,0.86);
    pointer-events: none;
    transition: all 0.16s ease;
    z-index: 261;
}

.tour-highlight {
    position: relative;
    z-index: 262 !important;
}

.tour-popover {
    position: fixed;
    z-index: 263;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem;
    box-shadow: 0 18px 60px rgba(0,0,0,0.22);
    pointer-events: auto;
}

.tour-kicker {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--rose);
    margin-bottom: 0.35rem;
}

.tour-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.2rem;
    color: var(--text);
    margin-bottom: 0.45rem;
}

.tour-text {
    font-size: 0.84rem;
    line-height: 1.5;
    color: var(--text-soft);
}

.tour-progress {
    display: flex;
    gap: 0.3rem;
    margin-top: 0.9rem;
}

.tour-progress span {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--border2);
}

.tour-progress span.active {
    width: 20px;
    background: var(--rose);
}

.tour-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 1rem;
}

.tour-actions .btn-outline,
.tour-actions .btn-primary {
    padding: 0.45rem 0.75rem;
}

@media (max-width: 600px) {
    .tour-dim {
        background: rgba(44, 36, 32, 0.56);
    }
    .tour-spotlight {
        display: none;
    }
    .tour-highlight {
        z-index: auto !important;
    }
    .tour-popover {
        left: 12px !important;
        right: 12px !important;
        width: auto !important;
        top: auto !important;
        bottom: 12px !important;
        max-height: calc(100vh - 24px);
        overflow-y: auto;
        border-radius: 14px;
    }
    .tour-actions {
        align-items: stretch;
    }
    .tour-actions .btn-outline,
    .tour-actions .btn-primary {
        min-height: 44px;
    }
}
