/* ═══════════════════════════════════════════════
   GESTIÓN BIOEQUIPAMIENTO — DESIGN SYSTEM
   Clínica Limatambo · v2.0
   ═══════════════════════════════════════════════ */

/* ── TOKENS ─────────────────────────────────── */
:root {
    --primary:       #C20000;
    --primary-dark:  #9A0000;
    --primary-light: rgba(194,0,0,0.08);
    --blue-dark:     #1565C0;
    --blue:          #1E88E5;
    --green:         #2E7D32;
    --red-alert:     #D32F2F;
    --yellow:        #F9A825;
    --gray-bg:       #F5F7FA;
    --gray-text:     #818161;
    --gray-border:   #E0E0E0;
    --white:         #FFFFFF;
    --text-primary:  #1A1A2E;
    --text-secondary:#555;
    --sidebar-w:     250px;
    --topbar-h:      60px;
    --radius:        10px;
    --radius-sm:     6px;
    --shadow-sm:     0 2px 8px rgba(0,0,0,0.07);
    --shadow-md:     0 4px 16px rgba(0,0,0,0.10);
    
    /* SIDEBAR MEDICAL THEME - PREMIUM DEEP BLUE */
    --sidebar-bg:     #002447;
    --sidebar-text:   #cbd5e1;
    --sidebar-label:  #64748b;
    --sidebar-hover:  rgba(255,255,255,0.06);
    --sidebar-active: #D60A17;
}

/* ── RESET & BASE ───────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    font-size: 14px;
    background: var(--gray-bg);
    color: var(--text-primary);
    margin: 0;
    line-height: 1.5;
}

/* ── LAYOUT ─────────────────────────────────── */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── SIDEBAR ────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w) !important;
    background: var(--sidebar-bg) !important;
    display: flex !important;
    flex-direction: column !important;
    border-right: none !important;
    z-index: 200 !important;
    flex-shrink: 0 !important;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25) !important;
    height: 100vh !important;
    overflow: hidden !important;
}

.sidebar-brand-centered {
    padding: 32px 20px 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1.5px solid rgba(255, 255, 255, 0.06);
    margin-bottom: 12px;
}

.sidebar-logo-svg-container {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.nav-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--sidebar-label);
    padding: 18px 24px 8px;
    font-family: 'Inter', sans-serif;
    opacity: 0.85;
}

.nav-item {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    padding: 10px 18px !important;
    color: rgba(255, 255, 255, 0.75) !important;
    text-decoration: none !important;
    font-size: 13.5px !important;
    font-weight: 500 !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    cursor: pointer !important;
    background: none !important;
    border: none !important;
    width: auto !important;
    margin: 4px 14px !important;
    border-radius: 8px !important;
    text-align: left !important;
}

.nav-item i {
    font-size: 18px;
    width: 24px;
    text-align: center;
    color: inherit;
    transition: transform 0.2s ease;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05) !important;
    color: white !important;
}

.nav-item:hover i {
    transform: scale(1.05);
}

.nav-item.active, .nav-link.active {
    background: var(--sidebar-active) !important;
    color: white !important;
    font-weight: 600 !important;
    box-shadow: 0 4px 15px rgba(214, 10, 23, 0.35) !important;
}

.nav-item.active i, .nav-link.active i {
    color: white !important;
}

/* Bottom User Profile Section */
.sidebar-user-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.12);
    border-top: 1.5px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.user-profile-left {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
}

