/* =========================================
   ATACHE: RESTAURACIÓN VISUAL (MATTE BLACK & GOLD)
   ========================================= */

:root {
    /* Identidad Oficial: The Clinical Atelier */
    --primary-color: #00355f;    /* Azul Atelier */
    --primary-container: #0f4c81;
    --secondary-color: #006a6a;  /* Verde Quirúrgico */
    --tertiary-color: #3d009b;   /* Violeta Clínico */
    
    /* Superficies y Fondos */
    --bg-dark: #f7f9fb;          /* Gris Neutro Atelier */
    --bg-darker: #eceef0;
    --surface: #ffffff;
    
    /* Glassmorphism & Shadows */
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(0, 53, 95, 0.08);
    --glass-shadow: 0 20px 40px rgba(0, 53, 95, 0.06);
    --shadow-sm: 0 1px 3px rgba(0, 53, 95, 0.02);

    /* Textos Legibilidad Máxima */
    --text-main: #191c1e;        /* On-Surface */
    --text-muted: #42474f;       /* On-Surface-Variant */
    --text-outline: #5c6066;     /* Oscurecido para mejor contraste en blanco */
    --text-outline-variant: #8e9199;

    /* Estados Semánticos */
    --status-success: #006a6a;
    --status-warning: #f59e0b;
    --status-danger: #ba1a1a;

    /* Tipografía y Espaciados */
    --font-family: 'Inter', sans-serif;
    --font-headline: 'Manrope', sans-serif;
    
    --border-radius-lg: 16px;
    --border-radius-md: 12px;
    --border-radius-sm: 8px;
    --border-radius-xl: 24px;
    
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Mapeo Engine ATACHE */
    --primary: var(--primary-color);
    --on-primary: #ffffff;
    --on-surface: var(--text-main);
    --on-surface-variant: var(--text-muted);
    --surface-container-lowest: #ffffff;
    --surface-container-low: #f2f4f6;
    --surface-container: #eceef0;
    --surface-container-high: #e6e8ea;
    --surface-container-highest: #e0e3e5;
}

/* =========================================
   RESET Y BASE
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Brillos de fondo (Desactivados en este perfil para mantener el Matte Clean) */
.bg-glows { display: none; }

/* =========================================
   UTILERÍAS - GLASSMORPHISM
   ========================================= */
.glass-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--glass-shadow);
    color: var(--on-surface); /* Asegurar texto legible por defecto */
}

/* Forzar contraste en formularios dentro de paneles claros */
.glass-panel input, 
.glass-panel select, 
.glass-panel textarea {
    color: var(--on-surface) !important;
}

.glass-panel label {
    color: var(--on-surface-variant) !important;
}

/* Campos de formulario clínicos estandarizados */
.clinical-input {
    width: 100%;
    background: var(--surface-container-low) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 8px !important;
    padding: 0.6rem 0.8rem !important;
    color: var(--on-surface) !important;
    font-size: 0.9rem !important;
    outline: none !important;
    transition: all 0.2s ease !important;
}

.clinical-input:focus {
    background: var(--surface) !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(0, 53, 95, 0.05) !important;
}


/* Scrollbar personalizada Global */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 53, 95, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 53, 95, 0.2);
}

/* Scrollbar para elementos específicos (como el sidebar) */
.custom-scrollbar::-webkit-scrollbar {
    width: 4px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* =========================================
   LAYOUT PRINCIPAL
   ========================================= */
.app-container {
    display: flex;
    height: 100vh;
    padding: 1rem;
    gap: 1.5rem;
}

/* =========================================
   SIDEBAR (MENÚ LATERAL - FIJO 260px)
   ========================================= */
.sidebar {
    width: 260px;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    flex-shrink: 0;
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2.5rem;
}

.logo-img {
    width: 45px;
    height: 45px;
    object-fit: contain;
    filter: drop-shadow(0 0 6px rgba(212, 175, 55, 0.2));
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--border-radius-md);
    transition: var(--transition-fast);
    font-weight: 500;
}

.nav-item i {
    font-size: 1.25rem;
}

