/**
 * Dental Theme - Estilos Especializados para Clínica Odontológica
 * Tipografía Moderna, Compacta y 100% Responsiva (Celulares, Tablets, Laptops y Pantallas Grandes)
 */

/* Escala Tipográfica Base Responsiva */
html {
    font-size: 13.5px; /* Celulares (< 768px) */
    -webkit-text-size-adjust: 100%;
}

@media (min-width: 768px) {
    html {
        font-size: 14px; /* Tablets (768px - 991.98px) */
    }
}

@media (min-width: 992px) {
    html {
        font-size: 14.5px; /* Laptops y escritorios estándar */
    }
}

@media (min-width: 1400px) {
    html {
        font-size: 15px; /* Pantallas grandes / Monitores amplios */
    }
}

:root {
    --dental-primary: #0284c7;
    --dental-primary-dark: #0369a1;
    --dental-primary-light: #e0f2fe;
    --dental-secondary: #06b6d4;
    --dental-accent: #0d9488;
    --dental-success: #10b981;
    --dental-warning: #f59e0b;
    --dental-danger: #ef4444;
    --dental-surface: #ffffff;
    --dental-bg: #f8fafc;
    --dental-text: #1e293b;
    --dental-muted: #64748b;
    --dental-border: #e2e8f0;
    --dental-radius: 12px;
    --dental-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.06);
    --dental-sidebar-width: 255px;
    --dental-navbar-height: 56px;
}

body {
    background-color: var(--dental-bg);
    color: var(--dental-text);
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    font-size: 0.915rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Jerarquía de Títulos Proporcional */
h1, .h1 { font-size: 1.45rem; font-weight: 700; line-height: 1.25; }
h2, .h2 { font-size: 1.25rem; font-weight: 700; line-height: 1.3; }
h3, .h3 { font-size: 1.12rem; font-weight: 600; line-height: 1.35; }
h4, .h4 { font-size: 1.02rem; font-weight: 600; line-height: 1.4; }
h5, .h5 { font-size: 0.92rem; font-weight: 600; line-height: 1.4; }
h6, .h6 { font-size: 0.82rem; font-weight: 600; line-height: 1.4; }

/* Sidebar Estilo Clínico */
.app-sidebar {
    width: var(--dental-sidebar-width);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    background: #ffffff;
    border-right: 1px solid var(--dental-border);
    z-index: 1035;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.02);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand {
    padding: 0.9rem 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--dental-border);
    background: linear-gradient(135deg, #f0fdf4 0%, #f0f9ff 100%);
}

.sidebar-brand-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1.5px solid var(--dental-primary);
    background: transparent;
    color: var(--dental-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
    padding: 2px;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.15);
}

.sidebar-brand-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
    background: transparent;
}

.sidebar-brand-text {
    font-weight: 700;
    font-size: 0.94rem;
    color: #0f172a;
    line-height: 1.2;
}

.sidebar-brand-sub {
    font-size: 0.68rem;
    color: var(--dental-primary);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-weight: 600;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0.65rem;
}

.nav-header {
    font-size: 0.69rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #5e718d;
    font-weight: 700;
    padding: 0.65rem 0.65rem 0.25rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.46rem 0.75rem;
    color: #334155;
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.855rem;
    font-weight: 500;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.15s ease;
    margin-bottom: 0.2rem;
}

.sidebar-link i {
    font-size: 1.15rem;
    color: #64748b;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.sidebar-link:hover {
    background-color: #f0f9ff;
    color: var(--dental-primary);
}

.sidebar-link:hover i {
    color: var(--dental-primary);
}

.sidebar-link.active {
    background: linear-gradient(135deg, var(--dental-primary) 0%, var(--dental-secondary) 100%);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
}

.sidebar-link.active i {
    color: #ffffff;
}

.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--dental-border);
    background: #f8fafc;
}

/* Navbar Superior */
.app-navbar {
    height: var(--dental-navbar-height);
    position: fixed;
    top: 0;
    right: 0;
    left: var(--dental-sidebar-width);
    background: #ffffff;
    border-bottom: 1px solid var(--dental-border);
    z-index: 1020;
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.02);
    transition: left 0.25s ease;
}

/* Main Container */
.app-main {
    margin-left: var(--dental-sidebar-width);
    margin-top: var(--dental-navbar-height);
    min-height: calc(100vh - var(--dental-navbar-height));
    background-color: var(--dental-bg);
    padding: 1.25rem 1.5rem;
    transition: margin-left 0.25s ease;
}