.user-avatar-circle {
    width: 38px;
    height: 38px;
    background: var(--sidebar-active);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

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

.user-name-bottom {
    font-weight: 600;
    font-size: 13.5px;
    color: white;
    line-height: 1.2;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.user-email-bottom {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.45);
    line-height: 1.2;
    margin-top: 3px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.sidebar-logout-btn {
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.4);
    transition: color 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.sidebar-logout-btn:hover {
    color: white;
    transform: translateX(2px);
}

.nav-divider {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    margin: 8px 24px;
}

/* ── MAIN CONTENT ───────────────────────────── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ── TOPBAR ─────────────────────────────────── */
.topbar {
    height: var(--topbar-h);
    background: var(--white);
    border-bottom: 1px solid var(--gray-border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    justify-content: space-between;
    flex-shrink: 0;
    gap: 16px;
}

.topbar-breadcrumb {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.topbar-breadcrumb span.current { color: var(--text-primary); font-weight: 600; }
.topbar-breadcrumb .sep { color: #ccc; }

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

.topbar-icon-btn {
    width: 36px; height: 36px;
    border: none; background: var(--gray-bg);
    border-radius: 50%; display: flex;
    align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-secondary);
    font-size: 16px;
    transition: all 0.15s;
    position: relative;
}

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

.notif-badge {
    position: absolute; top: -2px; right: -2px;
    width: 16px; height: 16px; background: var(--primary);
    border-radius: 50%; font-size: 9px; color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
}

.topbar-user-btn {
    display: flex; align-items: center; gap: 8px;
    cursor: pointer; padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
    border: none; background: none;
}

.topbar-user-btn:hover { background: var(--gray-bg); }

.topbar-avatar {
    width: 32px; height: 32px;
    background: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 14px;
}

/* ── PAGE CONTENT ───────────────────────────── */
.content-area {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title { font-size: 24px; font-weight: 700; color: var(--text-primary); margin: 0; }
.page-subtitle { font-size: 13px; color: var(--text-secondary); margin: 4px 0 0; }

.breadcrumb-nav {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    display: flex; gap: 6px; align-items: center;
}

.breadcrumb-nav a { color: var(--text-secondary); text-decoration: none; }
.breadcrumb-nav a:hover { color: var(--primary); }
.breadcrumb-nav .current { color: var(--text-primary); font-weight: 500; }

/* ── CARDS ──────────────────────────────────── */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px 24px;
    margin-bottom: 20px;
    border: 1px solid var(--gray-border);
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--gray-border);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── KPI CARDS ──────────────────────────────── */
.kpi-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-border);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi-icon { font-size: 28px; }
.kpi-value { font-size: 28px; font-weight: 700; line-height: 1; }
.kpi-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.kpi-sub { font-size: 11px; margin-top: 6px; }

.kpi-green  .kpi-value { color: var(--green); }
.kpi-green  .kpi-icon  { color: var(--green); }
.kpi-red    .kpi-value { color: var(--red-alert); }
.kpi-red    .kpi-icon  { color: var(--red-alert); }
.kpi-yellow .kpi-value { color: var(--yellow); }
.kpi-yellow .kpi-icon  { color: var(--yellow); }
.kpi-blue   .kpi-value { color: var(--blue); }
.kpi-blue   .kpi-icon  { color: var(--blue); }

/* ── TABLE ──────────────────────────────────── */
.table-container {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-border);
    overflow: hidden;
}

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

.table th {
    background: #C20000;
    color: white;
    font-weight: 600;
    font-size: 13px;
    padding: 11px 14px;
    text-align: left;
    white-space: nowrap;
}

.table td {
    padding: 11px 14px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
    vertical-align: middle;
    color: var(--text-primary);
}

.table tbody tr:hover { background: rgba(194,0,0,0.02); }
.table tbody tr:last-child td { border-bottom: none; }

/* ── BADGES ─────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-operativo       { background: rgba(46,125,50,0.12); color: #2E7D32; }
.badge-fuera-servicio  { background: rgba(211,47,47,0.12); color: #D32F2F; }
.badge-mantenimiento   { background: rgba(249,168,37,0.15); color: #E65100; }
.badge-baja            { background: rgba(120,120,120,0.12); color: #555; }
.badge-calibracion     { background: rgba(30,136,229,0.12); color: #1565C0; }

.badge-critica  { background: #D32F2F; color: white; }
.badge-alta     { background: rgba(249,168,37,0.2); color: #E65100; border: 1px solid #F9A825; }
.badge-media    { background: rgba(249,168,37,0.1); color: #F57F17; }
.badge-baja-p   { background: rgba(46,125,50,0.1); color: #2E7D32; }

.badge-abierta     { background: rgba(211,47,47,0.12); color: #D32F2F; }
.badge-en-proceso  { background: rgba(249,168,37,0.15); color: #E65100; }
.badge-cerrada     { background: rgba(46,125,50,0.12); color: #2E7D32; }
.badge-resuelta    { background: rgba(46,125,50,0.12); color: #2E7D32; }

.badge-vigente     { background: rgba(46,125,50,0.1); color: #2E7D32; }
.badge-por-vencer  { background: rgba(249,168,37,0.15); color: #E65100; }
.badge-vencido     { background: rgba(211,47,47,0.12); color: #D32F2F; }

.badge-preventivo  { background: rgba(30,136,229,0.12); color: #1565C0; }
.badge-correctivo  { background: rgba(211,47,47,0.12); color: #D32F2F; }
.badge-predictivo  { background: rgba(46,125,50,0.12); color: #2E7D32; }

/* ── BUTTONS ─────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 18px;
    border-radius: 6px;
    border: none;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary        { background: var(--primary); color: white; }
.btn-primary:hover  { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(194,0,0,0.3); }

.btn-secondary        { background: #1E88E5; color: white; }
.btn-secondary:hover  { background: #1565C0; }

.btn-outline          { background: transparent; border: 1.5px solid var(--gray-border); color: var(--text-primary); }
.btn-outline:hover    { border-color: var(--primary); color: var(--primary); }

.btn-outline-primary  { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: white; }

.btn-danger           { background: var(--red-alert); color: white; }
.btn-danger:hover     { background: #b71c1c; }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-icon { padding: 6px 10px; }

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

/* ── FORMS ───────────────────────────────────── */
.form-label { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 5px; display: block; }

.form-control, .form-select {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--gray-border);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    color: var(--text-primary);
    background: white;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: #1E88E5;
    box-shadow: 0 0 0 3px rgba(30,136,229,0.15);
}

.form-control.is-invalid { border-color: var(--red-alert); }

.input-search {
    position: relative;
}

.input-search i {
    position: absolute;
    left: 10px; top: 50%;
    transform: translateY(-50%);
    color: #aaa; font-size: 14px;
}

.input-search input { padding-left: 32px; }

/* ── FILTER BAR ──────────────────────────────── */
.filter-bar {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--gray-border);
    padding: 14px 18px;
    margin-bottom: 16px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

/* ── PAGINATION ──────────────────────────────── */
.pagination {
    display: flex; align-items: center; gap: 6px;
    padding: 12px 16px;
    border-top: 1px solid var(--gray-border);
    font-size: 13px;
}

.page-info { color: var(--text-secondary); flex: 1; }

.page-btn {
    width: 30px; height: 30px;
    border: 1.5px solid var(--gray-border);
    border-radius: var(--radius-sm);
    background: white;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
    transition: all 0.15s;
}

.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── MODALS ──────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}