.nav-item:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: var(--primary-color);
    background: #f0f9ff;
    font-weight: 600;
}

.sidebar-footer {
    border-top: 1px solid var(--glass-border);
    padding-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: auto;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: var(--border-radius-md);
    background: rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: var(--transition-fast);
}

.user-profile:hover {
    background: rgba(0, 0, 0, 0.4);
}

.avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: white;
}

.user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* =========================================
   CONTENIDO PRINCIPAL Y TOPBAR
   ========================================= */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    width: 400px;
    border-radius: 100px;
    position: relative;
}

.search-bar i {
    color: var(--text-muted);
    font-size: 1.2rem;
}

.search-bar input {
    background: transparent;
    border: none;
    color: var(--text-main);
    width: 100%;
    font-size: 0.95rem;
    outline: none;
    font-family: var(--font-family);
}

.search-bar input::placeholder {
    color: var(--text-muted);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Botones */
.btn-primary {
    background: var(--primary-color);
    color: #ffffff;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 100px;
    font-family: var(--font-family);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: var(--transition-fast);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-icon,
.btn-icon-small {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
    position: relative;
}

.btn-icon {
    width: 45px;
    height: 45px;
    font-size: 1.3rem;
}

.btn-icon-small {
    width: 35px;
    height: 35px;
    font-size: 1.2rem;
}

.btn-icon:hover,
.btn-icon-small:hover {
    background: rgba(255, 255, 255, 0.1);
}

.badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--accent-color);
    color: var(--bg-dark);
    font-size: 0.65rem;
    font-weight: 700;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.btn-text {
    background: transparent;
    border: none;
    color: var(--primary-color);
    font-family: var(--font-family);
    font-weight: 500;
    cursor: pointer;
}

/* =========================================
   DASHBOARD GRID Y TARJETAS
   ========================================= */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: auto 1fr;
    gap: 1.5rem;
    flex-grow: 1;
}

