/* ===== Reset & Base ===== */
/* Bootstrap já aplica box-sizing; mantemos apenas as variáveis e sobrescritas de marca */

:root {
    --blue-dark:   #003F7F;
    --blue-mid:    #0066CC;
    --blue-light:  #4DA6FF;
    --aqua:        #00B4D8;
    --aqua-light:  #90E0EF;
    --white:       #FFFFFF;
    --gray-50:     #F8FAFC;
    --gray-100:    #EEF2F7;
    --gray-300:    #CBD5E1;
    --gray-500:    #64748B;
    --gray-700:    #334155;
    --gray-900:    #0F172A;
    --success:     #10B981;
    --danger:      #EF4444;
    --warning:     #F59E0B;
    --shadow-sm:   0 1px 3px rgba(0,0,0,.1);
    --shadow-md:   0 4px 16px rgba(0,63,127,.15);
    --shadow-lg:   0 8px 32px rgba(0,63,127,.2);
    --radius:      12px;
    --radius-sm:   8px;
}

html { min-height: 100%; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--gray-50);
    color: var(--gray-700);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Empurra o rodapé para o final da página */
.site-footer { margin-top: auto; }

a { color: var(--blue-mid); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Header ===== */
.site-header {
    background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue-mid) 60%, var(--aqua) 100%);
    color: var(--white);
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px;
}

.logo {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: var(--white);
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.logo-icon { font-size: 2rem; }
.logo span { color: var(--aqua-light); }

.header-nav a {
    color: rgba(255,255,255,.85);
    font-size: .9rem;
    font-weight: 500;
    transition: color .2s;
}
.header-nav a:hover { color: var(--white); text-decoration: none; }

/* ===== Hero / Busca ===== */
.hero {
    background: linear-gradient(160deg, var(--blue-dark) 0%, var(--blue-mid) 50%, var(--aqua) 100%);
    color: var(--white);
    text-align: center;
    padding: 4rem 1.5rem 5rem;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0; right: 0;
    height: 60px;
    background: var(--gray-50);
    clip-path: ellipse(55% 100% at 50% 100%);
}

.hero h1 {
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    font-weight: 800;
    margin-bottom: .75rem;
}

.hero p,
.hero-subtitulo {
    font-size: 1.1rem;
    opacity: .9;
    max-width: 500px;
    margin: 0 auto 2.5rem;
}

.hero-titulo { margin-bottom: .75rem; }

/* Formatações do Quill no hero público */
.hero-titulo strong, .hero-titulo b { font-weight: 900; }
.hero-titulo em, .hero-titulo i     { font-style: italic; }
.hero-titulo u                       { text-decoration: underline; }
.hero-titulo s                       { text-decoration: line-through; }
.hero-subtitulo strong, .hero-subtitulo b { font-weight: 700; }
.hero-subtitulo em, .hero-subtitulo i     { font-style: italic; }
.hero-subtitulo p { margin: 0 auto 2.5rem; max-width: 500px; }
.hero-subtitulo p:last-child { margin-bottom: 0; }

/* ===== Search Box ===== */
.search-box {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 1.75rem;
    max-width: 520px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: .85rem;
}

.search-box .field {
    display: flex;
    flex-direction: column;
    gap: .45rem;
    width: 100%;
}

.search-box label {
    font-size: .78rem;
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.search-box input {
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-sm);
    padding: .85rem 5rem .85rem 1.1rem;
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--gray-900);
    width: 100%;
    transition: border-color .2s;
    outline: none;
}

.search-box input:focus { border-color: var(--blue-mid); }

.btn-search {
    width: 100%;
    justify-content: center;
    padding: .9rem 1.5rem;
    font-size: 1rem;
}

/* ===== Buttons (site público) ===== */
.btn-search {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: var(--aqua);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    padding: .9rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s;
    text-decoration: none;
    white-space: nowrap;
}
.btn-search:hover { background: var(--blue-mid); color: var(--white); text-decoration: none; }