.modal-box {
    background: white;
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-16px) scale(0.97); }
    to   { opacity: 1; transform: none; }
}

.modal-header {
    background: var(--primary);
    color: white;
    padding: 16px 24px;
    border-radius: var(--radius) var(--radius) 0 0;
    display: flex; align-items: center; justify-content: space-between;
}

.modal-title { font-size: 16px; font-weight: 700; }

.modal-close {
    background: none; border: none; color: white;
    cursor: pointer; font-size: 20px;
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    opacity: 0.8;
    transition: opacity 0.15s;
}

.modal-close:hover { opacity: 1; background: rgba(255,255,255,0.2); }

.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-border);
    display: flex; justify-content: flex-end; gap: 10px;
}

/* ── ALERTS & BANNERS ────────────────────────── */
.alert-banner {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-left: 4px solid;
}

.alert-danger-light  { background: rgba(211,47,47,0.06);  border-left-color: var(--red-alert); color: #8B0000; }
.alert-warning-light { background: rgba(249,168,37,0.10); border-left-color: var(--yellow);   color: #663300; }
.alert-success-light { background: rgba(46,125,50,0.08);  border-left-color: var(--green);    color: #1B5E20; }
.alert-info-light    { background: rgba(30,136,229,0.08); border-left-color: var(--blue);     color: #0D47A1; }

/* ── DETAIL INFO GRID ────────────────────────── */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.info-item label { font-size: 11px; color: var(--text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; display: block; margin-bottom: 2px; }
.info-item span  { font-size: 14px; color: var(--text-primary); font-weight: 500; }

/* ── TABS ────────────────────────────────────── */
.tab-bar {
    display: flex;
    border-bottom: 2px solid var(--gray-border);
    margin-bottom: 20px;
    gap: 0;
}

.tab-btn {
    padding: 10px 18px;
    border: none; background: none;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
    white-space: nowrap;
}

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

/* ── ACTION ICONS ────────────────────────────── */
.action-btn {
    width: 30px; height: 30px;
    border: none; border-radius: var(--radius-sm);
    background: var(--gray-bg);
    color: var(--text-secondary);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.15s;
}

.action-btn:hover { background: var(--primary-light); color: var(--primary); }
.action-btn.danger:hover { background: rgba(211,47,47,0.1); color: var(--red-alert); }

/* ── SPINNER ─────────────────────────────────── */
.spinner-center {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 60px 20px; gap: 12px;
    color: var(--text-secondary);
}

.spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--gray-border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── EMPTY STATE ─────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state i { font-size: 48px; color: #d0d0d0; margin-bottom: 12px; display: block; }
.empty-state h5 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.empty-state p { font-size: 13px; margin: 0; }

/* ── BLAZOR ERROR UI ─────────────────────────── */
#blazor-error-ui {
    background: #fff3cd;
    border-top: 2px solid #ffc107;
    bottom: 0; left: 0;
    padding: 10px 20px;
    position: fixed; width: 100%;
    z-index: 9999;
    display: none;
    font-size: 13px;
}

/* ── RESPONSIVE ──────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { width: 0; overflow: hidden; position: absolute; height: 100%; }
    .sidebar.open { width: var(--sidebar-w); }
    .content-area { padding: 16px; }
    .page-header { flex-direction: column; }
}
