/* ==============================================
   OdontoManager Pro — CSS Premium
   Sistema de Gestão Odontológica
   ============================================== */

/* === RESET & VARIÁVEIS === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Cores Principais */
    --primary: #0891b2;
    --primary-dark: #0e7490;
    --primary-light: #cffafe;
    --primary-gradient: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
    
    /* Cores de Status */
    --success: #10b981;
    --success-light: #d1fae5;
    --success-dark: #059669;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #3b82f6;
    --info-light: #dbeafe;
    
    /* Cores Auxiliares */
    --purple: #8b5cf6;
    --purple-light: #ede9fe;
    --teal: #14b8a6;
    --teal-light: #ccfbf1;
    --orange: #f97316;
    --orange-light: #ffedd5;
    --pink: #ec4899;
    --pink-light: #fce7f3;
    
    /* Cores de Interface */
    --bg: #f8fafc;
    --bg-alt: #f1f5f9;
    --bg-card: #ffffff;
    --text: #0f172a;
    --text-secondary: #475569;
    --text-light: #94a3b8;
    --text-muted: #cbd5e1;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    
    /* Sidebar */
    --sidebar-bg: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    --sidebar-text: #94a3b8;
    --sidebar-hover: rgba(255,255,255,0.08);
    --sidebar-active: var(--primary);
    
    /* Sombras */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
    --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
    --shadow-xl: 0 25px 50px -12px rgba(0,0,0,0.15);
    --shadow-glow: 0 0 20px rgba(8, 145, 178, 0.3);
    
    /* Bordas */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* Transições */
    --transition-fast: 0.15s ease;
    --transition: 0.2s ease;
    --transition-slow: 0.3s ease;
    
    /* Sidebar width */
    --sidebar-width: 280px;
}

/* === BASE === */
html {
    font-size: 15px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

/* Previne overflow horizontal em todos os elementos */
*, *::before, *::after {
    max-width: 100%;
}

.page {
    overflow-x: hidden;
}

/* === SCROLLBAR PERSONALIZADA === */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-alt);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
    transition: background var(--transition);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* === SIDEBAR === */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform var(--transition-slow);
    box-shadow: var(--shadow-lg);
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.logo-icon {
    font-size: 2rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.logo-text {
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.5px;
}

.logo-badge {
    background: var(--primary-gradient);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    letter-spacing: 0.5px;
}

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

.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.06);
    margin: 12px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--radius);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
    transition: height var(--transition);
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.nav-item.active {
    background: rgba(8, 145, 178, 0.2);
    color: #fff;
}

.nav-item.active::before {
    height: 24px;
}

.nav-icon {
    font-size: 1.15rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.clinica-info {
    color: var(--sidebar-text);
    font-size: 0.8rem;
    text-align: center;
    opacity: 0.8;
}

.clinica-info small {
    display: block;
    line-height: 1.4;
}

/* === MOBILE MENU === */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    background: var(--primary-gradient);
    color: #fff;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    font-size: 1.4rem;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: transform var(--transition), box-shadow var(--transition);
}

.mobile-menu-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 99;
}

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

/* === MAIN CONTENT === */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px;
    min-height: 100vh;
    background: var(--bg);
    overflow-x: hidden;
    max-width: calc(100vw - var(--sidebar-width));
}

/* === PAGES === */
.page {
    display: none;
    animation: pageIn 0.4s ease;
}

.page.active {
    display: block;
}

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

/* === PAGE HEADER === */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header h1 {
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 4px;
}