/* Override Bootstrap btn-primary e outline com cores da marca */
.btn-primary {
    --bs-btn-bg: var(--blue-mid);
    --bs-btn-border-color: var(--blue-mid);
    --bs-btn-hover-bg: var(--blue-dark);
    --bs-btn-hover-border-color: var(--blue-dark);
    --bs-btn-active-bg: var(--blue-dark);
    --bs-btn-active-border-color: var(--blue-dark);
    --bs-btn-disabled-bg: var(--blue-mid);
    --bs-btn-disabled-border-color: var(--blue-mid);
    --bs-btn-focus-shadow-rgb: var(--blue-mid-rgb, 0,102,204);
}
.btn-outline-primary {
    --bs-btn-color: var(--blue-mid);
    --bs-btn-border-color: var(--blue-mid);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--blue-mid);
    --bs-btn-hover-border-color: var(--blue-mid);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--blue-mid);
    --bs-btn-focus-shadow-rgb: var(--blue-mid-rgb, 0,102,204);
}

/* ===== Results ===== */
.results-section {
    max-width: 800px;
    margin: 3rem auto;
    padding: 0 1.5rem;
}

.result-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    margin-bottom: 1rem;
    border-left: 5px solid var(--aqua);
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
    animation: fadeUp .35s ease both;
    flex-wrap: wrap;
}

.result-card.first { border-left-color: var(--blue-mid); }

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.result-card:nth-child(2) { animation-delay: .08s; }
.result-card:nth-child(3) { animation-delay: .16s; }

.result-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue-mid), var(--aqua));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
    color: var(--white);
}

.result-info h3 {
    font-size: 1.1rem;
    color: var(--gray-900);
    margin-bottom: .25rem;
}

.result-info .address {
    font-size: .9rem;
    color: var(--gray-500);
    margin-bottom: .4rem;
    line-height: 1.5;
}

.result-info .phone {
    font-size: .95rem;
    font-weight: 600;
    color: var(--blue-dark);
    margin-bottom: .75rem;
}

.result-info {
    flex: 1;
    min-width: 0;
}

/* ===== Botões de ação do card ===== */
.result-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}

.btn-wa,
.btn-maps {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1rem;
    border-radius: 20px;
    font-size: .82rem;
    font-weight: 700;
    text-decoration: none;
    transition: all .2s;
    white-space: nowrap;
}

.btn-wa {
    background: #25D366;
    color: var(--white);
}
.btn-wa:hover {
    background: #1ebe57;
    color: var(--white);
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37,211,102,.35);
}

.btn-maps {
    background: var(--white);
    color: var(--blue-mid);
    border: 2px solid var(--blue-mid);
}
.btn-maps:hover {
    background: var(--blue-mid);
    color: var(--white);
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,102,204,.25);
}

.badge-distance {
    margin-left: auto;
    background: var(--blue-dark);
    color: var(--white);
    border-radius: 20px;
    padding: .3rem .85rem;
    font-size: .82rem;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
    align-self: flex-start;
}

.badge-nearest {
    display: inline-block;
    background: var(--aqua);
    color: var(--white);
    font-size: .7rem;
    font-weight: 700;
    padding: .15rem .6rem;
    border-radius: 20px;
    margin-left: .5rem;
    vertical-align: middle;
    text-transform: uppercase;
}

/* ===== Loading / Empty ===== */
.state-msg {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-500);
}

.state-msg .icon { font-size: 3rem; margin-bottom: .75rem; }
.state-msg p { font-size: 1rem; }

.spinner {
    width: 40px; height: 40px;
    border: 4px solid var(--gray-300);
    border-top-color: var(--blue-mid);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    margin: 0 auto .75rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Main Content ===== */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ===== Cards de info ===== */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin: 3rem auto;
    max-width: 900px;
    padding: 0 1.5rem;
}

.info-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    border-top: 4px solid var(--aqua);
}

.info-card .icon { font-size: 2rem; margin-bottom: .5rem; }
.info-card h3 { font-size: 1rem; color: var(--gray-900); margin-bottom: .3rem; }
.info-card p  { font-size: .85rem; color: var(--gray-500); line-height: 1.5; }

/* ===== Footer ===== */
.site-footer {
    background: var(--blue-dark);
    color: rgba(255,255,255,.7);
    text-align: center;
    padding: 1.5rem;
    font-size: .85rem;
    margin-top: auto;
}

.site-footer strong { color: var(--white); }

/* ===== ADMIN ===== */
.admin-body { background: #F1F5F9; }

.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────── */
.sidebar {
    width: 228px;
    background: var(--blue-dark, #0D1B2E);
    color: var(--white);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 200;
    transition: transform .28s cubic-bezier(.4,0,.2,1);
}

/* Brand / Logo */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 1.35rem 1.5rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.07);
}

.sidebar-brand-icon { font-size: 1.6rem; }

