/**
 * Frande One — Compiled Design System
 * ============================================================
 * Main CSS entry point. Loaded in header.php AFTER legacy CSS
 * (app.css, responsive.css) so overrides take effect via cascade.
 *
 * Architecture:
 *   1. variables.css  — Design tokens
 *   2. components.css — UI component styles
 *   3. Bridge section — Overrides for legacy class names used by
 *      existing _nav.php files, sidebar.php, and responsive.css
 * ============================================================
 */

@import url('variables.css');
@import url('components.css');

/* =============================================================
   BRIDGE: Override legacy CSS variables
   Maps old responsive.css/app.css variables to new design tokens.
   ============================================================= */
:root {
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 70px;
    --topbar-height: 60px;
    --primary-color: var(--fo-accent);
    --secondary-color: var(--fo-accent);
}

/* =============================================================
   BRIDGE: Body & Layout
   ============================================================= */
body {
    background-color: var(--fo-body-bg);
    font-family: var(--fo-font-family);
    color: var(--fo-text-primary);
}

.main-content {
    background: var(--fo-body-bg);
}

/* =============================================================
   BRIDGE: Sidebar — Dark Navy (#1B2838)
   Override responsive.css .sidebar.sidebar-dark from #1a56db
   ============================================================= */
.sidebar.sidebar-dark {
    background: var(--fo-sidebar-bg);
}

/* ── Sidebar Header ───────────────────────────────────────── */
.sidebar-header {
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

.sidebar-logo {
    background: rgba(255, 255, 255, 0.08);
}

/* ── Module Selector ──────────────────────────────────────── */
.sidebar-module-selector {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-module-selector:hover {
    background: rgba(255, 255, 255, 0.1);
}

.module-icon {
    background: rgba(var(--fo-accent-rgb), 0.2);
    color: var(--fo-accent);
    box-shadow: none;
}

/* ── Menu Items (used by _nav.php) ────────────────────────── */
.menu-item {
    color: var(--fo-sidebar-text);
    border-left: 3px solid transparent;
    font-size: var(--fo-font-size-base);
    transition: all var(--fo-transition-fast);
}

.menu-item i:first-child {
    color: rgba(255, 255, 255, 0.4);
    transition: color var(--fo-transition-fast);
}

.menu-item:hover {
    color: #d1d9e4;
    background: rgba(255, 255, 255, 0.04);
}

.menu-item:hover i:first-child {
    color: rgba(255, 255, 255, 0.7);
}

.menu-item.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
    border-left-color: var(--fo-accent);
}

.menu-item.active i:first-child {
    color: var(--fo-accent);
}

/* Dropdown header active */
.menu-item.menu-header.active,
.menu-dropdown.open .menu-header {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
}

/* ── Dropdown Items ───────────────────────────────────────── */
.dropdown-item-custom {
    color: rgba(255, 255, 255, 0.55);
    transition: all var(--fo-transition-fast);
}

.dropdown-item-custom i {
    color: rgba(255, 255, 255, 0.3);
}

.dropdown-item-custom:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #d1d9e4;
}

.dropdown-item-custom:hover i {
    color: rgba(255, 255, 255, 0.6);
}

.dropdown-item-custom.active {
    background: rgba(var(--fo-accent-rgb), 0.12);
    color: #ffffff;
}

.dropdown-item-custom.active i {
    color: var(--fo-accent);
}

/* ── Section Dividers & Titles ────────────────────────────── */
.menu-section-divider {
    background: rgba(255, 255, 255, 0.05);
}

.menu-section-title {
    color: rgba(255, 255, 255, 0.3);
    font-weight: var(--fo-font-weight-bold);
    letter-spacing: 0.08em;
}

.menu-divider {
    background: rgba(255, 255, 255, 0.05);
}

/* ── User Panel ───────────────────────────────────────────── */
.sidebar-user-panel {
    border-top-color: rgba(255, 255, 255, 0.06);
}

.user-avatar-sidebar {
    background: rgba(var(--fo-accent-rgb), 0.2);
    color: var(--fo-accent);
}

.user-menu-btn {
    background: rgba(255, 255, 255, 0.06);
}

.user-menu-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

/* ── Flyout & Tooltip (collapsed sidebar) ─────────────────── */
.sidebar-flyout a:hover {
    color: var(--fo-accent);
}

.sidebar-flyout a.active {
    color: var(--fo-accent);
    background: rgba(var(--fo-accent-rgb), 0.08);
}

.sidebar-flyout a:hover i,
.sidebar-flyout a.active i {
    color: var(--fo-accent);
}

/* =============================================================
   BRIDGE: Topbar — White with subtle border
   ============================================================= */
