/* ═══════════════════════════════════════════════════════════════════════════
   PORTAL DE LABORATORIO CLÍNICO — Estilos Personalizados
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Paleta principal — tonos médicos */
    --primary: #0d6efd;
    --primary-dark: #0a58ca;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #0d6efd 100%);
    --secondary: #6c757d;
    --accent: #00b4d8;
    --accent-light: #90e0ef;

    /* Fondos */
    --bg-body: #f0f2f5;
    --bg-sidebar: linear-gradient(180deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    --bg-card: #ffffff;
    --bg-card-hover: #f8f9ff;

    /* Textos */
    --text-primary: #1a1a2e;
    --text-secondary: #6c757d;
    --text-light: #adb5bd;
    --text-white: #ffffff;

    /* Estados */
    --success: #198754;
    --success-light: #d1e7dd;
    --danger: #dc3545;
    --danger-light: #f8d7da;
    --warning: #ffc107;
    --warning-light: #fff3cd;
    --info: #0dcaf0;
    --info-light: #cff4fc;

    /* Sombras */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, .1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, .12);
    --shadow-glow: 0 0 20px rgba(13, 110, 253, .15);

    /* Bordes */
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;

    /* Sidebar */
    --sidebar-width: 280px;
    --sidebar-collapsed: 0px;

    /* Transiciones */
    --transition: all .3s cubic-bezier(.4, 0, .2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ─── LOGIN ─────────────────────────────────────────────────────────────── */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f3460 0%, #1a1a2e 50%, #16213e 100%);
    overflow: hidden;
    position: relative;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(13, 110, 253, .15) 0%, transparent 70%);
    top: -100px;
    right: -100px;
    border-radius: 50%;
    animation: float 8s ease-in-out infinite;
}

.login-wrapper::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(0, 180, 216, .1) 0%, transparent 70%);
    bottom: -80px;
    left: -80px;
    border-radius: 50%;
    animation: float 10s ease-in-out infinite reverse;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(-30px) rotate(5deg);
    }
}

.login-card {
    background: rgba(255, 255, 255, .97);
    backdrop-filter: blur(20px);
    border-radius: var(--border-radius-lg);
    padding: 3rem 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg), 0 0 40px rgba(13, 110, 253, .1);
    position: relative;
    z-index: 1;
    animation: slideUp .6s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo .icon-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    box-shadow: 0 4px 15px rgba(13, 110, 253, .3);
}

.login-logo .icon-circle i {
    font-size: 2rem;
    color: white;
}

.login-logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: .25rem;
}

.login-logo p {
    color: var(--text-secondary);
    font-size: .875rem;
}

.login-card .form-control {
    border-radius: var(--border-radius-sm);
    padding: .75rem 1rem;
    border: 2px solid #e9ecef;
    transition: var(--transition);
    font-size: .9rem;
}

.login-card .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, .15);
}

.login-card .btn-primary {
    border-radius: var(--border-radius-sm);
    padding: .75rem;
    font-weight: 600;
    font-size: 1rem;
    background: var(--primary-gradient);
    border: none;
    transition: var(--transition);
}

.login-card .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(13, 110, 253, .35);
}

.login-card .input-group-text {
    border-radius: var(--border-radius-sm) 0 0 var(--border-radius-sm);
    border: 2px solid #e9ecef;
    border-right: none;
    background: #f8f9fa;
}

.login-legal {
    text-align: center;
    font-size: .7rem;
    color: var(--text-light);
    margin-top: 1.5rem;
    line-height: 1.5;
}

/* ─── LAYOUT PRINCIPAL ──────────────────────────────────────────────────── */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ─── SIDEBAR ───────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--text-white);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1050;
    overflow-y: auto;
    transition: var(--transition);
    box-shadow: 4px 0 15px rgba(0, 0, 0, .15);
}

.sidebar-header {
    padding: 1.5rem;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    background: rgba(0, 0, 0, .15);
}

.sidebar-header .logo-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: .5rem;
    box-shadow: 0 4px 15px rgba(13, 110, 253, .3);
}

.sidebar-header .logo-icon i {
    font-size: 1.4rem;
    color: white;
}

.sidebar-header h5 {
    font-size: .95rem;
    font-weight: 700;
    margin-bottom: .1rem;
    letter-spacing: .5px;
}

.sidebar-header small {
    font-size: .7rem;
    color: rgba(255, 255, 255, .5);
}

.sidebar-user {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    display: flex;
    align-items: center;
    gap: .75rem;
}

