/* ============================================================
   DENTAL CLINIC CABARETE — Sistema de Gestión
   Diseño basado en Stitch UI: dark sidebar + clean white content
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── CSS Variables ── */
:root {
    --primary:        #1565C0;
    --primary-dark:   #0D47A1;
    --primary-light:  #1976D2;
    --primary-xlight: #E3F2FD;
    --accent:         #00838F;
    --accent-light:   #E0F7FA;
    --success:        #2E7D32;
    --warning:        #E65100;
    --danger:         #C62828;
    --info:           #0277BD;

    --sidebar-bg:     #1A1D21;
    --sidebar-w:      220px;
    --sidebar-text:   #9CA3AF;
    --sidebar-hover:  rgba(255,255,255,0.08);
    --sidebar-active: rgba(21,101,192,0.25);
    --sidebar-active-border: #1565C0;

    --bg:             #F4F6F9;
    --white:          #FFFFFF;
    --border:         #E2E8F0;
    --border-light:   #F1F5F9;
    --text-dark:      #111827;
    --text-mid:       #4B5563;
    --text-light:     #9CA3AF;

    --topbar-h:       60px;
    --radius:         10px;
    --radius-sm:      6px;
    --shadow:         0 1px 4px rgba(0,0,0,0.08);
    --shadow-md:      0 4px 16px rgba(0,0,0,0.10);
    --shadow-lg:      0 8px 32px rgba(0,0,0,0.14);
    --transition:     all 0.2s ease;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text-dark);
    line-height: 1.5;
    min-height: 100vh;
}
a { text-decoration: none; color: var(--primary); transition: var(--transition); }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; }

/* ── Layout ── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    min-height: 100vh;
    position: fixed;
    top: 0; left: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: var(--transition);
    overflow: hidden;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    text-decoration: none;
}
.sidebar-brand-icon {
    width: 36px; height: 36px;
    background: var(--primary);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; color: #fff;
    flex-shrink: 0;
}
.sidebar-brand-text { flex: 1; min-width: 0; }
.sidebar-brand-name {
    font-size: 13px; font-weight: 700;
    color: #fff;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-brand-sub {
    font-size: 11px; color: var(--sidebar-text);
}
.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.nav-item { display: block; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    color: var(--sidebar-text);
    font-size: 13px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: var(--transition);
    border-radius: 0;
    text-decoration: none;
    cursor: pointer;
}
.nav-link i { font-size: 16px; width: 18px; flex-shrink: 0; }
.nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
    text-decoration: none;
}
.nav-link.active {
    background: var(--sidebar-active);
    color: #fff;
    border-left-color: var(--sidebar-active-border);
}
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user {
    display: flex; align-items: center; gap: 10px;
}
.sidebar-user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: #fff;
    flex-shrink: 0;
}
.sidebar-user-name {
    font-size: 12px; font-weight: 600; color: #fff;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: 11px; color: var(--sidebar-text);
}

/* ── Main Content ── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;          /* critical: prevents flex child from overflowing */
    overflow-x: hidden;   /* catch any overflow before it reaches the viewport */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
    height: var(--topbar-h);
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}
.topbar-search {
    flex: 1;
    max-width: 400px;
}
.topbar-search .input-group {
    border-radius: 20px;
    overflow: hidden;
}
.topbar-search .form-control {
    border-radius: 20px 0 0 20px;
    border-right: none;
    background: var(--bg);
    border-color: var(--border);
    font-size: 13px;
    padding: 6px 16px;
}
.topbar-search .form-control:focus {
    box-shadow: none;
    border-color: var(--primary);
    background: #fff;
}
.topbar-search .btn {
    border-radius: 0 20px 20px 0;
    background: var(--bg);
    border-color: var(--border);
    border-left: none;
    color: var(--text-light);
}
.topbar-spacer { flex: 1; }
.topbar-actions {
    display: flex; align-items: center; gap: 8px;
}
.topbar-icon-btn {
    width: 36px; height: 36px;
    border: none; background: none;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-mid);
    font-size: 18px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}