.sidebar-brand-name {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--white);
    letter-spacing: -.3px;
}

/* Section label */
.sidebar-section-label {
    display: block;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: rgba(255,255,255,.3);
    padding: 1.1rem 1.5rem .4rem;
}

/* Nav links */
.sidebar-nav {
    flex: 1;
    padding: .5rem 0;
    overflow-y: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem 1rem .65rem 1.25rem;
    margin: .15rem .75rem;
    border-radius: 10px;
    color: rgba(255,255,255,.6);
    font-size: .9rem;
    font-weight: 500;
    text-decoration: none;
    transition: background .18s, color .18s;
    position: relative;
}

.sidebar-link:hover {
    background: rgba(255,255,255,.07);
    color: rgba(255,255,255,.95);
    text-decoration: none;
}

.sidebar-link.active {
    background: rgba(var(--aqua-rgb, 0,180,216), .18);
    color: #e2f5ff;
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: -4px;
    top: 20%; bottom: 20%;
    width: 4px;
    border-radius: 0 4px 4px 0;
    background: var(--aqua);
}

.sidebar-link.active .sidebar-link-icon {
    color: var(--aqua);
}

.sidebar-link-icon {
    font-size: 1.05rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
    line-height: 1;
}

.sidebar-link-text { line-height: 1; }

/* Versão */
.sidebar-version {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,.07);
    font-size: .7rem;
    color: rgba(255,255,255,.2);
    text-align: center;
    letter-spacing: .04em;
}

/* ── Área de conteúdo (topbar + main) ────────────── */
.admin-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-left: 228px;
    min-height: 100vh;
}

/* ── Topbar ──────────────────────────────────────── */
.admin-topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 58px;
    background: #fff;
    border-bottom: 1px solid #E2E8F0;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    gap: 1rem;
}

.admin-topbar-left {
    display: flex;
    align-items: center;
    gap: .85rem;
}

.admin-topbar-right {
    display: flex;
    align-items: center;
    gap: .85rem;
    flex-shrink: 0;
}

.topbar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid var(--gray-100);
    object-fit: cover;
}

.topbar-user {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.topbar-user-name {
    font-size: .85rem;
    font-weight: 700;
    color: var(--gray-900);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-user-role {
    font-size: .72rem;
    color: var(--gray-500);
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem 1rem;
    border-radius: 8px;
    font-size: .82rem;
    font-weight: 700;
    color: #DC2626;
    border: 1.5px solid #FCA5A5;
    background: #FFF5F5;
    text-decoration: none;
    transition: all .18s;
    white-space: nowrap;
}
.btn-logout:hover {
    background: #DC2626;
    color: #fff;
    border-color: #DC2626;
    text-decoration: none;
}

/* Hamburguer — escondido em desktop, visível em tablet/mobile */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--gray-700);
    cursor: pointer;
    padding: .3rem;
    border-radius: 6px;
    transition: background .15s;
}
.sidebar-toggle:hover { background: var(--gray-100); }

/* ── Main content ────────────────────────────────── */
.admin-main {
    flex: 1;
    padding: 1.75rem 2rem 3rem;
    overflow-x: hidden;
}

.page-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
    display: flex;
    align-items: center;
    gap: .4rem;
}

/* ===== Table card wrapper ===== */
.table-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-header {
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--gray-100);
}

/* Bootstrap table customizações de marca */
.table thead th {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--gray-500);
}

.actions { display: flex; gap: .4rem; }

/* ===== Form card ===== */
.form-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 2rem;
    max-width: 680px;
}

/* Bootstrap form-control/form-select — sobrescreve cor de foco com nossa marca */
.form-control:focus,
.form-select:focus {
    border-color: var(--blue-mid);
    box-shadow: 0 0 0 .2rem rgba(0,102,204,.2);
}

/* ===== Alert — cores de marca sobre Bootstrap ===== */
.alert-success { background: #D1FAE5; color: #065F46; border-left: 4px solid var(--success); }
.alert-danger  { background: #FEE2E2; color: #991B1B; border-left: 4px solid var(--danger); }
.alert-warning { background: #FEF3C7; color: #92400E; border-left: 4px solid var(--warning); }
.alert-info    { background: #DBEAFE; color: #1E40AF; border-left: 4px solid var(--blue-mid); }

/* ===== Login ===== */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--blue-dark), var(--aqua));
}

.login-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
}