/* Cards Clínicas */
.card-dental {
    background: #ffffff;
    border-radius: var(--dental-radius);
    border: 1px solid var(--dental-border);
    box-shadow: var(--dental-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-dental:hover {
    box-shadow: 0 8px 24px -4px rgba(15, 23, 42, 0.08);
}

.card-header-dental {
    padding: 0.85rem 1.15rem;
    border-bottom: 1px solid var(--dental-border);
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top-left-radius: var(--dental-radius);
    border-top-right-radius: var(--dental-radius);
}

.card-header-dental .card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0;
}

.card-header-dental.primary {
    background: linear-gradient(135deg, var(--dental-primary), var(--dental-primary-dark));
    color: #ffffff;
}

.card-header-dental.primary .card-title {
    color: #ffffff;
}

/* Tarjetas de Métricas (KPIs) */
.kpi-card {
    padding: 0.95rem 1.15rem;
    border-radius: var(--dental-radius);
    background: #ffffff;
    border: 1px solid var(--dental-border);
    box-shadow: var(--dental-shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.kpi-icon-wrapper {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}

.kpi-blue {
    background: #e0f2fe;
    color: #0284c7;
}

.kpi-green {
    background: #dcfce7;
    color: #16a34a;
}

.kpi-purple {
    background: #f3e8ff;
    color: #9333ea;
}

.kpi-amber {
    background: #fef3c7;
    color: #d97706;
}

.kpi-cyan {
    background: #cffafe;
    color: #0891b2;
}

/* Tablas */
.table-dental {
    margin-bottom: 0;
}

.table-dental thead th {
    background-color: #f8fafc;
    color: #475569;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    border-bottom: 1px solid var(--dental-border);
    padding: 0.7rem 0.85rem;
}

.table-dental tbody td {
    padding: 0.7rem 0.85rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--dental-border);
    font-size: 0.85rem;
}

.table-dental tbody tr:hover {
    background-color: #f1f5f9;
}

/* Enlace Interactivo de Paciente a Ficha Clínica */
.paciente-link,
.table-dental td .paciente-link {
    color: #0F172A;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-block;
}

.paciente-link:hover,
.table-dental td .paciente-link:hover {
    color: #0284C7;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.paciente-link:focus-visible,
.table-dental td .paciente-link:focus-visible {
    color: #0284C7;
    text-decoration: underline;
    text-underline-offset: 2px;
    outline: 2px solid rgba(2, 132, 199, 0.4);
    outline-offset: 2px;
    border-radius: 2px;
}


/* Formularios e Inputs */
.form-control, .form-select {
    font-size: 0.85rem;
    padding: 0.42rem 0.75rem;
    border-radius: 8px;
    border-color: #cbd5e1;
}

.form-control:focus, .form-select:focus {
    border-color: var(--dental-primary);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.form-label {
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: #334155;
}

.input-group-text {
    font-size: 0.85rem;
    padding: 0.42rem 0.75rem;
}

/* Botones */
.btn {
    font-size: 0.85rem;
    padding: 0.42rem 0.8rem;
    border-radius: 8px;
    font-weight: 500;
}

.btn-sm {
    font-size: 0.78rem;
    padding: 0.28rem 0.55rem;
    border-radius: 6px;
}

.btn-primary {
    background-color: var(--dental-primary);
    border-color: var(--dental-primary);
}

.btn-primary:hover {
    background-color: var(--dental-primary-dark);
    border-color: var(--dental-primary-dark);
}

.badge {
    font-size: 0.74rem;
    font-weight: 600;
    padding: 0.28rem 0.55rem;
    border-radius: 6px;
}

/* Botones de Acción Uniformes con Icono */
.btn-action-icon {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 0.95rem;
    line-height: 1;
    transition: all 0.15s ease-in-out;
}

.btn-action-icon:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}

/* Modales Clínicos - Fondo sólido blanco garantizado */
.modal {
    --bs-modal-bg: #ffffff;
}

.modal-content {
    background-color: #ffffff !important;
    background: #ffffff !important;
    border-radius: var(--dental-radius);
    border: 1px solid var(--dental-border);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-header {
    background-color: #ffffff !important;
    border-bottom: 1px solid var(--dental-border);
    border-top-left-radius: var(--dental-radius);
    border-top-right-radius: var(--dental-radius);
    padding: 1rem 1.25rem;
}

.modal-body {
    background-color: #ffffff !important;
    padding: 1.25rem;
}

.modal-footer {
    background-color: #f8fafc !important;
    border-top: 1px solid var(--dental-border);
    border-bottom-left-radius: var(--dental-radius);
    border-bottom-right-radius: var(--dental-radius);
    padding: 0.85rem 1.25rem;
}

/* Telón de fondo para Drawer móvil y tablet */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 1030;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
}

/* Adaptabilidad Responsive (Celulares y Tablets) */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }

    .app-sidebar.show {
        transform: translateX(0);
        box-shadow: 8px 0 28px rgba(0, 0, 0, 0.16);
    }

    .app-navbar {
        left: 0;
        padding: 0 1rem;
    }

    .app-main {
        margin-left: 0;
        padding: 1rem;
    }
}

/* Celulares pequeños (< 576px) */
@media (max-width: 575.98px) {
    .app-main {
        padding: 0.85rem 0.5rem;
    }

    .app-navbar {
        padding: 0 0.75rem;
    }
}

/* ==========================================================
   Dashboard Moderno Ultraliviano & Web Performance
   ========================================================== */

/* Hero Banner con Degradado CSS Nativo */
.dashboard-hero {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 40%, #0f172a 100%);
    border-radius: var(--dental-radius);
    color: #ffffff;
    padding: 1.5rem 1.75rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 25px -5px rgba(2, 132, 199, 0.25);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.dashboard-hero::before {
    content: '';
    position: absolute;
    top: -50px;
    right: 180px;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0) 70%);
    pointer-events: none;
}