.topbar-icon-btn:hover { background: var(--bg); color: var(--primary); }
.topbar-icon-btn .badge-dot {
    position: absolute; top: 6px; right: 6px;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--danger);
    border: 2px solid #fff;
}
.topbar-user {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}
.topbar-user:hover { background: var(--bg); }
.topbar-user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: #fff;
}
.topbar-user-info { text-align: right; }
.topbar-user-name { font-size: 13px; font-weight: 600; color: var(--text-dark); }
.topbar-user-role { font-size: 11px; color: var(--text-light); }

/* ── Page Content ── */
.page-content {
    flex: 1;
    padding: 24px;
}
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--text-dark); }
.page-subtitle { font-size: 13px; color: var(--text-light); margin-top: 2px; }

/* ── Cards ── */
.card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    background: var(--white);
}
.card-title {
    font-size: 14px; font-weight: 600; color: var(--text-dark);
    margin: 0;
}
.card-body { padding: 20px; }
.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--border-light);
}

/* ── KPI Cards ── */
.kpi-card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi-header { display: flex; align-items: flex-start; justify-content: space-between; }
.kpi-label { font-size: 12px; font-weight: 500; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-icon {
    width: 40px; height: 40px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
}
.kpi-icon.blue   { background: var(--primary-xlight); color: var(--primary); }
.kpi-icon.teal   { background: var(--accent-light); color: var(--accent); }
.kpi-icon.green  { background: #E8F5E9; color: var(--success); }
.kpi-icon.orange { background: #FFF3E0; color: var(--warning); }
.kpi-icon.red    { background: #FFEBEE; color: var(--danger); }

.kpi-value { font-size: 26px; font-weight: 700; color: var(--text-dark); margin: 8px 0 4px; }
.kpi-delta { font-size: 12px; display: flex; align-items: center; gap: 4px; }
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }
.kpi-delta.neutral { color: var(--text-light); }
.kpi-alert { font-size: 12px; color: var(--danger); display: flex; align-items: center; gap: 4px; }

/* ── Tables ── */
.table-responsive { border-radius: var(--radius); overflow: hidden; }
.table { margin: 0; font-size: 13px; }
.table thead th {
    background: var(--border-light);
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-mid);
    border-bottom: 1px solid var(--border);
    padding: 10px 16px;
    white-space: nowrap;
}
.table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-dark);
}
.table tbody tr:hover { background: var(--border-light); }
.table tbody tr:last-child td { border-bottom: none; }

/* ── Patient Avatar ── */
.patient-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: #fff;
    flex-shrink: 0;
}
.patient-name { font-weight: 600; font-size: 13px; }
.patient-id { font-size: 11px; color: var(--text-light); }