.sidebar-user .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .85rem;
    flex-shrink: 0;
}

.sidebar-user .user-info {
    overflow: hidden;
}

.sidebar-user .user-info .name {
    font-size: .85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user .user-info .role {
    font-size: .7rem;
    color: var(--accent-light);
}

.sidebar-nav {
    padding: 1rem 0;
}

.sidebar-nav .nav-section {
    padding: .5rem 1.5rem;
    margin-top: .5rem;
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, .35);
    font-weight: 600;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem 1.5rem;
    color: rgba(255, 255, 255, .7);
    text-decoration: none;
    font-size: .85rem;
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.sidebar-nav .nav-link:hover {
    background: rgba(255, 255, 255, .08);
    color: white;
    border-left-color: var(--accent);
}

.sidebar-nav .nav-link.active {
    background: rgba(13, 110, 253, .15);
    color: white;
    border-left-color: var(--primary);
}

.sidebar-nav .nav-link i {
    width: 20px;
    text-align: center;
    font-size: .9rem;
}

/* ─── CONTENIDO PRINCIPAL ───────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    transition: var(--transition);
}

.topbar {
    background: var(--bg-card);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 1040;
}

.topbar .breadcrumb {
    margin: 0;
    background: none;
    font-size: .85rem;
}

.topbar .btn-toggle-sidebar {
    display: none;
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--text-primary);
    cursor: pointer;
}

.content-area {
    padding: 2rem;
}

/* ─── TARJETAS DE MÉTRICAS ──────────────────────────────────────────────── */
.metric-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    border: 1px solid rgba(0, 0, 0, .04);
    position: relative;
    overflow: hidden;
}

.metric-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.metric-card .metric-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: white;
}

.metric-card .metric-icon.bg-primary {
    background: var(--primary-gradient);
}