.header-info {
    text-align: right;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.header-info strong {
    color: var(--text);
    display: block;
}

/* === SECTION TITLE === */
.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin: 28px 0 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* === STATS GRID === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stats-grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    position: relative;
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.stat-blue::before { background: var(--primary); }
.stat-green::before { background: var(--success); }
.stat-purple::before { background: var(--purple); }
.stat-orange::before { background: var(--orange); }
.stat-red::before { background: var(--danger); }
.stat-teal::before { background: var(--teal); }
.stat-pink::before { background: var(--pink); }

.stat-icon {
    font-size: 2.2rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    background: var(--bg-alt);
    flex-shrink: 0;
}

.stat-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* === DASHBOARD GRID === */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

/* === CARDS === */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    overflow: hidden;
    transition: box-shadow var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-full {
    grid-column: 1 / -1;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(to bottom, var(--bg-card), var(--bg-alt));
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.link-more {
    font-size: 0.85rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition);
}

.link-more:hover {
    color: var(--primary-dark);
}

.card-body {
    padding: 20px 24px;
}

/* === TABLES === */
.table-responsive {
    overflow-x: auto;
    margin: -20px -24px;
    padding: 0 24px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    background: var(--bg-alt);
}

.table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.93rem;
    color: var(--text);
    vertical-align: middle;
}

.table tbody tr {
    transition: background var(--transition);
}

.table tbody tr:hover {
    background: var(--bg-alt);
}

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

/* === SEARCH BAR === */
.search-bar {
    position: relative;
    width: 100%;
    max-width: 400px;
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    opacity: 0.5;
}

.search-bar input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    color: var(--text);
    background: var(--bg);
    transition: all var(--transition);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-card);
    box-shadow: 0 0 0 4px rgba(8, 145, 178, 0.1);
}

/* === FILTER BAR === */
.filter-bar {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    margin-bottom: 24px;
    flex-wrap: wrap;
    background: var(--bg-card);
    padding: 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.filter-group input,
.filter-group select {
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--text);
    background: var(--bg);
    min-width: 180px;
    transition: all var(--transition);
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-card);
}

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 22px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(255,255,255,0.1), transparent);
    opacity: 0;
    transition: opacity var(--transition);
}

.btn:hover::before {
    opacity: 1;
}

.btn-primary {
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: 0 2px 8px rgba(8, 145, 178, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(8, 145, 178, 0.4);
}

.btn-secondary {
    background: var(--bg);
    color: var(--text-secondary);
    border: 2px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
    color: var(--text);
    border-color: var(--text-muted);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, var(--success-dark) 100%);
    color: #fff;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    color: #fff;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
}

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

.btn-lg {
    padding: 14px 32px;
    font-size: 1rem;
}

.btn-icon {
    padding: 8px;
    font-size: 1rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.btn-icon:hover {
    background: var(--bg-alt);
}

.btn-icon.view:hover { color: var(--info); border-color: var(--info); }
.btn-icon.edit:hover { color: var(--primary); border-color: var(--primary); }
.btn-icon.delete:hover { color: var(--danger); border-color: var(--danger); }
.btn-icon.print:hover { color: var(--purple); border-color: var(--purple); }
.btn-icon.download:hover { color: var(--success); border-color: var(--success); }
.btn-icon.whatsapp { background: #25D366; border-color: #25D366; color: #fff; }
.btn-icon.whatsapp:hover { background: #128C7E; border-color: #128C7E; transform: scale(1.1); }
.btn-icon.whatsapp svg { display: block; }

.action-buttons {
    display: flex;
    gap: 6px;
}

.btn-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.form-actions {
    padding: 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-alt);
    margin: 24px -24px -20px;
    display: flex;
    justify-content: flex-end;
}

/* === BADGES === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

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

.badge-confirmado {
    background: var(--purple-light);
    color: var(--purple);
}

/* === DEMO BANNER === */
.demo-banner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: #fbbf24;
    color: #451a03;
    text-align: center;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 9999;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

body.demo-mode {
    padding-top: 40px;
}

body.demo-mode .sidebar {
    top: 40px;
    height: calc(100vh - 40px);
}

body.demo-mode .mobile-menu-btn {
    top: 56px;
}

@media (max-width: 768px) {
    .demo-banner {
        font-size: 0.8rem;
        padding: 6px 12px;
    }
    body.demo-mode {
        padding-top: 46px; /* A bit more space if text wraps */
    }
    body.demo-mode .sidebar {
        top: 46px;
        height: calc(100vh - 46px);
    }
    body.demo-mode .mobile-menu-btn {
        top: 62px;
    }
}

.badge-realizado {
    background: var(--success-light);
    color: var(--success-dark);
}

.badge-cancelado {
    background: var(--danger-light);
    color: var(--danger);
}

/* === MODALS === */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(6px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-y: auto;
}

.modal-overlay.show {
    display: flex;
    animation: fadeIn 0.2s ease;
}

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

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalIn 0.3s ease;
    margin: auto;
}

.modal-lg {
    max-width: 720px;
}

.modal-xl {
    max-width: 900px;
}

.modal-sm {
    max-width: 420px;
}

@keyframes modalIn {
    from { 
        transform: translateY(-20px) scale(0.95); 
        opacity: 0; 
    }
    to { 
        transform: translateY(0) scale(1); 
        opacity: 1; 
    }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to bottom, var(--bg-card), var(--bg-alt));
    position: sticky;
    top: 0;
    z-index: 10;
}

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