/* ── Badges ── */
.badge {
    display: inline-flex; align-items: center;
    padding: 3px 8px; border-radius: 20px;
    font-size: 11px; font-weight: 600;
    line-height: 1.4;
}
.badge-success  { background: #E8F5E9; color: #2E7D32; }
.badge-warning  { background: #FFF8E1; color: #E65100; }
.badge-danger   { background: #FFEBEE; color: #C62828; }
.badge-info     { background: #E3F2FD; color: #0277BD; }
.badge-secondary{ background: #F1F5F9; color: #64748B; }
.badge-primary  { background: var(--primary-xlight); color: var(--primary); }

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 16px;
    font-size: 13px; font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer; transition: var(--transition);
    line-height: 1.4;
    white-space: nowrap;
}
.btn:focus { box-shadow: none; outline: none; }
.btn-primary  { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-secondary{ background: #fff; color: var(--text-mid); border-color: var(--border); }
.btn-secondary:hover{ background: var(--bg); }
.btn-success  { background: var(--success); color: #fff; border-color: var(--success); }
.btn-danger   { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #B71C1C; color: #fff; }
.btn-outline-primary { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }
.btn-icon { padding: 6px 8px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px 24px; font-size: 15px; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; }
.btn-fab {
    position: fixed; bottom: 28px; right: 28px;
    width: 54px; height: 54px; border-radius: 50%;
    background: var(--primary); color: #fff;
    border: none; font-size: 24px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-lg);
    cursor: pointer; transition: var(--transition);
    z-index: 200;
}
.btn-fab:hover { background: var(--primary-dark); transform: scale(1.05); }

/* ── Forms ── */
.form-label { font-size: 12px; font-weight: 600; color: var(--text-mid); margin-bottom: 4px; }

.form-control {
    font-size: 13px; border-radius: var(--radius-sm);
    border-color: var(--border); color: var(--text-dark);
    padding: 7px 12px;
    transition: var(--transition);
}

/* Select: needs extra right padding for the chevron arrow */
.form-select {
    font-size: 13px; border-radius: var(--radius-sm);
    border-color: var(--border); color: var(--text-dark);
    padding: 7px 2.25rem 7px 12px;   /* right=2.25rem leaves room for arrow */
    transition: var(--transition);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%231565C0' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 12px 8px;
    cursor: pointer;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21,101,192,0.12);
    outline: none;
}
.form-floating > .form-control { padding: 16px 12px 6px; }
.form-floating > label { font-size: 12px; color: var(--text-light); }

/* form-select-sm: Bootstrap overrides padding-top/bottom but we keep right padding for arrow */
.form-select-sm {
    padding-right: 2rem !important;
    background-position: right 0.6rem center !important;
    background-size: 11px 7px !important;
}

/* In-table estado select: ensure enough width to show full option text */
.estado-sel { min-width: 108px; }

/* Disabled selects */
.form-select:disabled { opacity: .6; cursor: not-allowed; }

/* ── Modals ── */
.modal-header {
    background: var(--white); border-bottom: 1px solid var(--border);
    padding: 16px 20px;
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--border-light); }
.modal-content { border-radius: var(--radius); border: none; box-shadow: var(--shadow-lg); }
.modal-lg { max-width: 700px; }
.modal-xl { max-width: 900px; }

/* ── Alerts / Flash ── */
.alert {
    border-radius: var(--radius-sm);
    font-size: 13px;
    padding: 10px 14px;
    border: none;
    display: flex; align-items: center; gap: 8px;
}
.alert-success { background: #E8F5E9; color: #2E7D32; }
.alert-danger   { background: #FFEBEE; color: #C62828; }
.alert-warning  { background: #FFF8E1; color: #E65100; }
.alert-info     { background: var(--primary-xlight); color: var(--primary); }

/* ── Agenda / Calendar ── */
.fc .fc-toolbar { padding: 12px; }
.fc .fc-button { border-radius: var(--radius-sm) !important; font-size: 12px !important; }
.fc .fc-button-primary { background: var(--primary) !important; border-color: var(--primary) !important; }
.fc .fc-event {
    border-radius: 4px; border: none;
    font-size: 11px; padding: 2px 4px;
    cursor: pointer;
}
.fc .fc-daygrid-day-number, .fc .fc-col-header-cell-cushion {
    font-size: 12px; color: var(--text-mid);
}
.fc .fc-day-today { background: var(--primary-xlight) !important; }
.fc-theme-standard td, .fc-theme-standard th { border-color: var(--border) !important; }

/* ── Odontogram ── */
.odontogram-container {
    background: #fff; border-radius: var(--radius);
    padding: 20px; overflow-x: auto;
}
.odontogram-arch { display: flex; justify-content: center; align-items: flex-end; gap: 2px; }
.tooth-wrapper { display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.tooth-wrapper:hover .tooth-svg-path { stroke: var(--primary); stroke-width: 2; }
.tooth-num { font-size: 10px; color: var(--text-light); margin-top: 2px; }
.tooth-upper .tooth-num { margin-top: 0; margin-bottom: 2px; order: -1; }
.tooth-svg-path { stroke: #9CA3AF; stroke-width: 1.5; fill: #fff; transition: var(--transition); }
.tooth-state-CARIES     .tooth-svg-path { fill: #FFCDD2; stroke: #C62828; }
.tooth-state-RESTAURADO .tooth-svg-path { fill: #BBDEFB; stroke: #1565C0; }
.tooth-state-EXTRAIDO   .tooth-svg-path { fill: #ECEFF1; stroke: #607D8B; }
.tooth-state-CORONA     .tooth-svg-path { fill: #FFF9C4; stroke: #F9A825; }
.tooth-state-IMPLANTE   .tooth-svg-path { fill: #C8E6C9; stroke: #2E7D32; }
.tooth-state-AUSENTE    .tooth-svg-path { fill: #F5F5F5; stroke: #BDBDBD; stroke-dasharray: 4; }
.tooth-state-TRATAMIENTO .tooth-svg-path { fill: #E8EAF6; stroke: #3949AB; }

.leyenda-dot {
    width: 14px; height: 14px; border-radius: 3px; display: inline-block;
}

/* ── WhatsApp Bot ── */
.chat-bubble {
    max-width: 75%; padding: 10px 14px; border-radius: 12px;
    font-size: 13px; line-height: 1.5; margin-bottom: 8px;
}
.chat-bubble.bot { background: #F1F5F9; border-bottom-left-radius: 3px; }
.chat-bubble.user { background: var(--primary); color: #fff; margin-left: auto; border-bottom-right-radius: 3px; }
.chat-bubble.system { background: var(--accent-light); color: var(--accent); text-align: center; margin: 4px auto; font-size: 11px; border-radius: 20px; padding: 4px 12px; }
.chat-meta { font-size: 10px; color: var(--text-light); margin-top: 4px; }

/* ── Status badges ── */
.status-activo    { background: #E8F5E9; color: #2E7D32; }
.status-inactivo  { background: #F1F5F9; color: #64748B; }
.status-pendiente { background: #FFF8E1; color: #E65100; }
.status-confirmada{ background: var(--primary-xlight); color: var(--primary); }
.status-atendida  { background: #E8F5E9; color: #2E7D32; }
.status-cancelada { background: #FFEBEE; color: #C62828; }
.status-pagada    { background: #E8F5E9; color: #2E7D32; }
.status-parcial   { background: #FFF8E1; color: #E65100; }
.status-anulada   { background: #FFEBEE; color: #C62828; }
.status-borrador  { background: #F1F5F9; color: #64748B; }
.status-emitida   { background: var(--primary-xlight); color: var(--primary); }

/* ── Utility ── */
.text-primary { color: var(--primary) !important; }
.text-muted   { color: var(--text-light) !important; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-12  { font-size: 12px; }
.fs-13  { font-size: 13px; }
.fs-22  { font-size: 22px; }
.rounded-full { border-radius: 50%; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--border-light); }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

/* ── Animations ── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.fade-in-up { animation: fadeInUp 0.25s ease; }

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.pulse { animation: pulse-dot 1.5s ease infinite; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .page-content { padding: 16px; }
    .kpi-card { margin-bottom: 12px; }
}

/* ── Login Page ── */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0D47A1 0%, #0277BD 50%, #00838F 100%);
    display: flex; align-items: center; justify-content: center;
    position: relative;
    overflow: hidden;
}
.login-page::before {
    content: '';
    position: absolute; inset: 0;
    background-image: radial-gradient(circle, rgba(255,255,255,0.04) 1px, transparent 1px);
    background-size: 40px 40px;
}
.login-card {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 40px 36px;
    width: 100%; max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    position: relative;
}
.login-logo {
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 26px; color: #fff;
    margin: 0 auto 16px;
}
.login-title {
    font-size: 22px; font-weight: 700;
    color: var(--primary); text-align: center;
}
.login-subtitle { font-size: 13px; color: var(--text-light); text-align: center; margin-bottom: 28px; }
.login-lang {
    display: flex; justify-content: center; gap: 8px; margin-top: 20px;
}
.login-lang button {
    padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 600;
    border: 1px solid var(--border); background: #fff; cursor: pointer; transition: var(--transition);
}
.login-lang button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.login-footer { text-align: center; font-size: 11px; color: var(--text-light); margin-top: 24px; }

/* ── Tabs ── */
.nav-tabs .nav-link {
    font-size: 13px; font-weight: 500;
    color: var(--text-mid); border: none; border-bottom: 2px solid transparent;
    padding: 10px 16px; border-radius: 0;
}
.nav-tabs .nav-link:hover { color: var(--primary); background: none; border-bottom-color: var(--primary-xlight); }
.nav-tabs .nav-link.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.nav-tabs { border-bottom: 1px solid var(--border); }

/* ── Dropdown actions ── */
.dropdown-menu {
    border-radius: var(--radius-sm);
    border-color: var(--border);
    box-shadow: var(--shadow-md);
    font-size: 13px;
    padding: 6px;
    min-width: 160px;
}
.dropdown-item {
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    display: flex; align-items: center; gap: 8px;
    color: var(--text-dark);
}
.dropdown-item:hover { background: var(--border-light); }
.dropdown-item.text-danger { color: var(--danger); }
.dropdown-item.text-danger:hover { background: #FFEBEE; }

/* ── Permissions Matrix ── */
.perms-table th, .perms-table td { text-align: center; vertical-align: middle; font-size: 12px; }
.perms-table th:first-child, .perms-table td:first-child { text-align: left; }
.perms-check { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }

/* ── Invoice ── */
.invoice-line-row:hover { background: var(--border-light); }
.invoice-total-row { background: var(--primary-xlight); }
.invoice-total-row td { font-weight: 700; color: var(--primary); }

/* ── Print ── */
@media print {
    .sidebar, .topbar, .btn, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ══════════════════════════════════════════
   RESPONSIVE — Mobile / Tablet
   ══════════════════════════════════════════ */

/* Sidebar overlay backdrop */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 999;
    transition: opacity .25s;
}
.sidebar-overlay.show { display: block; }

/* ── Tablet (768–991px) ── */
@media (max-width: 991.98px) {
    .page-content { padding: 16px; }
    .kpi-value { font-size: 20px; }
}

/* ── Mobile (<768px) ── */
@media (max-width: 767.98px) {
    /* Sidebar slides off-screen by default */
    .sidebar {
        left: calc(-1 * var(--sidebar-w));
        z-index: 1001;
        transition: left .28s cubic-bezier(.4,0,.2,1);
    }
    .sidebar.open {
        left: 0;
        box-shadow: 4px 0 32px rgba(0,0,0,0.35);
    }

    /* Main content occupies full width */
    .main-content { margin-left: 0; }

    /* Page content padding */
    .page-content { padding: 12px; }

    /* Page header stacks vertically */
    .page-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 10px;
        margin-bottom: 16px;
    }
    .page-header > *:last-child { width: 100%; }
    .page-title { font-size: 18px; }

    /* KPI cards: 2 per row on phone */
    .kpi-value { font-size: 18px; }

    /* Tables scroll horizontally */
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* Cards: remove border-radius on very narrow */
    .card { border-radius: 8px; }

    /* Topbar */
    .topbar {
        padding: 0 12px;
        gap: 6px;
        overflow: hidden;        /* prevent horizontal bleed */
    }
    .topbar-spacer { display: none; }
    .topbar-actions { gap: 4px; margin-left: auto; }
    /* Hide notification badge text and user name text on mobile */
    .topbar-user-info { display: none !important; }

    /* Odontogram chart scrolls horizontally on mobile */
    .odo-chart-body { overflow-x: auto; -webkit-overflow-scrolling: touch; min-height: 0; }
    .odo-arch-wrap  { min-width: 640px; display: block; }
    /* Side panel stacks below chart on mobile */
    #sidePanel { margin-top: 0; }

    /* Facturación nueva page buttons stack */
    .btn-group-mobile { flex-direction: column; width: 100%; }
    .btn-group-mobile .btn { width: 100%; }

    /* Form groups: full width inputs */
    .form-control, .form-select { font-size: 14px; }

    /* Modals: full width on small phones */
    .modal-dialog { margin: 8px; max-width: calc(100vw - 16px); }

    /* Tabs: scrollable */
    .nav-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .nav-tabs .nav-link { white-space: nowrap; }

    /* Hide non-essential table columns on mobile via utility class */
    .col-hide-xs { display: none !important; }
}

/* ── Very small phones (<480px) ── */
@media (max-width: 479.98px) {
    .page-content { padding: 8px; }
    .odo-arch-wrap { min-width: 560px; }
    .card-body { padding: 14px; }
    .kpi-card { padding: 14px; }
    /* Show icon-only in page header buttons */
    .btn-label-hide { display: none; }
}