.stat-card {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

.income-icon {
    background: rgba(212, 175, 55, 0.1);
    color: var(--accent-color);
}

.appointments-icon {
    background: rgba(74, 144, 226, 0.1);
    color: var(--primary-color);
}

.users-icon {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}

.stat-details {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-title {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.stat-trend {
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.stat-trend.positive {
    color: var(--status-success);
}

.stat-trend.neutral {
    color: var(--text-muted);
}

/* Secciones Grandes (Agenda y Actividad) */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.agenda-preview {
    grid-column: span 1;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.appointment-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex-grow: 1;
    overflow-y: auto;
}

.appointment-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: var(--border-radius-md);
    background: rgba(255, 255, 255, 0.03);
    border-left: 4px solid transparent;
    transition: var(--transition-fast);
}

.appointment-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.appointment-item.status-confirmed {
    border-left-color: var(--primary-color);
}

.appointment-item.status-waiting {
    border-left-color: var(--status-warning);
}

.appointment-item.status-unconfirmed {
    border-left-color: var(--text-muted);
}

.time {
    font-weight: 600;
    font-size: 0.95rem;
    min-width: 50px;
}

.patient-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.patient-info h4 {
    font-size: 0.95rem;
    font-weight: 600;
}

.patient-info span {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.status-badge {
    padding: 0.3rem 0.6rem;
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(74, 144, 226, 0.1);
    color: var(--primary-color);
}

.status-badge.waiting {
    background: rgba(245, 158, 11, 0.1);
    color: var(--status-warning);
}

.status-badge.unconfirmed {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-muted);
}

/* =========================================
   FICHA CLÍNICA DEL PACIENTE (PATIENT HUB)
   ========================================= */
.patient-hub {
    display: flex;
    gap: 1.5rem;
    flex-grow: 1;
    overflow: hidden;
}

/* Columna Izquierda: Perfil */
.patient-profile {
    width: 300px;
    flex-shrink: 0;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 1.5rem;
}

.patient-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    font-size: 2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    border: 3px solid var(--glass-border);
    box-shadow: 0 0 15px rgba(74, 144, 226, 0.2);
    color: white;
}

.patient-name {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.patient-id {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Alergias o Riesgos Médicos */
.patient-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    justify-content: center;
}

.badge-alert {
    padding: 0.4rem 0.8rem;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.badge-alert.danger {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.profile-details {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
    border-top: 1px solid var(--glass-border);
    padding-top: 1.5rem;
}

.detail-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.detail-row i {
    font-size: 1.2rem;
    color: var(--primary-color);
}

/* Finanzas en Perfil */
.financial-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.fin-box {
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--border-radius-md);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    border: 1px solid var(--glass-border);
}

.fin-box span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.fin-box.debt strong {
    color: #ef4444;
    font-size: 1.1rem;
}

.fin-box.points strong {
    color: var(--accent-color);
    font-size: 1.1rem;
}

/* Misc Utilities */
.w-100 {
    width: 100%;
}

/* Columna Derecha: Pestañas de Trabajo */
.patient-workspace {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.hub-tabs {
    display: flex;
    gap: 0.2rem;
    padding: 1rem 1rem 0 1rem;
    border-bottom: 1px solid var(--glass-border);
    overflow-x: auto;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 1rem 1.5rem;
    font-family: var(--font-family);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 3px solid transparent;
    transition: var(--transition-fast);
}

.tab-btn:hover {
    color: var(--text-main);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.tab-pane {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-pane.active {
    display: block;
}

.pane-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* Historial Clínico (Timeline) */
.timeline {
    border-left: 2px solid var(--glass-border);
    margin-left: 1rem;
    padding-left: 1.5rem;
}

.timeline-item {
    position: relative;
    margin-bottom: 2rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -29px;
    top: 5px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary-color);
    box-shadow: 0 0 10px rgba(74, 144, 226, 0.5);
}

.timeline-date {
    font-size: 0.8rem;
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.box-panel {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-md);
    padding: 1.2rem;
}

.box-panel h4 {
    margin-bottom: 0.5rem;
    color: var(--accent-color);
}

.box-panel p {
    font-size: 0.95rem;
    line-height: 1.5;
    color: #e2e8f0;
    margin-bottom: 1rem;
}

.doctor-sign {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* Odontograma Placeholder */
.odontograma-placeholder {
    height: 400px;
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
    gap: 1rem;
}

.odontograma-placeholder i {
    font-size: 4rem;
    color: rgba(255, 255, 255, 0.05);
}

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

/* Gráficas y Pagos */
.activity-overview {
    grid-column: span 2;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.chart-container {
    height: 200px;
    margin-bottom: 2rem;
    border-radius: var(--border-radius-md);
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-placeholder {
    color: var(--text-muted);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.chart-placeholder i {
    font-size: 2.5rem;
    opacity: 0.5;
}

.recent-payments h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.payment-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: var(--border-radius-md);
    background: rgba(255, 255, 255, 0.02);
    margin-bottom: 0.5rem;
}

.payment-item i {
    font-size: 1.5rem;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-card {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}

.icon-cash {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-color);
}

.pay-details {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.pay-details span {
    font-weight: 500;
    font-size: 0.95rem;
}

.pay-details small {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 0.2rem;
}

.pay-amount {
    font-size: 1.1rem;
    color: var(--status-success);
}
/* =========================================
   ESTILOS ESPECÍFICOS DEL ODONTOGRAMA
   ========================================= */
.odontograma-canvas {
    background: #ffffff;
    border-radius: var(--border-radius-md);
    padding: 2.5rem 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: auto;
    border: 1px solid var(--glass-border);
    margin: 1.5rem 0;
    min-height: 250px;
}

#svg-odontograma-adulto {
    max-width: 100%;
    height: auto;
}

/* Base del Diente */
.diente {
    cursor: pointer;
    transition: var(--transition-fast);
}

.diente:hover .cara {
    stroke: var(--primary-color);
    stroke-width: 1.5px;
}

/* Caras del Diente */
.cara {
    fill: #ffffff;
    stroke: #94a3b8;
    stroke-width: 0.8px;
    transition: all 0.3s ease;
}

.cara:hover {
    filter: brightness(0.9);
}

.diente-num {
    font-size: 11px;
    font-weight: 700;
    fill: var(--text-muted);
    font-family: var(--font-family);
    pointer-events: none;
}

/* Herramientas Clínicas */
.clinical-tools {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1.5rem;
    margin-top: 2rem;
}

.tool-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

.vita-select {
    background: var(--bg-darker);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.75rem;
    border-radius: var(--border-radius-sm);
    outline: none;
}

.notes-area {
    background: var(--bg-darker);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 1rem;
    border-radius: var(--border-radius-md);
    min-height: 80px;
    resize: vertical;
    font-family: var(--font-family);
}

/* =========================================
   PESTAÑAS DEL HUB (TABS)
   ========================================= */
.hub-tabs {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 100px;
    margin-bottom: 2rem;
    overflow-x: auto;
    border: 1px solid var(--glass-border);
}

.tab-btn {
    padding: 0.75rem 1.25rem;
    border-radius: 100px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.tab-btn i {
    font-size: 1.1rem;
}

.tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    background: var(--primary-color);
    color: white;
}

.tab-pane {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.tab-pane.active {
    display: block;
}

/* Ajustes adicionales para Ficha Clínica */
.patient-workspace {
    flex-grow: 1;
    padding: 2rem;
    overflow-y: auto;
}

.pane-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1rem;
}

/* =========================================
   BOTTOM NAVIGATION BAR (MOBILE)
   ========================================= */
.bottom-nav {
    display: none; /* Hidden on desktop */
}

/* =========================================
   RESPONSIVE: TABLETS (max-width: 1023px)
   ========================================= */
@media (max-width: 1023px) {

    /* --- Layout Principal --- */
    .app-container {
        flex-direction: column;
        padding: 0;
        gap: 0;
        height: auto;
        min-height: 100vh;
    }

    /* --- Ocultar Sidebar --- */
    .sidebar {
        display: none !important;
    }

    /* --- Contenido Principal --- */
    .main-content {
        padding: 1rem;
        padding-bottom: 100px; /* espacio para bottom nav */
        gap: 1rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* --- Topbar --- */
    .topbar {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .search-bar {
        width: 100%;
        max-width: 100%;
        order: 2;
    }

    .topbar-actions {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* --- Dashboard Grid --- */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .activity-overview {
        grid-column: span 1;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-icon {
        width: 48px;
        height: 48px;
        font-size: 1.5rem;
    }

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

    /* --- Ficha Clínica del Paciente --- */
    .patient-hub {
        flex-direction: column;
        overflow: visible;
    }

    .patient-profile {
        width: 100%;
        flex-shrink: initial;
    }

    .patient-workspace {
        padding: 1rem;
    }

    .profile-header {
        flex-direction: row;
        text-align: left;
        gap: 1rem;
    }

    .patient-avatar {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
        margin-bottom: 0;
        flex-shrink: 0;
    }

    .financial-summary {
        grid-template-columns: 1fr 1fr;
    }

    /* --- Tabs (Pestañas) --- */
    .hub-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-wrap: nowrap;
        padding: 0.4rem;
        gap: 0.25rem;
    }

    .hub-tabs::-webkit-scrollbar {
        display: none;
    }

    .tab-btn {
        padding: 0.6rem 0.9rem;
        font-size: 0.78rem;
        min-width: max-content;
    }

    .tab-btn i {
        font-size: 1rem;
    }

    .tab-content {
        padding: 1rem;
    }

    /* --- Tablas Genéricas (scroll horizontal) --- */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    thead, tbody, tr, th, td {
        display: revert; /* Mantener estructura de tabla */
    }

    th, td {
        padding: 0.6rem 0.75rem;
        font-size: 0.82rem;
    }

    /* --- Contenedores con overflow de tablas --- */
    .table-responsive,
    [style*="overflow-x"] {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* --- Herramientas Clínicas (Odontograma) --- */
    .clinical-tools {
        grid-template-columns: 1fr;
    }

    .odontograma-canvas {
        padding: 1rem 0.5rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .odontograma-placeholder {
        height: 250px;
    }

    /* --- Modales / Popups --- */
    .modal-content,
    .modal-body,
    [class*="modal"] > div {
        width: 95% !important;
        max-width: 600px !important;
        max-height: 90vh;
        overflow-y: auto;
        margin: auto;
    }

    /* --- Formularios Generales --- */
    input, select, textarea {
        font-size: 16px !important; /* Previene zoom en iOS */
    }

    /* --- Botones --- */
    .btn-primary {
        padding: 0.65rem 1.2rem;
        font-size: 0.9rem;
    }

    .btn-icon {
        width: 40px;
        height: 40px;
    }

    /* --- Gráficas --- */
    .chart-container {
        height: 180px;
    }

    /* --- Pagos y Listados --- */
    .payment-item {
        padding: 0.75rem;
    }

    .payment-item i {
        width: 38px;
        height: 38px;
        font-size: 1.2rem;
    }

    /* --- Agenda Appointments --- */
    .appointment-list {
        gap: 0.75rem;
    }

    .appointment-item {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    /* --- Secciones de Encabezado --- */
    .section-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .pane-header {
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-bottom: 1rem;
    }

    /* --- Bottom Navigation Visible --- */
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        justify-content: space-around;
        align-items: center;
        padding: 0.5rem 0.5rem calc(0.5rem + env(safe-area-inset-bottom));
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        z-index: 9999;
        border-top: 1px solid rgba(0, 53, 95, 0.08);
        box-shadow: 0 -4px 20px rgba(0, 53, 95, 0.06);
    }

    .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        color: var(--text-outline);
        padding: 0.4rem 0.75rem;
        border-radius: var(--border-radius-md);
        transition: all 0.25s ease;
        min-width: 56px;
    }

    .bottom-nav-item .material-symbols-outlined {
        font-size: 24px;
        line-height: 1;
    }

    .bottom-nav-item span:last-child {
        font-size: 0.6rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-top: 2px;
    }

    .bottom-nav-item.active {
        color: var(--primary-color);
        background: rgba(0, 53, 95, 0.08);
    }

    .bottom-nav-item.active .material-symbols-outlined {
        font-variation-settings: 'FILL' 1;
    }
}

/* =========================================
   RESPONSIVE: MÓVILES PEQUEÑOS (max-width: 480px)
   ========================================= */
@media (max-width: 480px) {

    .main-content {
        padding: 0.75rem;
        padding-bottom: 100px;
        gap: 0.75rem;
    }

    .topbar {
        gap: 0.5rem;
    }

    .search-bar {
        padding: 0.6rem 1rem;
    }

    /* Tarjetas de estadísticas más compactas */
    .stat-card {
        padding: 0.85rem;
        gap: 0.85rem;
    }

    .stat-icon {
        width: 42px;
        height: 42px;
        font-size: 1.25rem;
    }

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

    .stat-title {
        font-size: 0.78rem;
    }

    /* Perfil paciente compacto */
    .patient-avatar {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }

    .patient-name {
        font-size: 1.05rem;
    }

    .financial-summary {
        grid-template-columns: 1fr;
    }

    /* Tabs aún más compactas */
    .tab-btn {
        padding: 0.5rem 0.7rem;
        font-size: 0.72rem;
        gap: 0.3rem;
    }

    .tab-btn i {
        font-size: 0.9rem;
    }

    /* Listados */
    .appointment-item {
        flex-wrap: wrap;
    }

    .time {
        min-width: auto;
        font-size: 0.85rem;
    }

    .status-badge {
        font-size: 0.65rem;
        padding: 0.2rem 0.5rem;
    }

    /* Section headers stack */
    .section-header h2 {
        font-size: 0.95rem;
    }

    .pane-header h2,
    .pane-header h3 {
        font-size: 0.95rem;
    }

    /* Botones más touch-friendly */
    .btn-primary {
        padding: 0.7rem 1rem;
        font-size: 0.85rem;
        width: 100%;
        justify-content: center;
    }

    /* Bottom nav más compacta */
    .bottom-nav-item {
        padding: 0.35rem 0.5rem;
        min-width: 48px;
    }

    .bottom-nav-item .material-symbols-outlined {
        font-size: 22px;
    }

    .bottom-nav-item span:last-child {
        font-size: 0.55rem;
    }
}