.metric-card .metric-icon.bg-success {
    background: linear-gradient(135deg, #198754, #20c997);
}

.metric-card .metric-icon.bg-warning {
    background: linear-gradient(135deg, #ffc107, #fd7e14);
}

.metric-card .metric-icon.bg-danger {
    background: linear-gradient(135deg, #dc3545, #e35d6a);
}

.metric-card .metric-icon.bg-info {
    background: linear-gradient(135deg, #0dcaf0, #6610f2);
}

.metric-card .metric-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.metric-card .metric-label {
    font-size: .8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.metric-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(13, 110, 253, .05) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(30px, -30px);
}

/* ─── CARDS GENERALES ───────────────────────────────────────────────────── */
.card-custom {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, .04);
    overflow: hidden;
}

.card-custom .card-header {
    background: none;
    border-bottom: 1px solid #eee;
    padding: 1.25rem 1.5rem;
    font-weight: 600;
    font-size: .95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-custom .card-body {
    padding: 1.5rem;
}

/* ─── TABLAS ────────────────────────────────────────────────────────────── */
.table-custom {
    font-size: .85rem;
}

.table-custom thead th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-secondary);
    border-bottom: 2px solid #dee2e6;
    padding: .75rem 1rem;
    white-space: nowrap;
}

.table-custom tbody td {
    padding: .75rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f0f0f0;
}

.table-custom tbody tr {
    transition: var(--transition);
}

.table-custom tbody tr:hover {
    background: var(--bg-card-hover);
}

/* ─── BADGES ────────────────────────────────────────────────────────────── */
.badge-visto {
    background: var(--success-light);
    color: var(--success);
    padding: .35rem .65rem;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.badge-no-visto {
    background: var(--danger-light);
    color: var(--danger);
    padding: .35rem .65rem;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.badge-enviado {
    background: var(--info-light);
    color: #055160;
    padding: .35rem .65rem;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.badge-reenviado {
    background: var(--warning-light);
    color: #664d03;
    padding: .35rem .65rem;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.badge-active {
    background: var(--success-light);
    color: var(--success);
    padding: .35rem .65rem;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.badge-inactive {
    background: var(--danger-light);
    color: var(--danger);
    padding: .35rem .65rem;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

/* ─── PASSWORD PILL ────────────────────────────────────────────────────── */
.password-pill {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: .2rem .5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: var(--transition);
    max-width: 100%;
}

.password-pill:hover {
    background: #e9ecef;
    border-color: #dee2e6;
}

.password-pill code {
    color: var(--primary);
    font-size: .75rem;
    margin-right: .5rem;
}

.password-pill .action-icon {
    font-size: .85rem;
    color: var(--text-light);
}

.password-pill:hover .action-icon {
    color: var(--text-secondary);
}

/* ─── FORMULARIOS ───────────────────────────────────────────────────────── */
.form-control,
.form-select {
    border-radius: var(--border-radius-sm);
    border: 2px solid #e9ecef;
    padding: .6rem 1rem;
    transition: var(--transition);
    font-size: .875rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, .12);
}

.form-label {
    font-weight: 600;
    font-size: .8rem;
    color: var(--text-primary);
    margin-bottom: .4rem;
}

/* ─── BOTONES ───────────────────────────────────────────────────────────── */
.btn {
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    font-size: .85rem;
    padding: .5rem 1.25rem;
    transition: var(--transition);
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--primary-gradient);
    border: none;
}

.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(13, 110, 253, .3);
    background: var(--primary-gradient);
}

.btn-sm {
    padding: .3rem .75rem;
    font-size: .78rem;
}

.btn-action {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: .8rem;
}

/* ─── PAGINACIÓN ────────────────────────────────────────────────────────── */
.pagination .page-link {
    border-radius: var(--border-radius-sm);
    margin: 0 2px;
    border: none;
    padding: .4rem .75rem;
    font-size: .82rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition);
}

.pagination .page-link:hover {
    background: var(--primary);
    color: white;
}

.pagination .page-item.active .page-link {
    background: var(--primary-gradient);
    border: none;
}

/* ─── BÚSQUEDA ──────────────────────────────────────────────────────────── */
.search-box {
    position: relative;
}

.search-box .search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: .85rem;
}

.search-box input {
    padding-left: 2.75rem;
}

/* ─── PATIENT SEARCH DROPDOWN ───────────────────────────────────────────── */
.patient-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: white;
    border: 2px solid var(--primary);
    border-top: none;
    border-radius: 0 0 var(--border-radius-sm) var(--border-radius-sm);
    max-height: 250px;
    overflow-y: auto;
    z-index: 1060;
    box-shadow: var(--shadow-md);
    display: none;
}

.patient-search-results .patient-item {
    padding: .6rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: var(--transition);
    font-size: .85rem;
}

.patient-search-results .patient-item:hover {
    background: var(--bg-card-hover);
}

.patient-search-results .patient-item .name {
    font-weight: 600;
}

.patient-search-results .patient-item .detail {
    font-size: .75rem;
    color: var(--text-secondary);
}

/* ─── FILE UPLOAD ───────────────────────────────────────────────────────── */
.upload-zone {
    border: 2px dashed #d0d5dd;
    border-radius: var(--border-radius);
    padding: 2.5rem;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
    background: #fafbfc;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(13, 110, 253, .04);
}

.upload-zone i {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: .75rem;
}

.upload-zone p {
    font-size: .85rem;
    color: var(--text-secondary);
    margin-bottom: 0;
}

/* ─── PASSWORD MODAL ────────────────────────────────────────────────────── */
.password-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, .6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.password-overlay.show {
    display: flex;
}

.password-box {
    background: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    animation: slideUp .4s ease-out;
}

/* ─── RESPONSIVE ────────────────────────────────────────────────────────── */

/* Sidebar overlay background for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, .5);
    backdrop-filter: blur(2px);
    z-index: 1049;
}

.sidebar-overlay.show {
    display: block;
}

/* ── Large tablets / small desktops (≤1200px) ── */
@media (max-width: 1200px) {
    :root {
        --sidebar-width: 250px;
    }

    .metric-card .metric-value {
        font-size: 1.5rem;
    }

    .content-area {
        padding: 1.5rem;
    }

    .table-custom thead th,
    .table-custom tbody td {
        padding: .6rem .7rem;
        font-size: .8rem;
    }
}

/* ── Tablets (≤992px) ── */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .topbar .btn-toggle-sidebar {
        display: block;
    }

    .topbar {
        padding: .75rem 1rem;
    }

    .content-area {
        padding: 1rem;
    }

    /* Stack filter rows on tablet */
    .card-custom .card-body .row.g-2>[class*="col-md"] {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Action buttons: show as block on smaller tablet */
    .btn-action {
        width: 30px;
        height: 30px;
        font-size: .75rem;
    }

    /* Cards header flex wrap */
    .card-custom .card-header {
        flex-wrap: wrap;
        gap: .5rem;
        padding: 1rem;
    }

    .card-custom .card-body {
        padding: 1rem;
    }

    /* Metric cards */
    .metric-card {
        padding: 1.1rem;
    }

    .metric-card .metric-icon {
        width: 42px;
        height: 42px;
        font-size: 1.1rem;
    }

    .metric-card .metric-value {
        font-size: 1.4rem;
    }

    .metric-card .metric-label {
        font-size: .75rem;
    }

    /* Upload zone */
    .upload-zone {
        padding: 1.5rem;
    }

    .upload-zone i {
        font-size: 2rem;
    }
}

/* ── Mobile landscape (≤768px) ── */
@media (max-width: 768px) {
    .content-area {
        padding: .75rem;
    }

    .topbar {
        padding: .65rem .75rem;
    }

    .topbar .breadcrumb {
        font-size: .78rem;
    }

    /* Stack all filter columns */
    .card-custom .card-body .row.g-2>[class*="col-md"] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Compact table */
    .table-custom {
        font-size: .78rem;
    }

    .table-custom thead th {
        font-size: .68rem;
        padding: .5rem .5rem;
        letter-spacing: 0;
    }

    .table-custom tbody td {
        padding: .5rem .5rem;
    }

    /* Badges smaller */
    .badge-visto,
    .badge-no-visto,
    .badge-enviado,
    .badge-reenviado,
    .badge-active,
    .badge-inactive {
        font-size: .65rem;
        padding: .25rem .5rem;
    }

    /* Patient detail responsive */
    .col-auto .avatar {
        width: 45px !important;
        height: 45px !important;
        font-size: 1rem !important;
    }

    /* Charts resize */
    canvas {
        max-height: 220px !important;
    }

    /* d-flex gap utilities */
    .d-flex.gap-3 {
        gap: .5rem !important;
    }

    /* Search box */
    .search-box input {
        font-size: .82rem;
    }

    /* Pagination compact */
    .pagination .page-link {
        padding: .3rem .55rem;
        font-size: .75rem;
    }

    /* Metric cards two-column */
    .row.g-3>.col-xl-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Patient result cards full width */
    .row.g-3>.col-lg-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Buttons */
    .btn {
        font-size: .8rem;
        padding: .4rem 1rem;
    }

    .btn-sm {
        padding: .25rem .6rem;
        font-size: .72rem;
    }

    .btn-lg {
        padding: .6rem;
        font-size: .9rem;
    }

    /* Form controls */
    .form-control,
    .form-select {
        font-size: .82rem;
        padding: .5rem .8rem;
    }

    /* Login legal text */
    .login-legal {
        font-size: .65rem;
    }
}

/* ── Mobile portrait (≤576px) ── */
@media (max-width: 576px) {
    body {
        font-size: .85rem;
    }

    .content-area {
        padding: .5rem;
    }

    .topbar {
        padding: .5rem .6rem;
        gap: .25rem;
    }

    .topbar .breadcrumb {
        font-size: .72rem;
    }

    .topbar .text-muted {
        display: none;
    }

    /* Login */
    .login-card {
        margin: .75rem;
        padding: 1.75rem 1.25rem;
        max-width: 100%;
        border-radius: var(--border-radius);
    }

    .login-logo .icon-circle {
        width: 65px;
        height: 65px;
    }

    .login-logo .icon-circle i {
        font-size: 1.6rem;
    }

    .login-logo h1 {
        font-size: 1.25rem;
    }

    .login-logo p {
        font-size: .78rem;
    }

    .login-logo {
        margin-bottom: 1.25rem;
    }

    .login-card .form-control {
        padding: .6rem .8rem;
        font-size: .85rem;
    }

    .login-card .btn-primary {
        padding: .65rem;
        font-size: .9rem;
    }

    /* Sidebar */
    .sidebar {
        width: 260px;
    }

    .sidebar-header {
        padding: 1rem;
    }

    .sidebar-header .logo-icon {
        width: 40px;
        height: 40px;
    }

    .sidebar-header .logo-icon i {
        font-size: 1.1rem;
    }

    .sidebar-header h5 {
        font-size: .85rem;
    }

    .sidebar-user {
        padding: .75rem 1rem;
    }

    .sidebar-nav .nav-link {
        padding: .55rem 1rem;
        font-size: .8rem;
    }

    /* Metric cards single column on very small */
    .row.g-3>.col-xl-3,
    .row.g-3>.col-sm-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .metric-card {
        padding: .85rem;
    }

    .metric-card .metric-value {
        font-size: 1.2rem;
    }

    .metric-card .metric-label {
        font-size: .68rem;
    }

    .metric-card .metric-icon {
        width: 36px;
        height: 36px;
        font-size: .95rem;
    }

    /* Headings */
    h4.fw-bold {
        font-size: 1.1rem;
    }

    h5.fw-bold {
        font-size: 1rem;
    }

    /* Cards */
    .card-custom .card-header {
        padding: .75rem .85rem;
        font-size: .85rem;
    }

    .card-custom .card-body {
        padding: .85rem;
    }

    /* Table: make scrollable with hint */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }

    .table-custom thead th {
        font-size: .63rem;
        padding: .4rem .35rem;
    }

    .table-custom tbody td {
        font-size: .73rem;
        padding: .4rem .35rem;
    }

    /* Action buttons even smaller */
    .btn-action {
        width: 28px;
        height: 28px;
        font-size: .7rem;
        border-radius: 6px;
    }

    /* Upload zone responsive */
    .upload-zone {
        padding: 1.25rem;
    }

    .upload-zone i {
        font-size: 1.8rem;
        margin-bottom: .5rem;
    }

    .upload-zone p {
        font-size: .78rem;
    }

    /* Patient search results */
    .patient-search-results {
        max-height: 180px;
    }

    .patient-search-results .patient-item {
        padding: .5rem .75rem;
        font-size: .8rem;
    }

    /* Charts in metrics */
    canvas {
        max-height: 180px !important;
    }

    /* Alerts compact */
    .alert {
        font-size: .78rem;
        padding: .5rem .75rem;
    }

    /* Row gap reduction */
    .row.g-3 {
        --bs-gutter-y: .5rem;
        --bs-gutter-x: .5rem;
    }

    /* Pagination */
    .pagination .page-link {
        padding: .25rem .45rem;
        font-size: .7rem;
    }

    /* Toast position */
    .toast-container {
        top: .5rem;
        right: .5rem;
        left: .5rem;
    }

    .toast-container .alert {
        min-width: auto !important;
    }
}

/* ── Extra small (≤400px) ── */
@media (max-width: 400px) {
    .login-card {
        margin: .5rem;
        padding: 1.25rem 1rem;
    }

    .login-logo .icon-circle {
        width: 55px;
        height: 55px;
    }

    .login-logo h1 {
        font-size: 1.1rem;
    }

    .sidebar {
        width: 240px;
    }

    /* Single column metric cards */
    .row.g-3>.col-xl-3,
    .row.g-3>.col-sm-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .metric-card {
        padding: .75rem;
        display: flex;
        align-items: center;
        gap: .75rem;
    }

    .metric-card .d-flex {
        margin-bottom: 0 !important;
    }
}

/* ─── MOBILE TABLE CARD VIEW (Tablets & Mobiles) ── */
@media (max-width: 768px) {
    .table-responsive {
        border: none;
    }

    .table-custom thead {
        display: none;
    }

    .table-custom,
    .table-custom tbody,
    .table-custom tr,
    .table-custom td {
        display: block;
        width: 100%;
    }

    .table-custom tr {
        margin-bottom: 1rem;
        background: #fff;
        border-radius: var(--border-radius);
        box-shadow: var(--shadow-sm);
        padding: 1rem;
        border: 1px solid rgba(0, 0, 0, .05);
    }

    .table-custom td {
        text-align: right;
        padding-left: 50% !important;
        position: relative;
        border-bottom: 1px solid #eee;
        padding-top: .75rem;
        padding-bottom: .75rem;
    }

    .table-custom td:last-child {
        border-bottom: 0;
    }

    .table-custom td::before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 45%;
        padding-left: 1rem;
        font-weight: 700;
        font-size: .85rem;
        text-align: left;
        color: var(--text-secondary);
    }
}

/* ─── ANIMACIONES ───────────────────────────────────────────────────────── */
.fade-in {
    animation: fadeIn .5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ─── SCROLLBAR ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* ─── TOAST CONTAINER ───────────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
}

/* ─── SweetAlert2 Premium Styling ────────────────────────────────────── */
.premium-swal-popup {
    border-radius: 1.25rem !important;
    padding: 2rem !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1) !important;
}

.premium-swal-title {
    font-weight: 700 !important;
    color: #2B395E !important;
    font-size: 1.5rem !important;
    margin-bottom: 0.5rem !important;
}

.swal2-html-container {
    color: #6c757d !important;
    font-size: 1rem !important;
}

.swal2-actions {
    gap: 12px !important;
    margin-top: 1.5rem !important;
}