.dashboard-hero-title {
    font-size: 1.45rem;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 0.35rem;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.dashboard-hero-subtitle {
    font-size: 0.88rem;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 1rem;
}

.dashboard-hero-svg {
    width: 140px;
    height: 140px;
    flex-shrink: 0;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.2));
    transition: transform 0.3s ease;
}

.dashboard-hero-svg:hover {
    transform: scale(1.04);
}

/* Avatares Circulares CSS Puro (0 Peticiones HTTP) */
.avatar-circle {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.74rem;
    flex-shrink: 0;
    text-transform: uppercase;
    user-select: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1.5px solid rgba(255, 255, 255, 0.9);
}

.avatar-blue    { background-color: #e0f2fe; color: #0284c7; }
.avatar-emerald { background-color: #d1fae5; color: #059669; }
.avatar-purple  { background-color: #f3e8ff; color: #7e22ce; }
.avatar-amber   { background-color: #fef3c7; color: #d97706; }
.avatar-rose    { background-color: #ffe4e6; color: #e11d48; }
.avatar-cyan    { background-color: #cffafe; color: #0891b2; }
.avatar-indigo  { background-color: #e0e7ff; color: #4338ca; }

/* Contenedor Chart.js Anti-CLS */
.chart-container-citas {
    position: relative;
    width: 100%;
    height: 230px;
    min-height: 230px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Centro de Dona (Métrica Consolidada) */
.chart-center-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    user-select: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.chart-center-value {
    font-size: 1.85rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.chart-center-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 3px;
    line-height: 1.1;
}

/* Tarjetas de Consultorios / Sillones Dentales */
.sillon-card {
    border: 1px solid var(--dental-border);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    background: #ffffff;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.sillon-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
    border-color: #bae6fd;
}

.sillon-icon-wrap {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f9ff;
    color: #0284c7;
    flex-shrink: 0;
}

.sillon-icon-wrap.ocupado {
    background: #ecfdf5;
    color: #059669;
}

.sillon-icon-wrap.mantenimiento {
    background: #fffbeb;
    color: #d97706;
}

.status-pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.pulse-green {
    background-color: #10b981;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: statusPulse 2s infinite;
}

.pulse-blue {
    background-color: #0284c7;
}

.pulse-amber {
    background-color: #f59e0b;
}

@keyframes statusPulse {
    0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70%  { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Badge de Fecha y Reloj en Tiempo Real (Alto Contraste y Tabular Nums) */
.dashboard-clock-badge {
    background-color: #ffffff;
    color: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    font-size: 0.8125rem;
    font-weight: 600;
}

.clock-badge-text {
    color: #334155;
    letter-spacing: -0.01em;
}

.clock-badge-sep {
    color: #94a3b8;
    margin: 0 4px;
}

.clock-badge-time {
    color: #0369a1;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 767.98px) {
    .dashboard-hero {
        flex-direction: column;
        align-items: flex-start;
        padding: 1.25rem;
    }
    .dashboard-hero-svg {
        display: none;
    }
}
