/* ============================================
   Medicale — Design System
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800;900&display=swap');

/* ── Variáveis ─────────────────────────────── */
:root {
    --primary:      #1C2E3D;
    --primary-light:#4A9CBF;
    --accent:       #C8455A;
    --accent-dark:  #A83348;

    --red:          #C8455A;
    --red-dark:     #A83348;
    --red-light:    #FAE8EB;

    --blue:         #4A9CBF;
    --blue-dark:    #357A99;
    --blue-light:   #E2F3FA;

    --navy:         #1C2E3D;
    --gold:         #E8A020;
    --danger:       #D93025;
    --warning:      #F59E0B;
    --info:         #4A9CBF;

    --bg:           #F5F7FA;
    --bg-card:      #FFFFFF;
    --border:       #E0E8EF;
    --text:         #1A2533;
    --text-muted:   #5A6E80;
    --text-light:   #9AAFC0;

    --sidebar-w:    250px;
    --radius:       10px;
    --radius-lg:    16px;
    --shadow:       0 2px 14px rgba(74,156,191,0.09);
    --shadow-lg:    0 8px 36px rgba(74,156,191,0.16);

    --font-head: 'Poppins', sans-serif;
    --font-body: 'Poppins', sans-serif;
}

/* ── Reset ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}
a { color: var(--primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* ── Layout: Auth (login/cadastro) ─────────── */
.auth-wrapper {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
}
.auth-brand {
    background: linear-gradient(150deg, var(--navy) 0%, var(--blue-dark) 55%, var(--red-dark) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: #fff;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.auth-brand::before {
    content: '';
    position: absolute;
    inset: -50%;
    background: radial-gradient(circle at 60% 40%, rgba(200,69,90,0.28) 0%, transparent 60%);
    pointer-events: none;
}
.auth-brand .logo-big {
    margin-bottom: 1rem;
    position: relative;
}
.auth-brand .logo-big img {
    width: 110px;
    height: auto;
    display: block;
    margin: 0 auto;
    filter: drop-shadow(0 4px 16px rgba(0,0,0,0.25));
}
.auth-brand .logo-big span { color: var(--accent); }
.auth-brand .tagline {
    font-size: 1.05rem;
    opacity: 0.85;
    max-width: 280px;
    position: relative;
}
.auth-brand .feature-list {
    list-style: none;
    margin-top: 2.5rem;
    text-align: left;
    position: relative;
}
.auth-brand .feature-list li {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0;
    font-size: 0.9rem;
    opacity: 0.9;
}
.auth-brand .feature-list li::before {
    content: '✓';
    width: 20px;
    height: 20px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    flex-shrink: 0;
}
.auth-form-area {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem;
    background: #fff;
    overflow-y: auto;
}
.auth-box {
    width: 100%;
    max-width: 440px;
}
.auth-box h2 {
    font-family: var(--font-head);
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.3rem;
}
.auth-box .sub { color: var(--text-muted); margin-bottom: 2rem; font-size: 0.9rem; }

/* ── Layout: Dashboard ──────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: var(--primary);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
}
.sidebar-logo {
    padding: 1.6rem 1.5rem 1.2rem;
    font-family: var(--font-head);
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.5px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo span { color: var(--accent); }
.sidebar-section {
    padding: 1rem 1rem 0.5rem;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.4);
}
.sidebar nav { flex: 1; padding: 0.5rem 0.75rem; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.8rem;
    border-radius: 8px;
    color: rgba(255,255,255,0.75);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 2px;
    transition: all 0.15s;
    text-decoration: none;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.1); color: #fff; }
.sidebar nav a.active { background: var(--accent); color: #fff; }
.sidebar nav a .icon { font-size: 1rem; width: 20px; text-align: center; }
.sidebar-plan {
    margin: 1rem;
    padding: 1rem;
    background: rgba(255,255,255,0.08);
    border-radius: var(--radius);
    border: 1px solid rgba(255,255,255,0.12);
}
.sidebar-plan .plan-name {
    font-family: var(--font-head);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent);
    margin-bottom: 0.3rem;
}
.sidebar-plan .plan-text { font-size: 0.78rem; color: rgba(255,255,255,0.6); }
.sidebar-plan .btn-upgrade {
    display: block;
    margin-top: 0.75rem;
    padding: 0.4rem;
    background: var(--accent);
    color: #fff;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    transition: background 0.15s;
}
.sidebar-plan .btn-upgrade:hover { background: var(--accent-dark); text-decoration: none; }

/* Main content */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.topbar {
    height: 60px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.8rem;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar h1 {
    font-family: var(--font-head);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary);
}
.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.topbar-user .avatar {
    width: 34px; height: 34px;
    background: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 0.85rem;
}
.page-body { padding: 1.8rem; }

/* ── Cards / Stats ──────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.2rem;
    margin-bottom: 1.8rem;
}
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.4rem 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
}
.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.stat-icon.green  { background: #D1FAE5; }
.stat-icon.blue   { background: #DBEAFE; }
.stat-icon.amber  { background: #FEF3C7; }
.stat-icon.red    { background: #FEE2E2; }
.stat-info .value {
    font-family: var(--font-head);
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}
.stat-info .label { font-size: 0.8rem; color: var(--text-muted); margin-top: 3px; }

/* ── Tabelas ────────────────────────────────── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}
.card-header {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.card-header h3 {
    font-family: var(--font-head);
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
}
.card-body { padding: 1.5rem; }
table { width: 100%; border-collapse: collapse; }
table th {
    padding: 0.7rem 1rem;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
table td {
    padding: 0.9rem 1rem;
    font-size: 0.88rem;
    border-bottom: 1px solid #F1F5F9;
    vertical-align: middle;
}
table tr:last-child td { border-bottom: none; }
table tr:hover td { background: #F8FAFC; }
.produto-nome { font-weight: 600; color: var(--primary); font-size: 0.9rem; }
.produto-sub  { font-size: 0.78rem; color: var(--text-muted); }

/* ── Formulários ────────────────────────────── */
.form-grid { display: grid; gap: 1rem; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group label {
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--primary);
}
.form-control {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--text);
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
    appearance: none;
}
.form-control:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(18,96,168,0.1);
}
.form-control::placeholder { color: var(--text-light); }
.form-hint { font-size: 0.77rem; color: var(--text-muted); }
.form-section-title {
    font-family: var(--font-head);
    font-weight: 700;
    color: var(--primary);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }

/* Autocomplete CMED */
.autocomplete-wrap { position: relative; }
.autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: #fff;
    border: 1.5px solid var(--primary-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    max-height: 280px;
    overflow-y: auto;
    display: none;
}
.autocomplete-dropdown.show { display: block; }
.ac-item {
    padding: 0.7rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #F1F5F9;
    transition: background 0.1s;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.selected { background: #EFF6FF; }
.ac-item .ac-nome { font-weight: 600; font-size: 0.88rem; color: var(--primary); }
.ac-item .ac-sub  { font-size: 0.77rem; color: var(--text-muted); }
.ac-item .ac-pmc  { font-size: 0.75rem; color: var(--accent-dark); font-weight: 600; margin-top: 1px; }

/* Desconto calculado */
.preco-row { display: flex; align-items: center; gap: 0.75rem; }

/* Visibilidade do preço (toggle de cards) */
.price-vis-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
.price-vis-opt {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.85rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
}
.price-vis-opt:hover { border-color: var(--primary-light); }
.price-vis-opt input[type="radio"] {
    margin-top: 2px;
    accent-color: var(--accent);
    flex-shrink: 0;
}
.price-vis-opt:has(input:checked) {
    border-color: var(--accent);
    background: #F0FDF4;
}
.pv-icon { font-size: 1.2rem; flex-shrink: 0; }
.pv-text { display: flex; flex-direction: column; gap: 1px; }
.pv-text strong { font-size: 0.88rem; color: var(--text); }
.pv-text small { font-size: 0.74rem; color: var(--text-muted); }

/* Preço bloqueado na vitrine pública */
.preco-bloqueado {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    border-radius: 8px;
    padding: 0.5rem 0.7rem;
    font-size: 0.78rem;
    color: #92400E;
    font-weight: 600;
    text-decoration: none;
    margin: 0.2rem 0;
}
.preco-bloqueado:hover { background: #FEF3C7; text-decoration: none; color: #78350F; }
.badge-privado {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #FEF3C7;
    color: #92400E;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 99px;
}
.pmc-ref { font-size: 0.82rem; color: var(--text-muted); }
.pmc-ref strong { color: var(--accent-dark); }
.desconto-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background: #D1FAE5;
    color: var(--accent-dark);
    border-radius: 99px;
    font-size: 0.8rem;
    font-weight: 700;
}

/* ── Botões ─────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
    text-decoration: none;
}
.btn:hover { text-decoration: none; filter: brightness(0.93); }
.btn-primary  { background: var(--primary);  color: #fff; }
.btn-accent   { background: var(--accent);   color: #fff; }
.btn-danger   { background: var(--danger);   color: #fff; }
.btn-outline  { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); filter: none; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.8rem 1.8rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ── Badges ─────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-ativo    { background: #D1FAE5; color: #065F46; }
.badge-pausado  { background: #FEF3C7; color: #92400E; }
.badge-expirado { background: #FEE2E2; color: #991B1B; }
.badge-urgente  { background: #FEE2E2; color: #991B1B; }
.badge-atencao  { background: #FEF3C7; color: #92400E; }
.badge-ok       { background: #D1FAE5; color: #065F46; }
.badge-free     { background: #F1F5F9; color: #475569; }
.badge-starter  { background: #DBEAFE; color: #1E40AF; }
.badge-pro      { background: #EDE9FE; color: #5B21B6; }

/* ── Alertas ────────────────────────────────── */
.alert {
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius);
    font-size: 0.88rem;
    margin-bottom: 1.2rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}
.alert-success { background: #D1FAE5; color: #065F46; border: 1px solid #6EE7B7; }
.alert-error   { background: #FEE2E2; color: #991B1B; border: 1px solid #FCA5A5; }
.alert-warning { background: #FEF3C7; color: #92400E; border: 1px solid #FCD34D; }
.alert-info    { background: #DBEAFE; color: #1E3A8A; border: 1px solid #93C5FD; }

/* ── Planos ─────────────────────────────────── */
.planos-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 1.2rem; margin: 1.5rem 0; }
.plano-card {
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}
.plano-card:hover { border-color: var(--primary-light); }
.plano-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(200,69,90,0.15); }
.plano-card.popular::before {
    content: 'Popular';
    position: absolute;
    top: -11px; left: 50%; transform: translateX(-50%);
    background: var(--accent);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 99px;
    letter-spacing: 0.5px;
}
.plano-nome { font-family: var(--font-head); font-size: 1rem; font-weight: 700; color: var(--primary); }
.plano-preco { font-family: var(--font-head); font-size: 1.8rem; font-weight: 800; color: var(--text); margin: 0.3rem 0; }
.plano-preco small { font-size: 0.8rem; font-weight: 400; color: var(--text-muted); }
.plano-features { list-style: none; font-size: 0.83rem; color: var(--text-muted); margin-top: 0.8rem; }
.plano-features li { padding: 0.25rem 0; }
.plano-features li::before { content: '✓ '; color: var(--accent); font-weight: 700; }

/* ── Utilitários ────────────────────────────── */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { font-family: var(--font-head); color: var(--primary); margin-bottom: 0.4rem; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ── Hamburger (injetado via JS no topbar) ──── */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    padding: 6px;
    margin-right: 0.5rem;
}
.hamburger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--primary);
    border-radius: 2px;
    transition: all 0.25s;
}
.hamburger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 150;
}
.sidebar-overlay.active { display: block; }

/* ── Responsivo ─────────────────────────────── */
@media (max-width: 900px) {
    .auth-wrapper { grid-template-columns: 1fr; }
    .auth-brand { display: none; }
    .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
    .planos-grid { grid-template-columns: 1fr; }

    /* Sidebar vira gaveta (drawer) que desliza por cima */
    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 260px;
        max-width: 80vw;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 200;
    }
    .sidebar.mobile-open { transform: translateX(0); }

    .main-content { margin-left: 0; width: 100%; }
    .hamburger-btn { display: flex; }

    .stats-grid { grid-template-columns: 1fr 1fr; }
    .page-body { padding: 1.1rem; }
    .topbar { padding: 0 1rem; }
    .topbar h1 { font-size: 1rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .topbar-user span { display: none; }
}