.modal-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    color: var(--text-light);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color var(--transition), transform var(--transition);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

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

.modal-body {
    padding: 24px;
}

.modal-body-confirm {
    padding: 32px 24px;
    text-align: center;
}

.modal-body-confirm p {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: var(--bg-alt);
    position: sticky;
    bottom: 0;
}

/* === FORMS === */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-full {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    color: var(--text);
    font-family: inherit;
    transition: all var(--transition);
    background: var(--bg-card);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(8, 145, 178, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* === FILE UPLOAD === */
.file-upload {
    position: relative;
}

.file-upload input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.file-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: var(--bg-alt);
    color: var(--text-secondary);
    font-size: 0.95rem;
    text-align: center;
    transition: all var(--transition);
    min-height: 120px;
}

.file-upload:hover .file-upload-label {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary-dark);
}

.file-upload-label.has-file {
    border-color: var(--success);
    background: var(--success-light);
    color: var(--success-dark);
}

/* === ARQUIVOS GRID === */
.arquivos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.arquivo-card {
    background: var(--bg-alt);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    transition: all var(--transition);
    border: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.arquivo-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.arquivo-icon {
    font-size: 3rem;
    opacity: 0.8;
}

.arquivo-info {
    flex: 1;
}

.arquivo-nome {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 4px;
    word-break: break-word;
}

.arquivo-meta {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.arquivo-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 8px;
}

/* === RECEITA PREVIEW === */
.receita-preview {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    max-width: 100%;
    margin: 0 auto;
    font-family: 'Times New Roman', serif;
}

.receita-header {
    text-align: center;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 20px;
    margin-bottom: 30px;
}

.receita-header h2 {
    color: var(--primary-dark);
    font-size: 1.4rem;
    margin-bottom: 8px;
}

.receita-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 4px 0;
}

.receita-paciente {
    margin-bottom: 30px;
    padding: 16px;
    background: var(--bg-alt);
    border-radius: var(--radius-sm);
}

.receita-paciente p {
    margin: 6px 0;
}

.receita-corpo {
    min-height: 200px;
    margin-bottom: 30px;
    line-height: 1.8;
    white-space: pre-wrap;
}

.receita-orientacoes {
    padding: 16px;
    background: var(--warning-light);
    border-radius: var(--radius-sm);
    margin-bottom: 30px;
}

.receita-orientacoes h4 {
    color: var(--warning);
    margin-bottom: 8px;
}

.receita-footer {
    text-align: center;
    border-top: 1px solid var(--border);
    padding-top: 30px;
    margin-top: 40px;
}

.receita-assinatura {
    margin-bottom: 16px;
}

.receita-assinatura-linha {
    width: 250px;
    border-top: 1px solid var(--text);
    margin: 0 auto 8px;
}

.receita-rodape {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 20px;
}

/* === FICHA DO PACIENTE === */
.ficha-section {
    margin-bottom: 24px;
}

.ficha-section h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.ficha-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.ficha-item {
    background: var(--bg-alt);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
}

.ficha-item label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    display: block;
    margin-bottom: 4px;
}

.ficha-item span {
    font-size: 0.95rem;
    color: var(--text);
}

.ficha-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 16px;
}

/* === DASHBOARD LISTS === */
.dash-list {
    list-style: none;
}

.dash-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-light);
    gap: 12px;
}