.topbar {
    background: var(--fo-topbar-bg);
    border-bottom: var(--fo-topbar-border);
    box-shadow: var(--fo-topbar-shadow);
    padding: 0 1.25rem;
    height: var(--fo-topbar-height);
    min-height: var(--fo-topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 20;
    margin-bottom: 0;
    gap: 0.75rem;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.topbar-center {
    flex: 1;
    display: flex;
    justify-content: center;
    min-width: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Toggle button */
.topbar-toggle {
    background: none;
    border: none;
    color: var(--fo-text-secondary);
    font-size: 1.15rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--fo-border-radius);
    transition: background var(--fo-transition-fast), color var(--fo-transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
}

.topbar-toggle:hover {
    background: #f1f5f9;
    color: var(--fo-text-primary);
}

/* Page title in topbar */
.topbar-title h1 {
    font-family: var(--fo-font-family);
    font-size: var(--fo-font-size-md);
    font-weight: var(--fo-font-weight-semibold);
    color: var(--fo-text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
    line-height: var(--fo-line-height-tight);
}

.topbar-title h1 i {
    color: var(--fo-accent);
    margin-right: 0.375rem;
    font-size: 0.9em;
}

/* Search wrapper */
.topbar-search-wrap {
    position: relative;
    width: 100%;
    max-width: 360px;
}

.topbar-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--fo-text-muted);
    font-size: var(--fo-font-size-sm);
    pointer-events: none;
}

.fo-search-input {
    border: 1.5px solid var(--fo-border-color);
    border-radius: 20px;
    padding: 0.45rem 1rem 0.45rem 2.25rem;
    font-family: var(--fo-font-family);
    font-size: var(--fo-font-size-sm);
    width: 100%;
    background: #f8fafc;
    color: var(--fo-text-primary);
    transition: all var(--fo-transition-fast);
}

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

.fo-search-input:focus {
    background: #ffffff;
    border-color: var(--fo-accent);
    box-shadow: 0 0 0 3px rgba(var(--fo-accent-rgb), 0.1);
    outline: none;
}

/* Icon buttons in topbar (bell, NCF, cash) */
.topbar-icon-btn {
    background: none;
    border: none;
    color: var(--fo-text-secondary);
    font-size: 1.05rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--fo-border-radius);
    transition: all var(--fo-transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    position: relative;
    text-decoration: none;
}

.topbar-icon-btn:hover {
    background: #f1f5f9;
    color: var(--fo-text-primary);
}

.topbar-icon-btn.topbar-cash-active {
    color: var(--fo-success);
}

.topbar-icon-btn.topbar-cash-active:hover {
    background: rgba(var(--fo-success-rgb), 0.08);
}

/* Topbar badge (notification count, NCF count) */
.topbar-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    font-size: 0.6rem;
    font-weight: var(--fo-font-weight-bold);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

.topbar-badge-warning {
    background: var(--fo-warning);
    color: #1e2a3a;
}

.topbar-badge-danger {
    background: var(--fo-danger);
    color: #ffffff;
}

.topbar-badge-success {
    background: var(--fo-success);
    width: 8px;
    height: 8px;
    min-width: 8px;
    padding: 0;
    top: 8px;
    right: 8px;
}

/* Branch selector button */
.topbar-branch-btn {
    background: #f1f5f9;
    border: 1px solid var(--fo-border-color);
    color: var(--fo-text-secondary);
    font-size: var(--fo-font-size-sm);
    font-weight: var(--fo-font-weight-medium);
    padding: 0.35rem 0.75rem;
    border-radius: var(--fo-border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    transition: all var(--fo-transition-fast);
    white-space: nowrap;
}

.topbar-branch-btn:hover {
    background: #e2e8f0;
    color: var(--fo-text-primary);
}

.topbar-branch-btn::after {
    font-size: 0.6em;
    margin-left: 0.25rem;
}

/* Branch badge (single branch, non-admin) */
.topbar-branch-badge {
    background: #f1f5f9;
    border: 1px solid var(--fo-border-color);
    color: var(--fo-text-secondary);
    font-size: var(--fo-font-size-sm);
    font-weight: var(--fo-font-weight-medium);
    padding: 0.3rem 0.65rem;
    border-radius: var(--fo-border-radius);
    display: flex;
    align-items: center;
    gap: 0.375rem;
    white-space: nowrap;
}

/* Avatar button in topbar */
.topbar-avatar-btn {
    background: none;
    border: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem;
    border-radius: var(--fo-border-radius);
    cursor: pointer;
    transition: background var(--fo-transition-fast);
}

.topbar-avatar-btn:hover {
    background: #f1f5f9;
}

/* Hide Bootstrap caret for avatar */
.topbar-avatar-btn::after {
    display: none;
}

.topbar-user-name {
    font-family: var(--fo-font-family);
    font-size: var(--fo-font-size-sm);
    font-weight: var(--fo-font-weight-medium);
    color: var(--fo-text-primary);
}

/* User dropdown panel */
.topbar-user-dropdown {
    min-width: 220px;
    padding: 0.5rem;
}

.topbar-user-info {
    padding: 0.75rem 0.75rem 0.5rem;
}

.topbar-user-info strong {
    display: block;
    font-size: var(--fo-font-size-base);
    color: var(--fo-text-primary);
}

.topbar-user-info small {
    color: var(--fo-text-muted);
    font-size: var(--fo-font-size-sm);
}

.topbar-logout-item {
    color: var(--fo-danger) !important;
}

.topbar-logout-item:hover {
    background: rgba(var(--fo-danger-rgb), 0.06) !important;
    color: var(--fo-danger) !important;
}

/* =============================================================
   BRIDGE: Cards — White bg, no gradient headers
   ============================================================= */
.card-header {
    background: var(--fo-card-bg);
    color: var(--fo-text-primary);
    border-bottom: 1px solid var(--fo-border-color);
}

.card-header h5 {
    color: var(--fo-text-primary);
}

/* =============================================================
   BRIDGE: Tables — Light header, no gradient
   ============================================================= */
.table thead th {
    background: #f8fafc;
    color: var(--fo-text-secondary);
    border-bottom: 2px solid var(--fo-border-color);
    font-size: var(--fo-font-size-xs);
    font-weight: var(--fo-font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tbody td {
    border-color: #f1f5f9;
    font-size: var(--fo-font-size-base);
}

.table tbody tr:hover {
    background: #f8fafc;
    transform: none;
}

/* =============================================================
   BRIDGE: Modals — Clean, no gradient header
   ============================================================= */
.modal-header {
    background: var(--fo-card-bg);
    color: var(--fo-text-primary);
    border-bottom: 1px solid var(--fo-border-color);
    border-radius: var(--fo-border-radius-xl) var(--fo-border-radius-xl) 0 0;
}

.modal-header .btn-close {
    filter: none;
}

.modal-content {
    border-radius: var(--fo-border-radius-xl);
    box-shadow: var(--fo-shadow-3);
}

.modal-footer {
    background: var(--fo-card-bg);
    border-top: 1px solid var(--fo-border-color);
}

/* =============================================================
   BRIDGE: Buttons — Module accent, no gradient
   ============================================================= */
.btn-primary {
    background: var(--fo-accent);
    border-color: var(--fo-accent);
    box-shadow: 0 2px 4px rgba(var(--fo-accent-rgb), 0.25);
}

.btn-primary:hover,
.btn-primary:active,
.btn-primary:focus {
    background: var(--fo-accent);
    border-color: var(--fo-accent);
    filter: brightness(0.9);
    box-shadow: 0 4px 8px rgba(var(--fo-accent-rgb), 0.3);
    transform: none;
}

/* =============================================================
   BRIDGE: Dropdowns — Override slide effect
   ============================================================= */
.dropdown-item:hover,
.dropdown-item:focus {
    background: #f1f5f9;
    color: var(--fo-text-primary);
    transform: none;
}

.dropdown-item.active,
.dropdown-item:active {
    background: rgba(var(--fo-accent-rgb), 0.1);
    color: var(--fo-accent);
}

/* =============================================================
   BRIDGE: DataTables pagination — use accent
   ============================================================= */
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--fo-accent) !important;
    border-color: var(--fo-accent) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: rgba(var(--fo-accent-rgb), 0.1) !important;
    color: var(--fo-accent) !important;
}

/* =============================================================
   BRIDGE: Scrollbar — Neutral, no gradient
   ============================================================= */
::-webkit-scrollbar-thumb {
    background: var(--fo-border-color);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--fo-text-muted);
}

/* =============================================================
   BRIDGE: Alerts — Softer colors
   ============================================================= */
.alert-success { background-color: #ecfdf5; border-left-color: var(--fo-success); color: #065f46; }
.alert-danger  { background-color: #fef2f2; border-left-color: var(--fo-danger);  color: #991b1b; }
.alert-warning { background-color: #fffbeb; border-left-color: var(--fo-warning); color: #92400e; }
.alert-info    { background-color: #eff6ff; border-left-color: var(--fo-info);    color: #1e40af; }

/* =============================================================
   BRIDGE: Page-level layout integration
   ============================================================= */
.content-wrapper {
    padding: var(--fo-space-5);
    max-width: var(--fo-container-max);
}

/* =============================================================
   BRIDGE: Nav tabs — accent color
   ============================================================= */
.nav-tabs .nav-link.active {
    color: var(--fo-accent);
    border-bottom-color: var(--fo-accent);
}

/* =============================================================
   BRIDGE: Select2 — new border/focus colors
   ============================================================= */
.select2-container--bootstrap-5 .select2-selection {
    border-color: var(--fo-input-border);
}

.select2-container--bootstrap-5.select2-container--focus .select2-selection {
    border-color: var(--fo-accent);
    box-shadow: 0 0 0 3px rgba(var(--fo-accent-rgb), 0.12);
}

/* =============================================================
   BRIDGE: Focus visible — accent outline
   ============================================================= */
*:focus-visible {
    outline: 2px solid var(--fo-accent);
    outline-offset: 2px;
}

/* =============================================================
   BRIDGE: Page header (legacy .page-header class)
   ============================================================= */
.page-header h2 {
    font-family: var(--fo-font-family);
    font-weight: var(--fo-font-weight-semibold);
    color: var(--fo-text-primary);
}

/* =============================================================
   BRIDGE: Mobile cards — accent color
   ============================================================= */
.m-card {
    border-left-color: var(--fo-accent);
}

/* =============================================================
   BRIDGE: Responsive topbar adjustments
   ============================================================= */
@media (max-width: 767.98px) {
    .topbar {
        padding: 0 0.75rem;
        gap: 0.375rem;
    }

    .topbar-title h1 {
        font-size: var(--fo-font-size-base);
        max-width: 160px;
    }

    .topbar-icon-btn {
        width: 36px;
        height: 36px;
        font-size: 0.95rem;
    }
}

@media (max-width: 991.98px) {
    .topbar-title h1 {
        max-width: 200px;
    }
}

/* =============================================================
   PASO 3: COMPONENT MIGRATION — CSS Bridge
   Transform Bootstrap components to Frande One design system
   without modifying HTML in module views.
   ============================================================= */

/* =============================================================
   BRIDGE: Bootstrap Badges → Pastel Design
   Override solid Bootstrap badges to use soft pastel backgrounds
   with high-contrast text (WCAG AA verified).
   ============================================================= */

/* Success / Active / Paid */
.badge.bg-success {
    background-color: #ecfdf5 !important;
    color: #047857 !important;           /* 4.9:1 on #ecfdf5 ✓ */
}

/* Danger / Inactive / Voided */
.badge.bg-danger {
    background-color: #fef2f2 !important;
    color: #b91c1c !important;           /* 5.5:1 on #fef2f2 ✓ */
}

/* Warning / Pending */
.badge.bg-warning {
    background-color: #fff7ed !important;
    color: #b45309 !important;           /* 4.6:1 on #fff7ed ✓ */
}

/* Info */
.badge.bg-info {
    background-color: #eff6ff !important;
    color: #1d4ed8 !important;           /* 5.7:1 on #eff6ff ✓ */
}

/* Secondary / Neutral / Inactive */
.badge.bg-secondary {
    background-color: #f1f5f9 !important;
    color: #475569 !important;           /* 6.5:1 on #f1f5f9 ✓ */
}

/* Primary → uses module accent */
.badge.bg-primary {
    background-color: rgba(var(--fo-accent-rgb), 0.1) !important;
    color: var(--fo-accent) !important;
}

/* Light badge — subtle neutral */
.badge.bg-light {
    background-color: #f8fafc !important;
    color: #475569 !important;
    border: 1px solid var(--fo-border-color);
}

/* Dark badge — keep readable */
.badge.bg-dark {
    background-color: #1e293b !important;
    color: #f1f5f9 !important;
}

/* Override text-dark on warning/info badges (no longer needed with pastel) */
.badge.bg-warning.text-dark,
.badge.bg-info.text-dark {
    color: inherit !important;
}

/* Badge base refinements */
.badge {
    font-size: var(--fo-font-size-xs);
    font-weight: var(--fo-font-weight-semibold);
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    letter-spacing: 0.3px;
    line-height: 1;
}

/* Subtle badge variants — align with design tokens */
.badge.bg-success-subtle { background-color: #ecfdf5 !important; }
.badge.bg-danger-subtle  { background-color: #fef2f2 !important; }
.badge.bg-warning-subtle { background-color: #fff7ed !important; }
.badge.bg-info-subtle    { background-color: #eff6ff !important; }
.badge.bg-secondary-subtle { background-color: #f1f5f9 !important; }
.badge.bg-primary-subtle { background-color: rgba(var(--fo-accent-rgb), 0.08) !important; }

.badge.text-success { color: #047857 !important; }
.badge.text-danger  { color: #b91c1c !important; }
.badge.text-warning { color: #b45309 !important; }
.badge.text-info    { color: #1d4ed8 !important; }

/* =============================================================
   BRIDGE: Card Refinements
   Normalize all card variants to the design system.
   ============================================================= */

/* Cards with shadow-sm (most common pattern in views) */
.card.shadow-sm {
    box-shadow: var(--fo-shadow-1) !important;
}

.card.border-0 {
    border: none !important;
}

/* Card header with bg-white */
.card-header.bg-white {
    background-color: var(--fo-card-bg) !important;
    border-bottom: 1px solid var(--fo-border-color);
}

/* Card footer with bg-white */
.card-footer.bg-white {
    background-color: var(--fo-card-bg) !important;
    border-top: 1px solid var(--fo-border-color);
}

/* Card body with border-bottom (filter sections) */
.card-body.border-bottom {
    border-bottom-color: var(--fo-border-color) !important;
}

/* Card body padding refinements */
.card-body.p-0 .table-responsive {
    margin: 0;
}

/* Card with h-100 (stat card grid items) */
.card.h-100 {
    transition: transform var(--fo-transition-base),
                box-shadow var(--fo-transition-base);
}

.card.h-100:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08) !important;
}

/* =============================================================
   BRIDGE: KPI / Stat Card Classes
   Normalize custom .kpi-card classes used across dashboards.
   Lower specificity than embedded <style> so modules can
   override, but provides defaults for consistency.
   ============================================================= */
.kpi-card {
    background: var(--fo-card-bg);
    border-radius: var(--fo-card-radius);
    box-shadow: var(--fo-shadow-1);
    padding: 1.25rem;
    transition: transform var(--fo-transition-base),
                box-shadow var(--fo-transition-base);
    position: relative;
    overflow: hidden;
    height: 100%;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

/* Remove left border gradient — use clean accent line instead */
.kpi-card::before {
    background: var(--fo-accent) !important;
}

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

.kpi-value {
    font-size: var(--fo-font-size-xl);
    font-weight: var(--fo-font-weight-bold);
    color: var(--fo-text-primary);
    line-height: var(--fo-line-height-tight);
}

.kpi-label {
    font-size: var(--fo-font-size-sm);
    color: var(--fo-text-secondary);
    margin-top: 2px;
}

.kpi-change {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: var(--fo-font-size-xs);
    font-weight: var(--fo-font-weight-semibold);
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    margin-top: 4px;
}

.kpi-change.positive {
    background: #ecfdf5;
    color: #047857;
}

.kpi-change.negative {
    background: #fef2f2;
    color: #b91c1c;
}

/* =============================================================
   BRIDGE: Table Refinements
   Enhance table appearance system-wide.
   ============================================================= */

/* thead.table-light → use design token bg */
.table thead.table-light th,
.table-light th {
    background-color: #f8fafc !important;
    color: var(--fo-text-secondary);
    font-size: var(--fo-font-size-xs);
    font-weight: var(--fo-font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--fo-border-color);
    white-space: nowrap;
}

/* Softer row borders */
.table > tbody > tr > td {
    border-bottom-color: #f1f5f9;
}

/* Last row no border */
.table > tbody > tr:last-child > td {
    border-bottom: none;
}

/* Hover row — subtle highlight */
.table-hover > tbody > tr:hover > td,
.table-hover > tbody > tr:hover > th {
    background-color: #f8fafc;
}

/* Striped table — softer */
.table-striped > tbody > tr:nth-of-type(odd) > td {
    background-color: #fafbfd;
}

/* Table inside card — remove extra spacing */
.card > .table-responsive > .table,
.card > .table {
    margin-bottom: 0;
}

/* Table responsive wrapper — subtle scrollbar */
.table-responsive::-webkit-scrollbar {
    height: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: var(--fo-border-color);
    border-radius: 2px;
}

/* =============================================================
   BRIDGE: Button Refinements
   Complete button system: sizes, variants, outlines.
   ============================================================= */

/* Small buttons */
.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: var(--fo-font-size-sm);
    border-radius: 6px;
    min-height: 32px;
}

/* Extra small buttons (for table actions) */
.btn-xs {
    padding: 0.2rem 0.5rem;
    font-size: var(--fo-font-size-xs);
    border-radius: 5px;
    min-height: 26px;
}

/* Secondary button — softer look */
.btn-secondary {
    background-color: #f1f5f9;
    border-color: #e2e8f0;
    color: #475569;
    box-shadow: none;
}

.btn-secondary:hover,
.btn-secondary:active,
.btn-secondary:focus {
    background-color: #e2e8f0;
    border-color: #cbd5e1;
    color: #334155;
    box-shadow: none;
}

/* Info button */
.btn-info {
    background-color: var(--fo-info);
    border-color: var(--fo-info);
    color: #ffffff;
}

.btn-info:hover,
.btn-info:active {
    background-color: var(--fo-info);
    border-color: var(--fo-info);
    color: #ffffff;
    filter: brightness(0.9);
}

/* Outline variants — accent aware */
.btn-outline-secondary {
    color: var(--fo-text-secondary);
    border-color: var(--fo-border-color);
}

.btn-outline-secondary:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: var(--fo-text-primary);
}

.btn-outline-success {
    color: #047857;
    border-color: #86efac;
}

.btn-outline-success:hover {
    background: #ecfdf5;
    border-color: #047857;
    color: #047857;
}

.btn-outline-danger {
    color: #b91c1c;
    border-color: #fca5a5;
}

.btn-outline-danger:hover {
    background: #fef2f2;
    border-color: #b91c1c;
    color: #b91c1c;
}

.btn-outline-info {
    color: #1d4ed8;
    border-color: #93c5fd;
}

.btn-outline-info:hover {
    background: #eff6ff;
    border-color: #1d4ed8;
    color: #1d4ed8;
}

.btn-outline-warning {
    color: #b45309;
    border-color: #fcd34d;
}

.btn-outline-warning:hover {
    background: #fff7ed;
    border-color: #b45309;
    color: #b45309;
}

/* Button group — consistent radius */
.btn-group > .btn:first-child {
    border-top-left-radius: var(--fo-border-radius);
    border-bottom-left-radius: var(--fo-border-radius);
}

.btn-group > .btn:last-child {
    border-top-right-radius: var(--fo-border-radius);
    border-bottom-right-radius: var(--fo-border-radius);
}

.btn-group > .btn:not(:first-child):not(:last-child) {
    border-radius: 0;
}

/* =============================================================
   BRIDGE: Form Refinements
   Extend form styling to small variants, input groups, checks.
   ============================================================= */

/* Small form controls — maintain design tokens */
.form-control-sm,
.form-select-sm {
    border: 1.5px solid var(--fo-input-border);
    border-radius: 6px;
    font-size: var(--fo-font-size-sm);
    padding: 0.35rem 0.65rem;
    transition: border-color var(--fo-transition-fast),
                box-shadow var(--fo-transition-fast);
}

.form-control-sm:focus,
.form-select-sm:focus {
    border-color: var(--fo-accent);
    box-shadow: 0 0 0 3px rgba(var(--fo-accent-rgb), 0.12);
    outline: none;
}

/* Input groups — consistent borders */
.input-group > .form-control,
.input-group > .form-select {
    border-color: var(--fo-input-border);
}

.input-group > .form-control:focus,
.input-group > .form-select:focus {
    border-color: var(--fo-accent);
    box-shadow: 0 0 0 3px rgba(var(--fo-accent-rgb), 0.12);
    z-index: 3;
}

.input-group-text {
    background-color: #f8fafc;
    border: 1.5px solid var(--fo-input-border);
    color: var(--fo-text-secondary);
    font-size: var(--fo-font-size-sm);
}

/* Checkboxes & Radios — accent color */
.form-check-input:checked {
    background-color: var(--fo-accent);
    border-color: var(--fo-accent);
}

.form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(var(--fo-accent-rgb), 0.15);
    border-color: var(--fo-accent);
}

.form-check-label {
    font-size: var(--fo-font-size-base);
    color: var(--fo-text-primary);
}

/* Form switch — accent color */
.form-switch .form-check-input:checked {
    background-color: var(--fo-accent);
    border-color: var(--fo-accent);
}

/* Textarea refinements */
textarea.form-control {
    border-radius: var(--fo-input-radius);
    min-height: 80px;
}

/* =============================================================
   BRIDGE: Modal Colored Headers
   Some modules use .modal-header.bg-success, .bg-danger, etc.
   Override to use softer, cleaner headers.
   ============================================================= */
.modal-header.bg-success,
.modal-header.bg-primary,
.modal-header.bg-info,
.modal-header.bg-warning,
.modal-header.bg-danger {
    color: var(--fo-text-primary) !important;
    border-bottom: 1px solid var(--fo-border-color);
}

.modal-header.bg-success { background-color: #ecfdf5 !important; }
.modal-header.bg-primary { background-color: rgba(var(--fo-accent-rgb), 0.08) !important; }
.modal-header.bg-info    { background-color: #eff6ff !important; }
.modal-header.bg-warning { background-color: #fff7ed !important; }
.modal-header.bg-danger  { background-color: #fef2f2 !important; }

/* Override text-white on colored modal headers */
.modal-header.bg-success .modal-title,
.modal-header.bg-primary .modal-title,
.modal-header.bg-info .modal-title,
.modal-header.bg-warning .modal-title,
.modal-header.bg-danger .modal-title,
.modal-header.bg-success .btn-close,
.modal-header.bg-primary .btn-close,
.modal-header.bg-info .btn-close,
.modal-header.bg-warning .btn-close,
.modal-header.bg-danger .btn-close {
    filter: none !important;
    color: var(--fo-text-primary);
}

/* Override .text-white on modal header when parent has bg-* */
.modal-header.text-white {
    color: var(--fo-text-primary) !important;
}

/* Full-screen modal on small screens */
@media (max-width: 575.98px) {
    .modal-header {
        border-radius: 0 !important;
    }
}

/* =============================================================
   BRIDGE: Progress Bars — Module accent
   ============================================================= */
.progress {
    border-radius: 6px;
    height: 8px;
    background-color: #f1f5f9;
    overflow: hidden;
}

.progress-bar {
    background-color: var(--fo-accent);
    transition: width var(--fo-transition-slow);
}

.progress-bar.bg-success { background-color: var(--fo-success) !important; }
.progress-bar.bg-danger  { background-color: var(--fo-danger) !important; }
.progress-bar.bg-warning { background-color: var(--fo-warning) !important; }
.progress-bar.bg-info    { background-color: var(--fo-info) !important; }

/* =============================================================
   BRIDGE: List Groups — Cleaner borders
   ============================================================= */
.list-group-item {
    border-color: var(--fo-border-color);
    padding: 0.75rem 1.25rem;
    font-size: var(--fo-font-size-base);
    color: var(--fo-text-primary);
    transition: background-color var(--fo-transition-fast);
}

.list-group-item:hover {
    background-color: #f8fafc;
}

.list-group-item.active {
    background-color: rgba(var(--fo-accent-rgb), 0.08);
    border-color: var(--fo-accent);
    color: var(--fo-accent);
}

/* =============================================================
   BRIDGE: Bootstrap Text/BG Utilities → Design Token Colors
   ============================================================= */
.text-primary { color: var(--fo-accent) !important; }
.text-success { color: #047857 !important; }
.text-danger  { color: #b91c1c !important; }
.text-warning { color: #b45309 !important; }
.text-info    { color: #1d4ed8 !important; }
.text-muted   { color: var(--fo-text-muted) !important; }
.text-secondary { color: var(--fo-text-secondary) !important; }

/* Background utilities — keep soft */
.bg-primary    { background-color: var(--fo-accent) !important; }
.bg-light      { background-color: #f8fafc !important; }

/* Border utilities */
.border-primary { border-color: var(--fo-accent) !important; }
.border-success { border-color: #86efac !important; }
.border-danger  { border-color: #fca5a5 !important; }
.border-warning { border-color: #fcd34d !important; }
.border-info    { border-color: #93c5fd !important; }

/* =============================================================
   BRIDGE: Breadcrumb — Cleaner styling
   ============================================================= */
.breadcrumb {
    font-size: var(--fo-font-size-sm);
    margin-bottom: var(--fo-space-3);
    padding: 0;
    background: none;
}

.breadcrumb-item a {
    color: var(--fo-text-secondary);
}

.breadcrumb-item a:hover {
    color: var(--fo-accent);
}

.breadcrumb-item.active {
    color: var(--fo-text-muted);
}

.breadcrumb-item + .breadcrumb-item::before {
    color: var(--fo-border-color);
}

/* =============================================================
   BRIDGE: Tooltip & Popover — Design token styling
   ============================================================= */
.tooltip-inner {
    border-radius: 6px;
    font-size: var(--fo-font-size-sm);
    padding: 0.375rem 0.65rem;
    font-family: var(--fo-font-family);
}

.popover {
    border: 1px solid var(--fo-border-color);
    border-radius: var(--fo-border-radius);
    box-shadow: var(--fo-shadow-2);
    font-family: var(--fo-font-family);
}

.popover-header {
    background-color: #f8fafc;
    border-bottom-color: var(--fo-border-color);
    font-weight: var(--fo-font-weight-semibold);
    font-size: var(--fo-font-size-base);
}

.popover-body {
    font-size: var(--fo-font-size-base);
    color: var(--fo-text-primary);
}

/* =============================================================
   BRIDGE: Accordion — Cleaner borders, accent focus
   ============================================================= */
.accordion-item {
    border-color: var(--fo-border-color);
}

.accordion-button {
    font-family: var(--fo-font-family);
    font-weight: var(--fo-font-weight-medium);
    font-size: var(--fo-font-size-base);
    color: var(--fo-text-primary);
    padding: 0.875rem 1.25rem;
}

.accordion-button:not(.collapsed) {
    background-color: rgba(var(--fo-accent-rgb), 0.04);
    color: var(--fo-accent);
    box-shadow: inset 0 -1px 0 var(--fo-border-color);
}

.accordion-button:focus {
    border-color: var(--fo-accent);
    box-shadow: 0 0 0 3px rgba(var(--fo-accent-rgb), 0.12);
}

.accordion-body {
    padding: 1.25rem;
    font-size: var(--fo-font-size-base);
}

/* =============================================================
   BRIDGE: Offcanvas — Design token styling
   ============================================================= */
.offcanvas {
    border: none;
    box-shadow: var(--fo-shadow-3);
}

.offcanvas-header {
    border-bottom: 1px solid var(--fo-border-color);
    padding: 1.25rem 1.5rem;
}

.offcanvas-title {
    font-weight: var(--fo-font-weight-semibold);
    font-size: 1.1rem;
}

.offcanvas-body {
    padding: 1.5rem;
}

/* =============================================================
   BRIDGE: Link Underline Exceptions
   Nav/UI links that should NOT have underlines (WCAG 1.4.1
   compliance: these links are distinguishable by context/position).
   ============================================================= */
.card a:not(.btn),
.table a:not(.btn),
.list-group-item a,
.pagination a,
.page-link,
.badge,
.topbar-icon-btn,
.topbar-branch-btn,
.topbar-avatar-btn,
.menu-item,
.dropdown-item-custom,
.sidebar-module-selector {
    text-decoration: none;
}

/* Re-add underline on hover for content links in cards/tables */
.card-body a:not(.btn):not(.badge):not(.dropdown-item):hover,
.table a:not(.btn):not(.badge):hover {
    text-decoration: underline;
}

/* =============================================================
   BRIDGE: Additional Responsive
   ============================================================= */

/* Stat card grids (Bootstrap row with col-sm-6 col-xl-3) */
@media (max-width: 575.98px) {
    .row > [class*="col-sm-6"][class*="col-xl-3"] > .card,
    .row > [class*="col-6"][class*="col-lg-3"] > .card,
    .row > [class*="col-6"][class*="col-lg-3"] > .kpi-card {
        margin-bottom: 0;
    }

    /* Full width filter inputs on mobile */
    .card-body .row.g-2 > [class*="col-md"] {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Print overrides — ensure new styles don't bleed */
@media print {
    .sidebar,
    .sidebar-overlay,
    .topbar,
    .sidebar-flyout,
    .sidebar-tooltip {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    .content-wrapper {
        max-width: 100%;
        padding: 0;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        break-inside: avoid;
    }

    .card-header {
        background: #f8f8f8 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .badge {
        border: 1px solid #999 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .btn {
        display: none !important;
    }

    .kpi-card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }

    .table thead th {
        background-color: #f0f0f0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* =============================================================
   PASO 4 FIXES — Missing Bridge Classes
   Added after audit of all 17 modules + core views.
   Priority order: 🔴 Alta → 🟡 Media → 🟢 Baja
   ============================================================= */

/* =============================================================
   🔴 ALTA: Soporte Module — Purple Color System
   ⚠️  INCONSISTENCIA DOCUMENTADA: El módulo Soporte usa
   #6f42c1 (morado) en toda su UI, pero variables.css define
   --fo-accent: #eab308 (amarillo) para body[data-module="soporte"].
   Las clases .text-purple/.btn-purple usan el color morado
   ACTUAL del módulo para no romper nada. Pendiente alineación
   futura con el design token correcto.
   ============================================================= */
:root {
    --fo-purple: #6f42c1;
    --fo-purple-rgb: 111, 66, 193;
}

.text-purple {
    color: var(--fo-purple) !important;
}

.bg-purple {
    background-color: var(--fo-purple) !important;
    color: #ffffff;
}

.border-purple {
    border-color: var(--fo-purple) !important;
}

.btn-purple {
    background-color: var(--fo-purple);
    border-color: var(--fo-purple);
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(var(--fo-purple-rgb), 0.25);
    border-radius: var(--fo-border-radius);
    font-weight: var(--fo-font-weight-medium);
    font-size: var(--fo-font-size-base);
    padding: 0.5rem 1.25rem;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    transition: all var(--fo-transition-fast);
    cursor: pointer;
}

.btn-purple:hover,
.btn-purple:active,
.btn-purple:focus {
    background-color: #5a35a0;
    border-color: #5a35a0;
    color: #ffffff;
    box-shadow: 0 4px 8px rgba(var(--fo-purple-rgb), 0.3);
}

.btn-sm.btn-purple {
    padding: 0.35rem 0.75rem;
    font-size: var(--fo-font-size-sm);
    border-radius: 6px;
    min-height: 32px;
}

.btn-outline-purple {
    background: transparent;
    color: var(--fo-purple);
    border: 1.5px solid var(--fo-purple);
    border-radius: var(--fo-border-radius);
    font-weight: var(--fo-font-weight-medium);
    font-size: var(--fo-font-size-base);
    padding: 0.5rem 1.25rem;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    transition: all var(--fo-transition-fast);
    cursor: pointer;
}

.btn-outline-purple:hover,
.btn-outline-purple:active {
    background: var(--fo-purple);
    color: #ffffff;
}

.btn-sm.btn-outline-purple {
    padding: 0.35rem 0.75rem;
    font-size: var(--fo-font-size-sm);
    border-radius: 6px;
    min-height: 32px;
}

/* Spinner purple */
.spinner-border.text-purple,
.text-purple.spinner-border {
    color: var(--fo-purple) !important;
}

/* Modal header purple (soporte tickets) */
.modal-header.bg-purple {
    background-color: rgba(var(--fo-purple-rgb), 0.08) !important;
    color: var(--fo-text-primary) !important;
    border-bottom: 1px solid var(--fo-border-color);
}

.modal-header.bg-purple .modal-title {
    color: var(--fo-purple);
}

.modal-header.bg-purple.text-white {
    color: var(--fo-text-primary) !important;
}

.modal-header.bg-purple .btn-close {
    filter: none !important;
}

/* =============================================================
   🔴 ALTA: Core Settings — Embedded style classes
   Matches exactly the <style> block in settings/index.php
   so the external bridge takes effect if the embedded block
   is ever removed, and sets tokens for consistency.
   ============================================================= */

/* Settings nav tabs — custom pill tabs style */
.settings-tabs .nav-link {
    color: var(--fo-text-primary);
    font-weight: var(--fo-font-weight-medium);
    font-size: var(--fo-font-size-base);
    border-radius: 8px 8px 0 0;
    padding: 0.6rem 1.1rem;
    border: 1px solid transparent;
    border-bottom: none;
    transition: all var(--fo-transition-fast);
    text-decoration: none;
}

.settings-tabs .nav-link:hover {
    background: #f3f4f6;
    color: var(--fo-text-primary);
}

.settings-tabs .nav-link.active {
    color: var(--fo-accent);
    background: var(--fo-card-bg);
    border-color: var(--fo-border-color);
}

.settings-tabs .nav-link i {
    font-size: var(--fo-font-size-sm);
}

/* Tab content panel */
.settings-tabs ~ .tab-content,
.tab-content.settings-tab-content {
    background: var(--fo-card-bg);
    border: 1px solid var(--fo-border-color);
    border-top: none;
    border-radius: 0 0 var(--fo-border-radius-lg) var(--fo-border-radius-lg);
}

.settings-tabs ~ .tab-content .tab-pane,
.tab-content.settings-tab-content .tab-pane {
    padding: 1.75rem;
}

/* Form section — groups related fields */
.form-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #f3f4f6;
}

.form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Form section title — uppercase label above field group */
.form-section-title {
    font-size: var(--fo-font-size-sm);
    font-weight: var(--fo-font-weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fo-text-muted);
    margin-bottom: 1rem;
}

/* Logo preview box — dashed border upload area */
.logo-preview {
    width: 120px;
    height: 80px;
    border: 2px dashed var(--fo-input-border);
    border-radius: var(--fo-border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #f9fafb;
    cursor: pointer;
    transition: border-color var(--fo-transition-fast);
}

.logo-preview:hover {
    border-color: var(--fo-accent);
}

.logo-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Info card — read-only information display */
.info-card {
    background: #f8fafc;
    border: 1px solid var(--fo-border-color);
    border-radius: var(--fo-border-radius);
    padding: 1rem;
}

/* Info row — key/value pairs inside info-card */
.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    font-size: var(--fo-font-size-base);
}

.info-row + .info-row {
    border-top: 1px solid var(--fo-border-color);
}

/* =============================================================
   🟡 MEDIA: .stat-icon — Estandarizado
   Tamaño único: 44×44px (promedio entre 42px de salud y
   46px de dental). Las clases bg-*-opacity-10 text-* de
   Bootstrap 5.3 manejan el color dinámicamente.
   ============================================================= */
.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* Branch icon — slightly smaller variant for table rows */
.branch-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}

/* =============================================================
   🟡 MEDIA: Chart Containers — finanzas, moda, isp dashboards
   Normaliza los contenedores de Chart.js con design tokens.
   ============================================================= */

/* Chart wrapper card */
.chart-container {
    position: relative;
    height: 320px;
    background: var(--fo-card-bg);
    border-radius: var(--fo-card-radius);
    padding: 1.5rem;
    box-shadow: var(--fo-shadow-1);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.chart-container.tall {
    height: 400px;
}

/* ISP-style chart box (less padding, same card treatment) */
.chart-box {
    background: var(--fo-card-bg);
    border-radius: var(--fo-card-radius);
    box-shadow: var(--fo-shadow-1);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.chart-box h6 {
    font-weight: var(--fo-font-weight-semibold);
    color: var(--fo-text-primary);
    margin-bottom: 1rem;
    font-size: var(--fo-font-size-base);
}

/* Chart title — header above chart */
.chart-title {
    font-size: 1rem;
    font-weight: var(--fo-font-weight-semibold);
    color: var(--fo-text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-title i {
    color: var(--fo-accent);    /* module-aware icon color */
    font-size: 0.9em;
}

/* Table container — legacy wrapper used alongside chart-container */
.table-container {
    background: var(--fo-card-bg);
    border-radius: var(--fo-card-radius);
    padding: 1.25rem;
    box-shadow: var(--fo-shadow-1);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

/* =============================================================
   🟡 MEDIA: .table-modern — Custom table variant
   Used in finanzas, moda, isp dashboards alongside Chart.js.
   Lighter styling than .table-card (no wrapper card).
   ============================================================= */
.table-modern thead th {
    background: #f8fafc;
    border-bottom: 2px solid var(--fo-border-color);
    color: var(--fo-text-secondary);
    font-weight: var(--fo-font-weight-semibold);
    font-size: var(--fo-font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.75rem;
    white-space: nowrap;
}

.table-modern tbody td {
    padding: 0.65rem 0.75rem;
    vertical-align: middle;
    border-bottom: 1px solid #f8fafc;
    font-size: var(--fo-font-size-sm);
    color: var(--fo-text-primary);
}

.table-modern tbody tr:hover {
    background: #f8fafc;
}

.table-modern tbody tr:last-child td {
    border-bottom: none;
}

/* =============================================================
   🟡 MEDIA: ISP .sync-bar — Barra de sincronización WispHub
   ============================================================= */
.sync-bar {
    background: var(--fo-card-bg);
    border-radius: var(--fo-card-radius);
    box-shadow: var(--fo-shadow-1);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--fo-space-3);
    font-size: var(--fo-font-size-sm);
    color: var(--fo-text-secondary);
}

.sync-bar strong {
    color: var(--fo-text-primary);
}

/* =============================================================
   🟡 MEDIA: .timeline-item — Salud patients consultation history
   WCAG 1.4.1: Estado communicado con icono + color + texto
   ============================================================= */
.timeline-item {
    position: relative;
    padding-left: 30px;
    margin-bottom: 20px;
    border-left: 2px solid var(--fo-border-color);
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--fo-accent);   /* module-aware accent dot */
    border: 2px solid var(--fo-card-bg);
    box-shadow: 0 0 0 1px var(--fo-border-color);
}

.timeline-item.completed::before {
    background: var(--fo-success);
}

.timeline-item.pending::before {
    background: var(--fo-warning);
}

.timeline-item.cancelled::before {
    background: var(--fo-danger);
}

/* Timeline content */
.timeline-item .tl-date {
    font-size: var(--fo-font-size-xs);
    color: var(--fo-text-muted);
    margin-bottom: 2px;
}

.timeline-item .tl-title {
    font-size: var(--fo-font-size-base);
    font-weight: var(--fo-font-weight-medium);
    color: var(--fo-text-primary);
}

.timeline-item .tl-body {
    font-size: var(--fo-font-size-sm);
    color: var(--fo-text-secondary);
    margin-top: 4px;
}

/* =============================================================
   🟡 MEDIA: .quick-btn — Dental dashboard quick action buttons
   Links verticales con ícono arriba + texto abajo.
   ============================================================= */
.quick-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: var(--fo-text-secondary);
    font-size: var(--fo-font-size-xs);
    font-weight: var(--fo-font-weight-semibold);
    padding: 0.65rem 0.5rem;
    border-radius: var(--fo-border-radius);
    transition: all var(--fo-transition-fast);
}

.quick-btn:hover {
    background: #f1f5f9;
    color: var(--fo-text-primary);
    text-decoration: none;
}

.quick-btn i {
    font-size: 1.3rem;
    color: var(--fo-accent);        /* module-aware icon */
    transition: color var(--fo-transition-fast);
}

.quick-btn:hover i {
    color: var(--fo-accent);
    filter: brightness(0.85);
}

/* =============================================================
   🟡 MEDIA: .pipeline-card — Taller orders pipeline filter chips
   Tarjetas de filtro de estado en órdenes de taller.
   ============================================================= */
.pipeline-card {
    transition: transform var(--fo-transition-fast),
                box-shadow var(--fo-transition-fast);
    cursor: pointer;
}

.pipeline-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--fo-shadow-2) !important;
}

/* Active/selected state via Bootstrap border utility */
.pipeline-card.border {
    border-color: var(--fo-accent) !important;   /* module-aware accent border */
}

/* =============================================================
   🟡 MEDIA: .text-teal — Inventario TI module color
   inventario_ti usa teal (#14b8a6) en su UI.
   También útil para cualquier módulo dental/teal.
   ============================================================= */
.text-teal   { color: #14b8a6 !important; }
.bg-teal     { background-color: #14b8a6 !important; color: #ffffff; }
.border-teal { border-color: #14b8a6 !important; }

/* =============================================================
   🟢 BAJA: Animations — fadeInUp
   Usado en dashboards de finanzas, moda para entrada
   de KPI cards. Se define globalmente para evitar duplicados.
   ============================================================= */
@keyframes fo-fadeInUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Keep legacy keyframe name for backwards compat with existing dashboards */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0);    }
}

.animate-fade-in {
    animation: fadeInUp 0.6s ease-out both;
}

@media (prefers-reduced-motion: reduce) {
    .animate-fade-in { animation: none; }
}

/* Stagger delay variants (up to 6 items) */
.anim-delay-1 { animation-delay: 0.1s; }
.anim-delay-2 { animation-delay: 0.2s; }
.anim-delay-3 { animation-delay: 0.3s; }
.anim-delay-4 { animation-delay: 0.4s; }
.anim-delay-5 { animation-delay: 0.5s; }
.anim-delay-6 { animation-delay: 0.6s; }

/* =============================================================
   🟢 BAJA: .seller-performance-card — Moda dashboard
   Tarjeta de ranking de vendedores con border-left accent.
   ============================================================= */
.seller-performance-card {
    background: var(--fo-card-bg);
    border-radius: var(--fo-border-radius);
    padding: 0.85rem;
    box-shadow: var(--fo-shadow-1);
    transition: transform var(--fo-transition-fast);
    border-left: 4px solid var(--fo-accent);    /* module-aware accent border */
    height: 100%;
}

.seller-performance-card:hover {
    transform: translateX(4px);
}

/* =============================================================
   🟢 BAJA: .quick-action-admin — Moda dashboard action buttons
   Botones de acción rápida en grid (nueva venta, producto...).
   Complementa .btn-primary/.btn-warning existentes.
   ============================================================= */
.quick-action-admin {
    min-height: 55px;
    border-radius: var(--fo-border-radius);
    font-size: var(--fo-font-size-xs);
    font-weight: var(--fo-font-weight-semibold);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-decoration: none;
    transition: all var(--fo-transition-fast);
}

.quick-action-admin i {
    font-size: 1.1rem;
}

/* =============================================================
   GLOBAL RESPONSIVE — Mobile-first fixes for all modules
   Appended: covers tablets (≤767px) and phones (≤575px).
   Does NOT modify existing rules above; cascade handles priority.
   ============================================================= */

/* ── Utility: hide element on mobile only ──────────────── */
@media (max-width: 575.98px) {
    .d-none-mobile { display: none !important; }
}

/* ============================================================
   ≤ 767.98px — Tablet / phablet
   ============================================================ */
@media (max-width: 767.98px) {

    /* ── Content wrapper: tighter padding ─────────────── */
    .content-wrapper { padding: 1rem 1.125rem; }

    /* ── Tables: compact ──────────────────────────────── */
    .table { font-size: 0.825rem; }
    .table td, .table th { padding: 0.45rem 0.6rem; vertical-align: middle; }

    /* Table action btn-groups: smaller padding ─────────── */
    .table .btn-group .btn,
    .table .btn-group-sm .btn { padding: 0.28rem 0.45rem; }

    /* ── KPI / stat cards ─────────────────────────────── */
    .kpi-card    { padding: 1rem !important; min-height: unset !important; }
    .kpi-value   { font-size: 1.4rem !important; }
    .kpi-icon    { width: 40px !important; height: 40px !important;
                   font-size: 1.1rem !important; margin-bottom: 0.35rem !important; }
    .kpi-label   { font-size: 0.72rem !important; }

    /* ── Chart containers: reduce height ─────────────── */
    .chart-container      { height: 220px !important; padding: 1rem !important; }
    .chart-container.tall { height: 260px !important; }
    .chart-title          { font-size: 0.95rem !important; margin-bottom: 0.75rem !important; }

    /* ── Table container cards: less padding ─────────── */
    .table-container { padding: 1rem !important; }
}

/* ============================================================
   ≤ 575.98px — Mobile phones
   ============================================================ */
@media (max-width: 575.98px) {

    /* ── Content wrapper ──────────────────────────────── */
    .content-wrapper { padding: 0.75rem 0.875rem; }

    /* ── Page title ───────────────────────────────────── */
    .container-fluid h1.h3 { font-size: 1.05rem; }
    .container-fluid h1.h3 .text-muted { font-size: 0.78rem; }

    /* Page header bars: allow wrap so CTA button drops below title */
    .justify-content-between.mb-4,
    .justify-content-between.mb-3 { flex-wrap: wrap; gap: 0.5rem; }

    /* ── Tables ───────────────────────────────────────── */
    .table { font-size: 0.8rem; }
    .table td, .table th { padding: 0.38rem 0.45rem; }
    .table-responsive { -webkit-overflow-scrolling: touch; }

    /* Action buttons in tables ─────────────────────────── */
    .table .btn-group .btn,
    .table .btn-group-sm .btn { padding: 0.25rem 0.38rem; font-size: 0.75rem; }

    /* ── Stat icons ──────────────────────────────────── */
    .stat-icon {
        width: 36px !important; height: 36px !important;
        font-size: 0.9rem !important; border-radius: 8px !important;
    }
    .branch-icon {
        width: 28px !important; height: 28px !important;
        font-size: 0.8rem !important; border-radius: 6px !important;
    }

    /* ── KPI / stat cards ─────────────────────────────── */
    .kpi-card  { padding: 0.75rem !important; min-height: unset !important; }
    .kpi-value { font-size: 1.2rem !important; }
    .kpi-icon  { width: 36px !important; height: 36px !important;
                 font-size: 1rem !important; margin-bottom: 0.25rem !important; }
    .kpi-label { font-size: 0.68rem !important; letter-spacing: 0 !important; }
    .kpi-change { font-size: 0.68rem !important; padding: 0.15rem 0.45rem !important; }

    /* ── Chart containers ────────────────────────────── */
    .chart-container      { height: 190px !important; padding: 0.75rem !important; }
    .chart-container.tall { height: 230px !important; }
    .chart-title          { font-size: 0.88rem !important; margin-bottom: 0.5rem !important; }
    .table-container      { padding: 0.75rem !important; }

    /* ── Cards: compact padding ──────────────────────── */
    /* Use lower specificity so inline styles can still override */
    .card > .card-body    { padding: 0.875rem; }
    .card > .card-header  { padding: 0.6rem 0.875rem; }
    .card > .card-footer  { padding: 0.6rem 0.875rem; }

    /* ── Modals: near-full-screen on phones ──────────── */
    /* Non-sm modals get max width */
    .modal-dialog:not(.modal-sm) {
        margin: 0.375rem auto;
        max-width: calc(100vw - 0.75rem);
    }
    /* Large / XL modals: full stretch */
    .modal-dialog.modal-lg,
    .modal-dialog.modal-xl,
    .modal-dialog.modal-dialog-scrollable:not(.modal-sm) {
        margin: 0.25rem;
        max-width: calc(100vw - 0.5rem);
    }
    .modal-body   { padding: 0.875rem !important; }
    .modal-footer { padding: 0.6rem 0.875rem !important; gap: 0.375rem; }

    /* ── Topbar: hide global search on mobile ─────────── */
    /* Search bar takes too much space; icon-only topbar is cleaner */
    .topbar-center { display: none !important; }

    /* ── Nav tabs & pills: horizontal scroll ─────────── */
    .nav-tabs,
    .nav-pills {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 1px;    /* avoid clipping active border */
    }
    .nav-tabs::-webkit-scrollbar,
    .nav-pills::-webkit-scrollbar { display: none; }
    .nav-tabs .nav-link,
    .nav-pills .nav-link { white-space: nowrap; }

    /* ── Filter bars: inputs full-width ──────────────── */
    /* Complement existing rule (line ~1408) for col-md-* in .row.g-* */
    .card-body .row.g-3 > [class*="col-md"],
    .card-body .row.g-2 > [class*="col-md"],
    .card-body .row.g-1 > [class*="col-md"] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* ── Period btn-groups: compact ──────────────────── */
    .btn-group[role="group"] .btn { font-size: 0.72rem; padding: 0.28rem 0.38rem; }

    /* ── DataTables: compact controls ───────────────── */
    .dataTables_wrapper .dataTables_filter { text-align: left !important; }
    .dataTables_wrapper .dataTables_filter input { max-width: 140px; }
    .dataTables_wrapper .dataTables_info  { font-size: 0.78rem; }

    /* ── Dropdowns: prevent off-screen ───────────────── */
    .dropdown-menu { max-height: 55vh; overflow-y: auto; }

    /* ── Touch: minimum target sizes ─────────────────── */
    .btn     { min-height: 36px; touch-action: manipulation; }
    .btn-sm  { min-height: 32px; }
    .btn-lg  { min-height: 44px; }
    .form-control, .form-select { min-height: 38px; font-size: 0.875rem; }

    /* ── Pagination: compact ─────────────────────────── */
    .pagination .page-link { padding: 0.32rem 0.55rem; font-size: 0.78rem; }

    /* ── Goal progress card: text-wrap ───────────────── */
    .goal-card .fs-3 { font-size: 1.4rem !important; }
    .goal-progress   { height: 22px !important; }

    /* ── Seller performance card: compact ────────────── */
    .seller-performance-card { padding: 0.65rem !important; }

    /* ── Quick action buttons: smaller ───────────────── */
    .quick-action-admin { min-height: 46px !important; font-size: 0.68rem !important; }
    .quick-action-admin i { font-size: 0.95rem !important; }
}

/* =============================================================
   MODULE-SPECIFIC RESPONSIVE — Column hiding & micro-fixes
   Uses :has() (Chrome 105+, FF 121+, Safari 15.4+) for thead.
   Falls back gracefully: thead columns visible, tbody hidden.
   ============================================================= */

/* ── Comercio: Productos (ocultar SKU + Categoría) ────── */
@media (max-width: 575.98px) {
    table:has(#productsTbody) thead th:nth-child(2),
    table:has(#productsTbody) thead th:nth-child(3),
    #productsTbody td:nth-child(2),
    #productsTbody td:nth-child(3) { display: none; }
}

/* ── Comercio: Ventas (ocultar NCF + Vendedor + Fecha) ── */
@media (max-width: 575.98px) {
    table:has(#salesTbody) thead th:nth-child(2),
    table:has(#salesTbody) thead th:nth-child(4),
    table:has(#salesTbody) thead th:nth-child(8),
    #salesTbody td:nth-child(2),
    #salesTbody td:nth-child(4),
    #salesTbody td:nth-child(8) { display: none; }
}

/* ── Restaurante: Órdenes (ocultar Mesero + Apertura + Cierre) */
@media (max-width: 575.98px) {
    #tblOrders thead th:nth-child(3),
    #tblOrders thead th:nth-child(6),
    #tblOrders thead th:nth-child(7),
    #tblOrders tbody td:nth-child(3),
    #tblOrders tbody td:nth-child(6),
    #tblOrders tbody td:nth-child(7) { display: none; }
}

/* ── Salud: Agenda / FullCalendar ─────────────────────── */
@media (max-width: 575.98px) {
    #calendar .fc-toolbar {
        flex-wrap: wrap;
        gap: 0.375rem;
        justify-content: center !important;
    }
    #calendar .fc-toolbar-title { font-size: 1rem !important; }
    #calendar .fc-col-header-cell-cushion,
    #calendar .fc-daygrid-day-number { font-size: 0.75rem; }
}
