/* ==========================================
   VARIÁVEIS DE CORES (PALETA TERROSA)
========================================== */
:root {
    --primary: #c05c47;
    --primary-dark: #8c3b2b;
    --primary-light: #f4e8e6;
    
    --bg-color: #fdfbf7;
    --sidebar-bg: #ffffff;
    
    --text-main: #3e2723;
    --text-muted: #8d6e63;
    --border: #e7e0d8;
    
    --sidebar-width: 260px;
    --topbar-height: 70px;
    --radius: 10px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.03);
}

/* ==========================================
   RESETS E BASE
========================================== */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

/* ==========================================
   SIDEBAR
========================================== */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease, width 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    min-height: var(--topbar-height);
}

.sidebar-header .material-icons {
    font-size: 32px;
    color: var(--primary);
    flex-shrink: 0;
}

.sidebar-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
}

.sidebar-menu {
    flex: 1;
    padding: 16px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s;
    user-select: none;
}

.menu-item:hover {
    background-color: #faf6f0;
    color: var(--primary);
}

.menu-item.active {
    background-color: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.menu-item .material-icons {
    font-size: 22px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 10px 20px;
    border-top: 1px solid var(--border);
}

/* Overlay mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(62, 39, 35, 0.45);
    z-index: 90;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.visible {
    display: block;
}

/* ==========================================
   MAIN CONTENT
========================================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    transition: margin-left 0.3s ease, width 0.3s ease;
}

.topbar {
    height: var(--topbar-height);
    background-color: var(--sidebar-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-menu {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    padding: 6px;
    border-radius: 8px;
}

.btn-menu:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.btn-menu .material-icons {
    font-size: 26px;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    color: var(--text-main);
}

.topbar-user .material-icons {
    color: var(--text-muted);
    font-size: 28px;
}

.content-area {
    flex: 1;
    padding: 24px 28px 40px;
    overflow-y: auto;
}

/* ==========================================
   UTILITÁRIOS
========================================== */
.hidden { display: none !important; }

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-main);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.section-header .section-title {
    margin-bottom: 0;
}

.card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.card-muted {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Stats no dashboard */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0,0,0,0.05);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon .material-icons {
    font-size: 26px;
}

.stat-info h4 {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.stat-info p {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-main);
}

/* ==========================================
   BOTÕES
========================================== */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    line-height: 1.2;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background-color: var(--primary);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-dark);
}

.btn-secondary {
    background-color: var(--primary-light);
    color: var(--primary-dark);
}

.btn-secondary:hover:not(:disabled) {
    background-color: #ead9d5;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-sm {
    padding: 7px 12px;
    font-size: 0.82rem;
}

/* ==========================================
   FORMULÁRIOS
========================================== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text-main);
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(192, 92, 71, 0.15);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* ==========================================
   MODAIS
========================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(62, 39, 35, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
    padding: 16px;
}

.modal-content {
    background: #fff;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.15);
}

.modal-content.modal-lg {
    max-width: 640px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
}

.modal-header h2 {
    font-size: 1.2rem;
    color: var(--text-main);
}

.modal-close {
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 6px;
    padding: 2px;
}

.modal-close:hover {
    color: var(--primary);
    background: var(--primary-light);
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
}

.modal-actions .btn {
    flex: 1;
}

/* ==========================================
   GRID E CARDS DE PACIENTES
========================================== */
.grid-pacientes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.patient-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    transition: transform 0.2s, box-shadow 0.2s;
    border-left: 4px solid var(--primary);
}

.patient-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 14px rgba(0,0,0,0.06);
}

.patient-card h3 {
    font-size: 1.05rem;
    margin-bottom: 12px;
    color: var(--text-main);
    line-height: 1.3;
}

.patient-card p {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.patient-card .material-icons {
    font-size: 17px;
    color: var(--primary);
    flex-shrink: 0;
}

.patient-card-actions {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Empty / loading states */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state .material-icons {
    font-size: 48px;
    opacity: 0.4;
    margin-bottom: 12px;
}

.loading-text {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ==========================================
   TABELAS SIMPLES (Agenda / Docs)
========================================== */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

table.data-table th,
table.data-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

table.data-table th {
    background: #faf6f0;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
}

table.data-table tr:last-child td {
    border-bottom: none;
}

table.data-table tr:hover td {
    background: #fdfbf7;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-warning {
    background: #fff8e1;
    color: #f57f17;
}

.badge-danger {
    background: #fce4ec;
    color: #c62828;
}

.badge-info {
    background: var(--primary-light);
    color: var(--primary-dark);
}

/* ==========================================
   LOGIN PAGE
========================================== */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background-color: var(--bg-color);
}

.login-container {
    background: #ffffff;
    padding: 2.25rem;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.04);
    width: 100%;
    max-width: 380px;
    text-align: center;
    border: 1px solid var(--border);
}

.login-container .logo-icon {
    font-size: 48px;
    color: var(--primary);
    margin-bottom: 8px;
}

.login-container h1 {
    font-size: 1.45rem;
    color: var(--text-main);
    margin-bottom: 0.4rem;
}

.login-container .subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1.75rem;
}

.login-container .form-group {
    text-align: left;
}

.btn-submit {
    width: 100%;
    background-color: var(--primary);
    color: white;
    padding: 0.8rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-top: 0.5rem;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-submit:hover:not(:disabled) {
    background-color: var(--primary-dark);
}

.btn-submit:disabled {
    background-color: #d7ccc8;
    cursor: not-allowed;
}

/* ==========================================
   RESPONSIVO
========================================== */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .btn-menu {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .content-area {
        padding: 20px 16px 32px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .section-title {
        font-size: 1.3rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .section-header .btn {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .grid-pacientes {
        grid-template-columns: 1fr;
    }

    .modal-content {
        padding: 18px;
    }

    .topbar {
        padding: 0 14px;
    }

    .login-container {
        padding: 1.75rem 1.25rem;
    }
}

@media (max-width: 400px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ========== EXTRAS v1.2 ========== */
.subsection-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 8px 0 12px;
    color: var(--text-main);
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 14px;
    margin-bottom: 18px;
}
.search-bar .material-icons {
    color: var(--text-muted);
    font-size: 22px;
}
.search-bar .form-control {
    border: none;
    box-shadow: none;
    padding: 6px 0;
}
.search-bar .form-control:focus {
    box-shadow: none;
}

.sugestoes-lista {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-top: -12px;
    margin-bottom: 16px;
    max-height: 240px;
    overflow-y: auto;
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
    z-index: 20;
    position: relative;
}
.sugestao-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    gap: 12px;
}
.sugestao-item:last-child { border-bottom: none; }
.sugestao-item:hover { background: var(--primary-light); }
.sugestao-item.muted { color: var(--text-muted); cursor: default; }

.pront-header { margin-bottom: 16px; }
.pront-header-grid {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    align-items: flex-start;
}
.pront-header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filtros-periodo {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 16px;
}

.evol-card {
    margin-bottom: 10px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}
.evol-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0,0,0,0.06);
}
.evol-preview {
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.4;
}

.contact-actions {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.aniv-list { display: flex; flex-direction: column; gap: 10px; }
.aniv-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.aniv-item:last-child { border-bottom: none; }
.aniv-dia {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}
.chip small { opacity: 0.75; font-weight: 400; }

.form-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 8px 0 14px;
}
.form-section-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

@media (max-width: 600px) {
    .pront-header-grid { flex-direction: column; }
    .aniv-item { flex-wrap: wrap; }
}