.dash-list-item:last-child {
    border-bottom: none;
}

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

.dash-list-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dash-list-detail {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.dash-list-value {
    font-weight: 600;
    color: var(--danger);
    white-space: nowrap;
}

.dash-list-value.positive {
    color: var(--success);
}

/* === PROGRESS BAR === */
.progress-bar {
    height: 8px;
    background: var(--bg-alt);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-top: 8px;
}

.progress-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.5s ease;
}

.progress-bar-fill.blue { background: var(--primary-gradient); }
.progress-bar-fill.green { background: linear-gradient(135deg, var(--success), var(--teal)); }
.progress-bar-fill.purple { background: linear-gradient(135deg, var(--purple), var(--pink)); }
.progress-bar-fill.orange { background: linear-gradient(135deg, var(--orange), var(--warning)); }
.progress-bar-fill.red { background: linear-gradient(135deg, var(--danger), var(--orange)); }

/* === CHART BARS (CSS-only) === */
.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 180px;
    padding: 16px 0;
}

.chart-bar {
    flex: 1;
    background: var(--primary-gradient);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    position: relative;
    min-height: 8px;
    transition: all var(--transition);
}

.chart-bar:hover {
    opacity: 0.8;
}

.chart-bar-label {
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.chart-bar-value {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    color: var(--text-light);
    padding: 40px 20px;
    font-size: 0.95rem;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* === TOAST === */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 380px;
}

.toast {
    padding: 16px 20px;
    border-radius: var(--radius);
    color: #fff;
    font-weight: 500;
    font-size: 0.9rem;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.toast-success { background: linear-gradient(135deg, var(--success), var(--success-dark)); }
.toast-error { background: linear-gradient(135deg, var(--danger), #dc2626); }
.toast-info { background: var(--primary-gradient); }
.toast-warning { background: linear-gradient(135deg, var(--warning), var(--orange)); }

@keyframes slideIn {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(120%); opacity: 0; }
}

/* === UTILITIES === */
.mt-20 { margin-top: 20px; }
.mb-16 { margin-bottom: 16px; }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }

/* === RESPONSIVE === */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* === CLASSES UTILITÁRIAS MOBILE === */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

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

    .main-content {
        margin-left: 0;
        padding: 16px 12px;
        padding-top: 72px;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .page {
        width: 100%;
        overflow-x: hidden;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }

    .page-header > div:last-child:not(:first-child) {
        width: 100%;
    }

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

    /* === STATS GRID MOBILE === */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

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

    .stat-card {
        padding: 14px 12px;
        gap: 10px;
        flex-direction: column;
        text-align: center;
    }

    .stat-icon {
        width: 44px;
        height: 44px;
        font-size: 1.5rem;
        margin: 0 auto;
    }

    .stat-value {
        font-size: 1.1rem;
    }

    .stat-label {
        font-size: 0.7rem;
        line-height: 1.3;
    }

    /* === FORMS MOBILE === */
    .form-grid {
        grid-template-columns: 1fr;
        padding: 16px;
    }

    .form-full {
        grid-column: 1;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 10px 12px;
        font-size: 16px; /* Previne zoom no iOS */
    }

    /* === MODALS MOBILE === */
    .modal-overlay {
        padding: 8px;
        align-items: flex-start;
        padding-top: 60px;
    }

    .modal {
        margin: 0;
        max-height: calc(100vh - 80px);
        border-radius: var(--radius);
    }

    .modal-header {
        padding: 14px 16px;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .modal-header h2 {
        font-size: 1rem;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        padding: 12px 16px;
        flex-direction: column;
        position: sticky;
        bottom: 0;
    }

    .modal-footer .btn {
        width: 100%;
    }

    /* === FILTER BAR MOBILE === */
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 14px;
        gap: 12px;
    }

    .filter-group {
        width: 100%;
    }

    .filter-group label {
        font-size: 0.75rem;
    }

    .filter-group input,
    .filter-group select {
        min-width: auto;
        width: 100%;
        padding: 10px 12px;
        font-size: 16px;
    }

    .filter-bar .btn {
        width: 100%;
        margin-top: 4px;
    }

    /* === CARDS MOBILE === */
    .card {
        border-radius: var(--radius);
    }

    .card-header {
        padding: 14px 16px;
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .card-header h3 {
        font-size: 0.95rem;
    }

    .card-body {
        padding: 12px;
    }

    /* === TABLES MOBILE === */
    .table-responsive {
        margin: -12px;
        padding: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: calc(100vw - 24px);
    }

    .table {
        min-width: 320px;
        width: 100%;
        table-layout: auto;
    }

    .table th, 
    .table td {
        padding: 8px 6px;
        font-size: 0.75rem;
        white-space: nowrap;
    }

    .table th:first-child,
    .table td:first-child {
        padding-left: 8px;
        position: sticky;
        left: 0;
        background: inherit;
        z-index: 1;
    }

    .table tbody tr:hover td:first-child {
        background: var(--bg-alt);
    }

    .table th:last-child,
    .table td:last-child {
        padding-right: 8px;
    }

    /* Colunas ocultas em mobile para tabelas específicas */
    .table .col-hide-mobile {
        display: none;
    }

    /* Força quebra de texto em algumas colunas */
    .table td {
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .table td:last-child {
        max-width: none;
        overflow: visible;
    }

    /* === ACTION BUTTONS MOBILE === */
    .action-buttons {
        gap: 4px;
        flex-wrap: nowrap;
    }

    .btn-icon {
        width: 30px;
        height: 30px;
        font-size: 0.85rem;
        padding: 4px;
    }

    .btn-icon svg {
        width: 14px;
        height: 14px;
    }

    /* === BADGE MOBILE === */
    .badge {
        padding: 3px 8px;
        font-size: 0.65rem;
    }

    /* === TOAST MOBILE === */
    .toast-container {
        left: 12px;
        right: 12px;
        top: 16px;
        max-width: none;
    }

    .toast {
        padding: 12px 16px;
        font-size: 0.85rem;
    }

    /* === RECEITA PREVIEW MOBILE === */
    .receita-preview {
        padding: 12px;
        font-size: 0.85rem;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .receita-header h2 {
        font-size: 1rem;
        word-wrap: break-word;
    }

    .receita-header p {
        font-size: 0.75rem;
        word-wrap: break-word;
    }

    .receita-corpo {
        font-size: 0.85rem;
        min-height: 120px;
        word-wrap: break-word;
        white-space: pre-wrap;
    }

    .receita-assinatura-linha {
        width: 180px;
    }

    .receita-paciente {
        padding: 10px;
    }

    .receita-paciente p {
        font-size: 0.8rem;
        word-wrap: break-word;
    }

    .receita-orientacoes {
        padding: 10px;
    }

    .receita-orientacoes h4 {
        font-size: 0.9rem;
    }

    .receita-orientacoes p {
        font-size: 0.8rem;
    }

    /* === ARQUIVOS GRID MOBILE === */
    .arquivos-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 10px;
    }

    .arquivo-card {
        padding: 12px 8px;
    }

    .arquivo-icon {
        font-size: 2.2rem;
    }

    .arquivo-nome {
        font-size: 0.8rem;
    }

    .arquivo-meta {
        font-size: 0.7rem;
    }

    .arquivo-actions {
        gap: 4px;
    }

    .arquivo-actions .btn-icon {
        width: 28px;
        height: 28px;
    }

    /* === SEARCH BAR MOBILE === */
    .search-bar {
        max-width: 100%;
    }

    .search-bar input {
        padding: 10px 12px 10px 40px;
        font-size: 16px;
    }

    /* === DASHBOARD MOBILE === */
    .dashboard-grid {
        gap: 16px;
    }

    .dash-list-item {
        padding: 10px 0;
        flex-wrap: wrap;
        gap: 8px;
    }

    .dash-list-name {
        font-size: 0.9rem;
    }

    .dash-list-detail {
        font-size: 0.75rem;
    }

    .dash-list-value {
        font-size: 0.85rem;
    }

    /* === FICHA PACIENTE MOBILE === */
    .ficha-section {
        margin-bottom: 20px;
    }

    .ficha-section h4 {
        font-size: 0.95rem;
    }

    .ficha-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .ficha-item {
        padding: 10px 12px;
    }

    .ficha-item label {
        font-size: 0.7rem;
    }

    .ficha-item span {
        font-size: 0.88rem;
    }

    .ficha-actions {
        flex-direction: column;
        gap: 8px;
    }

    .ficha-actions .btn {
        width: 100%;
    }

    /* === SECTION TITLE MOBILE === */
    .section-title {
        font-size: 1rem;
        margin: 20px 0 12px;
    }

    /* === SIDEBAR NAV MOBILE === */
    .nav-item {
        padding: 14px 16px;
    }

    /* === ESTATÍSTICAS MOBILE === */
    .chart-bars {
        height: 120px;
        padding-bottom: 30px;
        gap: 4px;
        overflow-x: auto;
        overflow-y: visible;
        padding-top: 20px;
    }

    .chart-bar {
        min-width: 30px;
        flex: 0 0 auto;
    }

    .chart-bar-label {
        font-size: 0.55rem;
        bottom: -22px;
    }

    .chart-bar-value {
        font-size: 0.55rem;
        top: -16px;
    }

    /* Card full em mobile */
    .card-full {
        grid-column: 1;
    }

    /* Dashboard grid em mobile */
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    /* === PROGRESS BARS MOBILE === */
    .progress-bar {
        height: 6px;
    }

    /* === LISTA ESTATÍSTICAS MOBILE === */
    .dash-list-item {
        flex-direction: column;
        align-items: flex-start !important;
    }

    .dash-list-item > div {
        width: 100%;
    }

    .dash-list-item .dash-list-name {
        white-space: normal;
        word-wrap: break-word;
    }

    /* === BTN GROUP MOBILE === */
    .btn-group {
        flex-direction: column;
        width: 100%;
    }

    .btn-group .btn {
        width: 100%;
    }

    /* === FORM ACTIONS MOBILE === */
    .form-actions {
        padding: 16px;
        margin: 16px -16px -12px;
    }

    .form-actions .btn {
        width: 100%;
    }

    /* === FILE UPLOAD MOBILE === */
    .file-upload-label {
        padding: 24px 16px;
        min-height: 100px;
        font-size: 0.9rem;
    }

    /* === VISUALIZADOR ARQUIVO MOBILE === */
    .arquivo-viewer {
        min-height: 300px;
        max-height: 60vh;
        padding: 12px;
    }

    .arquivo-viewer img {
        max-height: 55vh;
    }

    .arquivo-viewer iframe {
        height: 55vh;
    }

    .arquivo-viewer .no-preview .icon {
        font-size: 3rem;
    }

    .arquivo-viewer .no-preview p {
        font-size: 1rem;
    }

    /* === FORÇAR LARGURAS DE TABELA MOBILE === */
    .table {
        table-layout: fixed !important;
        width: 100% !important;
    }

    /* Todas as células truncam texto */
    .table td,
    .table th {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* === CORREÇÕES ESPECÍFICAS PARA TABELAS MOBILE === */
@media (max-width: 768px) {
    /* Truncar nomes longos com ... */
    .table td.truncate,
    .table .truncate {
        max-width: 100px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Coluna de nome em Pacientes */
    .table td:first-child {
        max-width: 120px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Ajuste geral de colunas */
    .table th,
    .table td {
        max-width: 100px;
        word-wrap: break-word;
    }

    /* Coluna de ações sempre visível */
    .table td:last-child,
    .table th:last-child {
        max-width: none;
        white-space: nowrap;
    }

    /* Financeiro - colunas menores */
    #tabelaFinanceiro td,
    #tabelaFinanceiro th {
        padding: 8px 6px;
        font-size: 0.75rem;
    }

    #tabelaFinanceiro td:nth-child(1) { max-width: 70px; } /* Data */
    #tabelaFinanceiro td:nth-child(2) { max-width: 80px; } /* Paciente */
    #tabelaFinanceiro td:nth-child(3) { max-width: 80px; } /* Serviço */
    #tabelaFinanceiro td:nth-child(4) { max-width: 70px; white-space: nowrap; } /* Valor */

    /* Despesas - ajuste */
    #tabelaDespesas td,
    #tabelaDespesas th {
        padding: 8px 6px;
        font-size: 0.75rem;
    }

    #tabelaDespesas td:nth-child(1) { max-width: 70px; } /* Data */
    #tabelaDespesas td:nth-child(2) { max-width: 90px; } /* Descrição */
    #tabelaDespesas td:nth-child(3) { max-width: 70px; } /* Categoria */
    #tabelaDespesas td:nth-child(4) { max-width: 65px; white-space: nowrap; } /* Valor */

    /* Receituário - medicamentos abreviados */
    #tabelaReceitas td:nth-child(3) {
        max-width: 100px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Agendamentos */
    #tabelaAgendamentos td:nth-child(1) { max-width: 75px; font-size: 0.7rem; } /* Data/Hora */
    #tabelaAgendamentos td:nth-child(2) { max-width: 90px; } /* Paciente */

    /* Tratamentos */
    #tabelaTratamentos td:nth-child(1) { max-width: 100px; } /* Procedimento */

    /* Pacientes */
    #tabelaPacientes td:nth-child(1) { max-width: 100px; } /* Nome */
    #tabelaPacientes td:nth-child(2) { max-width: 80px; } /* Telefone */
}

/* === MOBILE EXTRA SMALL === */
@media (max-width: 380px) {
    html {
        font-size: 13px;
    }

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

    .stat-card {
        flex-direction: row;
        text-align: left;
        padding: 12px;
    }

    .stat-icon {
        margin: 0;
        width: 40px;
        height: 40px;
        font-size: 1.3rem;
    }

    .stat-value {
        font-size: 1rem;
    }

    .stat-label {
        font-size: 0.65rem;
    }

    .page-header h1 {
        font-size: 1.2rem;
    }

    .logo-text {
        font-size: 1.1rem;
    }

    .action-buttons {
        gap: 2px;
    }

    .btn-icon {
        width: 26px;
        height: 26px;
        font-size: 0.75rem;
    }

    .btn-icon svg {
        width: 12px;
        height: 12px;
    }

    .filter-bar {
        padding: 10px;
    }

    .filter-group input,
    .filter-group select {
        padding: 8px 10px;
        font-size: 14px;
    }

    .card-header {
        padding: 10px 12px;
    }

    .card-body {
        padding: 10px;
    }

    .table th,
    .table td {
        padding: 6px 4px;
        font-size: 0.7rem;
    }

    .badge {
        padding: 2px 6px;
        font-size: 0.6rem;
    }

    .section-title {
        font-size: 0.9rem;
    }
}

/* === VISUALIZADOR DE ARQUIVOS === */
.arquivo-viewer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    max-height: 70vh;
    overflow: auto;
    background: var(--bg-alt);
    border-radius: var(--radius);
    padding: 20px;
}

.arquivo-viewer img {
    max-width: 100%;
    max-height: 65vh;
    object-fit: contain;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
}

.arquivo-viewer iframe {
    width: 100%;
    height: 70vh;
    border: none;
    border-radius: var(--radius-sm);
}

.arquivo-viewer .no-preview {
    text-align: center;
    color: var(--text-secondary);
    padding: 60px 20px;
}

.arquivo-viewer .no-preview .icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.arquivo-viewer .no-preview p {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.arquivo-viewer .no-preview small {
    color: var(--text-light);
}

/* === PRINT === */
@media print {
    body {
        background: #fff;
    }

    .sidebar, .mobile-menu-btn, .modal-footer, .btn, .toast-container {
        display: none !important;
    }

    .main-content {
        margin: 0;
        padding: 0;
    }

    .modal-overlay {
        position: static;
        background: none;
        backdrop-filter: none;
        display: block !important;
        padding: 0;
    }

    .modal {
        box-shadow: none;
        border: none;
        max-width: 100%;
        max-height: none;
    }

    .modal-header {
        background: none;
    }

    .receita-preview {
        border: none;
        padding: 0;
    }
}