.login-card .logo {
    justify-content: center;
    margin-bottom: 1.75rem;
    font-size: 1.6rem;
    color: var(--blue-dark);
}

.login-card .logo span { color: var(--aqua); }


/* ===== Modal "não encontrado" ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    padding: 1rem;
    animation: fadeIn .2s ease;
}

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

.modal-box {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2rem 2.25rem;
    max-width: 460px;
    width: 100%;
    text-align: center;
    animation: slideUp .25s ease;
}

@keyframes slideUp { from { transform: translateY(20px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }

.modal-icon { font-size: 3rem; margin-bottom: .75rem; }

.modal-box h3 {
    font-size: 1.15rem;
    color: var(--gray-900);
    margin-bottom: .5rem;
    font-weight: 700;
}

.modal-box p {
    font-size: .92rem;
    color: var(--gray-500);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: .75rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ===== Sidebar Overlay ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 149;
}

/* ===== Responsive — Tablet (≤1024px) ===== */
@media (max-width: 1024px) {
    .sidebar-toggle  { display: flex; }
    .sidebar-overlay { display: block; opacity: 0; pointer-events: none; transition: opacity .25s; }

    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { opacity: 1; pointer-events: auto; }

    .admin-content { margin-left: 0; }
    .admin-main { padding: 1.25rem 1.25rem 2rem; }
    .cfg-save-bar { left: 0; padding: .75rem 1rem; }
    .cfg-save-bar-hint { display: none; }
}

/* ===== Responsive — Mobile (≤640px) ===== */
@media (max-width: 640px) {
    /* Header público */
    .header-inner { height: 58px; }
    .logo { font-size: 1.3rem; }
    .logo-icon { font-size: 1.6rem; }
    .header-nav a { font-size: .8rem; }

    /* Hero */
    .hero { padding: 2.5rem 1rem 3.5rem; }
    .hero-titulo, .hero h1 { font-size: clamp(1.4rem, 6vw, 2rem); }
    .hero p, .hero-subtitulo { font-size: 1rem; margin-bottom: 1.75rem; }

    /* Search box */
    .search-box { padding: 1.25rem; gap: .65rem; }
    .search-box input { padding: .7rem 4rem .7rem .85rem; }

    /* Resultados */
    .results-section { margin: 1.75rem auto; padding: 0 1rem; }
    .result-card     { flex-direction: column; gap: .75rem; padding: 1.1rem; }
    .result-icon     { width: 42px; height: 42px; font-size: 1.1rem; }
    .result-info h3  { font-size: 1rem; }
    .badge-distance  { margin-left: 0; align-self: flex-start; }
    .btn-wa, .btn-maps { flex: 1; justify-content: center; }

    /* Info grid */
    .info-grid { grid-template-columns: 1fr; padding: 0 1rem; margin: 2rem auto; }

    /* Footer */
    .site-footer { padding: 1.25rem 1rem; }

    /* Login */
    .login-card { padding: 1.75rem 1.25rem; margin: 1rem; }

    /* Modal público */
    .modal-box { padding: 1.5rem 1.25rem; }
    .modal-actions { flex-direction: column; }
    .modal-actions .btn { width: 100%; justify-content: center; }

    /* Admin layout */
    .admin-main { padding: 1rem .875rem 2rem; }
    .admin-topbar { padding: 0 .875rem; gap: .5rem; }
    .topbar-user { display: none; }
    .topbar-avatar { width: 30px; height: 30px; }
    .btn-logout span { display: none; } /* esconde texto "Sair" em mobile */
    .form-card { padding: 1.25rem; }
    .page-title { font-size: 1rem; }

    /* Table */
    .table-header { flex-direction: column; align-items: flex-start; gap: .65rem; }
    .table-header > div, .table-header > .d-flex { width: 100%; }

    /* Stat cards admin — 2 por linha em mobile */
    .stat-box-num { font-size: 1.5rem; }

    /* Configurações */
    .cfg-grid-2, .cfg-grid-3 { grid-template-columns: 1fr !important; }
    .cfg-save-bar { padding: .65rem .875rem; }
}

/* ===== Responsive — Extra small (≤420px) ===== */
@media (max-width: 420px) {
    .logo { font-size: 1.1rem; }
    .hero { padding: 2rem .75rem 3rem; }
    .search-box { padding: 1rem; }
    .result-card { padding: .9rem; }
    .login-card { padding: 1.5rem 1rem; }
    .admin-topbar { height: 52px; }
}
