/* ===================================================
   ReserBar Design System
   Version: 2.0 — Dark Sidebar + Plus Jakarta Sans
   =================================================== */

/* ===== 1. VARIABLES ===== */

:root {
    /* Brand
       Primario único de marca: #EA580C (orange-600). Es el naranja que ya domina
       la UI y ofrece mejor contraste sobre blanco (3.56:1) que el antiguo #F97316
       (2.80:1). Cualquier naranja hardcodeado debe usar var(--rb-primary). */
    --rb-primary: #EA580C;
    --rb-primary-dark: #C2410C;
    --rb-primary-light: #FED7AA;
    --rb-primary-bg: #FFF7ED;
    --rb-primary-subtle: color-mix(in srgb, var(--rb-primary) 8%, white);
    --rb-primary-hover: var(--rb-primary-dark);
    /* Texto de marca sobre fondos claros: cumple 4.5:1 sobre blanco y sobre --rb-primary-bg */
    --rb-primary-text: #C2410C;
    /* Marca sobre superficies oscuras (sidebar #1E293B): #EA580C sólo alcanza 4.10:1,
       por eso el acento sobre oscuro sube a orange-400 (6.45:1). */
    --rb-primary-on-dark: #FB923C;
    --rb-primary-on-dark-bg: rgba(251, 146, 60, 0.15);
    /* Anillo de foco/atención derivado del primario (usado por inputs, selects y textareas) */
    --rb-focus-ring: 0 0 0 3px rgba(234, 88, 12, 0.18);

    /* Surfaces */
    --rb-bg: #FFFFFF;
    --rb-bg-alt: #F8FAFC;
    --rb-bg-muted: #F1F5F9;
    --rb-surface: #FFFFFF;
    --rb-border: #E2E8F0;
    --rb-border-light: #F1F5F9;
    --rb-bg-dark: #1E293B;

    /* Text */
    --rb-text: #0F172A;
    --rb-text-secondary: #64748B;
    --rb-text-muted: #64748B;
    /* SÓLO decorativo (separadores, placeholders, iconos apagados): 2.54:1 sobre blanco.
       Cualquier texto informativo o enlace debe usar --rb-text-muted (4.76:1). */
    --rb-text-faint: #94A3B8;

    /* Semantic */
    --rb-success: #22C55E;
    --rb-success-bg: #F0FDF4;
    --rb-danger: #EF4444;
    --rb-danger-bg: #FEF2F2;
    --rb-warning: #F59E0B;
    --rb-warning-bg: #FFFBEB;
    --rb-info: #3B82F6;
    --rb-info-bg: #EFF6FF;

    /* Estado triplets (for badges with borders) */
    --rb-estado-pendiente-bg: #FFFBEB;
    --rb-estado-pendiente-color: #92400E;
    --rb-estado-pendiente-border: #FDE68A;
    --rb-estado-confirmada-bg: #F0FDF4;
    --rb-estado-confirmada-color: #166534;
    --rb-estado-confirmada-border: #BBF7D0;
    --rb-estado-sentada-bg: #EFF6FF;
    --rb-estado-sentada-color: #1D4ED8;
    --rb-estado-sentada-border: #BFDBFE;
    --rb-estado-completada-bg: #F8FAFC;
    --rb-estado-completada-color: #475569;
    --rb-estado-completada-border: #E2E8F0;
    --rb-estado-noshow-bg: #FFF1F2;
    --rb-estado-noshow-color: #9F1239;
    --rb-estado-noshow-border: #FECDD3;
    --rb-estado-cancelada-bg: #F8FAFC;
    --rb-estado-cancelada-color: #64748B; /* 4.76:1 sobre #F8FAFC (antes #94A3B8 = 2.47:1) */
    --rb-estado-cancelada-border: #E2E8F0;

    /* Mesa States */
    --rb-mesa-libre: #22C55E;
    --rb-mesa-ocupada: #EF4444;
    --rb-mesa-reservada: #F59E0B;
    --rb-mesa-bloqueada: #94A3B8;
    --rb-mesa-limpiando: #64748B;

    /* Typography */
    --rb-font-display: 'Plus Jakarta Sans', system-ui, sans-serif;
    --rb-font-body: 'Inter', system-ui, sans-serif;
    --rb-font-mono: 'JetBrains Mono', 'Consolas', monospace;
    --rb-font: var(--rb-font-body);

    /* Font sizes */
    --rb-font-size-xs: 0.75rem;
    --rb-font-size-sm: 0.8125rem;
    --rb-font-size-base: 0.875rem;
    --rb-font-size-lg: 1rem;
    --rb-font-size-xl: 1.125rem;
    --rb-font-size-2xl: 1.5rem;
    --rb-font-size-3xl: 1.875rem;

    /* Spacing */
    --rb-space-1: 0.25rem;
    --rb-space-2: 0.5rem;
    --rb-space-3: 0.75rem;
    --rb-space-4: 1rem;
    --rb-space-5: 1.25rem;
    --rb-space-6: 1.5rem;
    --rb-space-8: 2rem;
    --rb-space-10: 2.5rem;
    --rb-space-12: 3rem;

    /* Radii */
    --rb-radius-sm: 6px;
    --rb-radius-md: 8px;
    --rb-radius-lg: 12px;
    --rb-radius-xl: 16px;

    /* Shadows */
    --rb-shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --rb-shadow-md: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --rb-shadow-lg: 0 4px 16px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
    --rb-shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.06);

    /* Layout */
    --rb-sidebar-width: 260px;
    --rb-sidebar-collapsed: 72px;
    --rb-topbar-height: 60px;

    /* Tenant overrides (set dynamically) */
    --brand-primary: var(--rb-primary);
    --brand-primary-hover: var(--rb-primary-dark);
    --brand-bg: var(--rb-bg);
    --brand-text: var(--rb-text);
}

/* ===== 2. BASE ===== */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--rb-font);
    font-size: var(--rb-font-size-base);
    color: var(--rb-text);
    background: var(--rb-bg-alt);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ===== 3. ADMIN LAYOUT ===== */

.rb-app {
    min-height: 100vh;
}

/* --- Sidebar (Dark) --- */
.rb-sidebar {
    width: var(--rb-sidebar-width);
    background: #1E293B;
    border-right: none;
    box-shadow: 1px 0 0 rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1030;
    transition: width 0.2s ease, transform 0.2s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.rb-sidebar-brand {
    height: var(--rb-topbar-height);
    display: flex;
    align-items: center;
    padding: 0 var(--rb-space-5);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
    gap: var(--rb-space-3);
    text-decoration: none;
    color: white;
}

.rb-sidebar-brand-icon {
    width: 32px;
    height: 32px;
    background: var(--rb-primary);
    border-radius: var(--rb-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: var(--rb-font-size-lg);
    flex-shrink: 0;
}

.rb-sidebar-brand-text {
    font-family: var(--rb-font-display);
    font-weight: 700;
    font-size: var(--rb-font-size-xl);
    white-space: nowrap;
    color: white;
}

.rb-sidebar-nav {
    padding: var(--rb-space-3) var(--rb-space-3);
    flex: 1;
}

.rb-sidebar-section {
    margin-bottom: var(--rb-space-4);
}

.rb-sidebar-section-title {
    font-size: var(--rb-font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94A3B8; /* 4.99:1 sobre el sidebar oscuro (antes #475569 = 1.74:1) */
    padding: var(--rb-space-2) var(--rb-space-3);
    margin-bottom: var(--rb-space-1);
}

.rb-nav-item {
    display: flex;
    align-items: center;
    gap: var(--rb-space-3);
    padding: var(--rb-space-2) var(--rb-space-3);
    border-radius: var(--rb-radius-md);
    color: #94A3B8;
    text-decoration: none;
    font-size: var(--rb-font-size-base);
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.rb-nav-item:hover {
    background: rgba(255,255,255,0.06);
    color: #E2E8F0;
}

.rb-nav-item.active {
    background: var(--rb-primary);
    color: white;
    font-weight: 600;
}

.rb-nav-item .bi {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.rb-nav-badge {
    margin-left: auto;
    background: var(--rb-danger);
    color: white;
    font-size: var(--rb-font-size-xs);
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 99px;
    min-width: 18px;
    text-align: center;
}

/* Sidebar Footer */
.rb-sidebar-footer {
    padding: var(--rb-space-3);
    border-top: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.rb-sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--rb-space-3);
    padding: var(--rb-space-2) var(--rb-space-3);
    border-radius: var(--rb-radius-md);
    text-decoration: none;
    color: #CBD5E1;
}

.rb-sidebar-user:hover {
    background: rgba(255,255,255,0.06);
}

.rb-sidebar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--rb-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: var(--rb-font-size-sm);
    flex-shrink: 0;
}

.rb-sidebar-user-info {
    overflow: hidden;
}

.rb-sidebar-user-name {
    font-weight: 600;
    font-size: var(--rb-font-size-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #E2E8F0;
}

.rb-sidebar-user-role {
    font-size: var(--rb-font-size-xs);
    color: #94A3B8; /* 4.99:1 sobre el sidebar oscuro (antes #64748B = 2.86:1) */
}

/* --- Main Content --- */
.rb-main {
    margin-left: var(--rb-sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
    transition: margin-left 0.2s ease;
}

/* --- Topbar --- */
.rb-topbar {
    height: var(--rb-topbar-height);
    background: var(--rb-bg);
    border-bottom: 1px solid var(--rb-border);
    display: flex;
    align-items: center;
    padding: 0 var(--rb-space-6);
    gap: var(--rb-space-4);
    position: sticky;
    top: 0;
    z-index: 1020;
}

.rb-topbar-toggle {
    display: none;
    background: none;
    border: none;
    padding: var(--rb-space-2);
    cursor: pointer;
    color: var(--rb-text-secondary);
    font-size: 1.25rem;
}

.rb-topbar-breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--rb-space-2);
    font-size: var(--rb-font-size-sm);
    color: var(--rb-text-muted);
}

.rb-topbar-breadcrumb a {
    color: var(--rb-text-secondary);
    text-decoration: none;
}

.rb-topbar-breadcrumb a:hover {
    color: var(--rb-primary-text);
}

.rb-topbar-breadcrumb .current {
    color: var(--rb-text);
    font-weight: 500;
}

.rb-topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--rb-space-3);
}

/* --- Content Area --- */
.rb-content {
    flex: 1;
    padding: var(--rb-space-6);
    max-width: 1400px;
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
}

/* --- Page Header --- */
.rb-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--rb-space-6);
    flex-wrap: wrap;
    gap: var(--rb-space-4);
}

.rb-page-title {
    font-family: var(--rb-font-display);
    font-size: var(--rb-font-size-2xl);
    font-weight: 700;
    color: var(--rb-text);
    margin: 0;
}

.rb-page-subtitle {
    font-size: var(--rb-font-size-sm);
    color: var(--rb-text-secondary);
    margin-top: var(--rb-space-1);
}

/* ===== 4. COMPONENTS ===== */

/* --- Cards --- */
.rb-card {
    background: var(--rb-bg);
    border: 1px solid var(--rb-border);
    border-radius: var(--rb-radius-lg);
    box-shadow: var(--rb-shadow-sm);
}

.rb-card-header {
    padding: var(--rb-space-4) var(--rb-space-5);
    border-bottom: 1px solid var(--rb-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.rb-card-title {
    font-family: var(--rb-font-display);
    font-size: var(--rb-font-size-lg);
    font-weight: 600;
    margin: 0;
}

.rb-card-body {
    padding: var(--rb-space-5);
}

/* --- KPI Cards --- */
.rb-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--rb-space-4);
    margin-bottom: var(--rb-space-6);
}

.rb-kpi {
    background: var(--rb-bg);
    border: 1px solid var(--rb-border);
    border-radius: var(--rb-radius-lg);
    padding: var(--rb-space-5);
    display: flex;
    align-items: flex-start;
    gap: var(--rb-space-4);
    box-shadow: var(--rb-shadow-md);
}

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

.rb-kpi-icon.primary { background: var(--rb-primary-light); color: var(--rb-primary); }
.rb-kpi-icon.success { background: var(--rb-success-bg); color: var(--rb-success); }
.rb-kpi-icon.warning { background: var(--rb-warning-bg); color: var(--rb-warning); }
.rb-kpi-icon.danger { background: var(--rb-danger-bg); color: var(--rb-danger); }
.rb-kpi-icon.info { background: var(--rb-info-bg); color: var(--rb-info); }

.rb-kpi-value {
    font-family: var(--rb-font-display);
    font-size: var(--rb-font-size-2xl);
    font-weight: 700;
    color: var(--rb-text);
    line-height: 1.2;
}

.rb-kpi-label {
    font-size: var(--rb-font-size-sm);
    color: var(--rb-text-secondary);
    margin-top: var(--rb-space-1);
}

/* --- Buttons --- */
.rb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--rb-space-2);
    padding: 0.5rem 1rem;
    border-radius: var(--rb-radius-md);
    font-size: var(--rb-font-size-base);
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.5;
}

/* Fondo --rb-primary-dark (#C2410C) y no --rb-primary: texto blanco sobre #EA580C da
   3.56:1 y WCAG AA exige 4.5:1 para texto normal; sobre #C2410C da 5.94:1. La marca
   sigue siendo #EA580C en acentos, links y estados activos — solo el botón se oscurece. */
.rb-btn-primary {
    background: var(--rb-primary-dark);
    color: white;
    border-color: var(--rb-primary-dark);
}
.rb-btn-primary:hover { background: #9A3412; border-color: #9A3412; color: white; }

.rb-btn-outline {
    background: transparent;
    color: var(--rb-text-secondary);
    border-color: var(--rb-border);
}
.rb-btn-outline:hover { background: var(--rb-bg-alt); color: var(--rb-text); }

.rb-btn-success { background: var(--rb-success); color: white; }
.rb-btn-success:hover { background: #16A34A; color: white; }

.rb-btn-danger { background: var(--rb-danger); color: white; }
.rb-btn-danger:hover { background: #DC2626; color: white; }

.rb-btn-ghost {
    background: transparent;
    color: var(--rb-text-secondary);
    border: none;
    padding: 0.375rem 0.625rem;
}
.rb-btn-ghost:hover { background: var(--rb-bg-alt); color: var(--rb-text); }

.rb-btn-sm { padding: 0.25rem 0.625rem; font-size: var(--rb-font-size-sm); }
.rb-btn-lg { padding: 0.625rem 1.25rem; font-size: var(--rb-font-size-lg); }

/* --- Badges --- */
.rb-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 99px;
    font-size: var(--rb-font-size-xs);
    font-weight: 600;
    white-space: nowrap;
}

.rb-badge-primary { background: var(--rb-primary-bg); color: var(--rb-primary-text); } /* 5.94:1 */
.rb-badge-success { background: var(--rb-success-bg); color: #15803D; }
.rb-badge-warning { background: var(--rb-warning-bg); color: #A16207; }
.rb-badge-danger { background: var(--rb-danger-bg); color: #B91C1C; }
.rb-badge-info { background: var(--rb-info-bg); color: #1D4ED8; }
.rb-badge-neutral { background: var(--rb-bg-alt); color: var(--rb-text-secondary); }

/* --- Estado Reserva badges (confirmada=GREEN, sentada=BLUE) --- */
.rb-estado-pendiente {
    background: var(--rb-estado-pendiente-bg);
    color: var(--rb-estado-pendiente-color);
    border: 1px solid var(--rb-estado-pendiente-border);
}
.rb-estado-confirmada {
    background: var(--rb-estado-confirmada-bg);
    color: var(--rb-estado-confirmada-color);
    border: 1px solid var(--rb-estado-confirmada-border);
}
.rb-estado-sentada {
    background: var(--rb-estado-sentada-bg);
    color: var(--rb-estado-sentada-color);
    border: 1px solid var(--rb-estado-sentada-border);
}
.rb-estado-completada {
    background: var(--rb-estado-completada-bg);
    color: var(--rb-estado-completada-color);
    border: 1px solid var(--rb-estado-completada-border);
}
.rb-estado-noshow {
    background: var(--rb-estado-noshow-bg);
    color: var(--rb-estado-noshow-color);
    border: 1px solid var(--rb-estado-noshow-border);
}
.rb-estado-cancelada {
    background: var(--rb-estado-cancelada-bg);
    color: var(--rb-estado-cancelada-color);
    border: 1px solid var(--rb-estado-cancelada-border);
}

/* --- Tables --- */
.rb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--rb-font-size-base);
}

.rb-table th {
    text-align: left;
    padding: var(--rb-space-3) var(--rb-space-4);
    font-weight: 600;
    font-size: var(--rb-font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--rb-text-secondary);
    background: var(--rb-bg-alt);
    border-bottom: 1px solid var(--rb-border);
    white-space: nowrap;
}

.rb-table td {
    padding: var(--rb-space-3) var(--rb-space-4);
    border-bottom: 1px solid var(--rb-border);
    vertical-align: middle;
}

.rb-table tbody tr:hover {
    background: color-mix(in srgb, var(--rb-primary) 3%, white);
}

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

/* --- Empty State --- */
.rb-empty {
    text-align: center;
    padding: var(--rb-space-12) var(--rb-space-6);
    color: var(--rb-text-muted);
}

.rb-empty-icon {
    font-size: 2.5rem;
    margin-bottom: var(--rb-space-4);
    opacity: 0.5;
}

.rb-empty-title {
    font-family: var(--rb-font-display);
    font-size: var(--rb-font-size-lg);
    font-weight: 600;
    color: var(--rb-text-secondary);
    margin-bottom: var(--rb-space-2);
}

/* ===== 5. FORM COMPONENTS ===== */

/* Form Group */
.rb-form-group { margin-bottom: var(--rb-space-4); }
.rb-form-label { display: block; font-size: var(--rb-font-size-sm); font-weight: 500; color: var(--rb-text); margin-bottom: 4px; }
.rb-form-hint { font-size: var(--rb-font-size-xs); color: var(--rb-text-muted); margin-top: 2px; }
.rb-form-error { font-size: var(--rb-font-size-xs); color: var(--rb-danger); margin-top: 2px; }

/* Input */
.rb-input {
    width: 100%;
    padding: 8px 12px;
    font-size: var(--rb-font-size-sm);
    border: 1px solid var(--rb-border);
    border-radius: var(--rb-radius-md);
    background: white;
    color: var(--rb-text);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.rb-input:focus {
    outline: none;
    border-color: var(--rb-primary);
    box-shadow: var(--rb-focus-ring);
}
.rb-input:disabled {
    background: var(--rb-bg-muted);
    cursor: not-allowed;
    opacity: 0.7;
}
.rb-input.is-invalid { border-color: var(--rb-danger); }
.rb-input.is-invalid:focus { box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1); }

/* Select */
.rb-select {
    width: 100%;
    padding: 8px 12px;
    font-size: var(--rb-font-size-sm);
    border: 1px solid var(--rb-border);
    border-radius: var(--rb-radius-md);
    background: white;
    color: var(--rb-text);
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748B' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}
.rb-select:focus {
    outline: none;
    border-color: var(--rb-primary);
    box-shadow: var(--rb-focus-ring);
}
.rb-select:disabled {
    background-color: var(--rb-bg-muted);
    cursor: not-allowed;
    opacity: 0.7;
}
.rb-select.is-invalid { border-color: var(--rb-danger); }
.rb-select.is-invalid:focus { box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1); }

/* Textarea */
.rb-textarea {
    width: 100%;
    padding: 8px 12px;
    font-size: var(--rb-font-size-sm);
    border: 1px solid var(--rb-border);
    border-radius: var(--rb-radius-md);
    background: white;
    color: var(--rb-text);
    transition: border-color 0.15s, box-shadow 0.15s;
    min-height: 80px;
    resize: vertical;
}
.rb-textarea:focus {
    outline: none;
    border-color: var(--rb-primary);
    box-shadow: var(--rb-focus-ring);
}
.rb-textarea:disabled {
    background: var(--rb-bg-muted);
    cursor: not-allowed;
    opacity: 0.7;
}
.rb-textarea.is-invalid { border-color: var(--rb-danger); }
.rb-textarea.is-invalid:focus { box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1); }

/* ===== 6. MODAL, ALERT, TOAST, SPINNER ===== */

/* --- Modal --- */
.rb-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}
.rb-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.rb-modal {
    background: white;
    border-radius: var(--rb-radius-lg);
    box-shadow: var(--rb-shadow-xl);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(10px);
    transition: transform 0.2s;
}
.rb-modal-overlay.active .rb-modal {
    transform: translateY(0);
}
.rb-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--rb-space-4);
    border-bottom: 1px solid var(--rb-border);
}
.rb-modal-title {
    font-family: var(--rb-font-display);
    font-size: var(--rb-font-size-lg);
    font-weight: 600;
}
.rb-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--rb-space-1);
    color: var(--rb-text-muted);
    font-size: 1.25rem;
    line-height: 1;
    border-radius: var(--rb-radius-sm);
    transition: background 0.15s, color 0.15s;
}
.rb-modal-close:hover {
    background: var(--rb-bg-alt);
    color: var(--rb-text);
}
.rb-modal-body {
    padding: var(--rb-space-4);
}
.rb-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--rb-space-2);
    padding: var(--rb-space-4);
    border-top: 1px solid var(--rb-border);
}

/* --- Diálogo de confirmación (window.rbConfirm) --- */
/* Sustituye a confirm() nativo: mismo lenguaje visual que el resto del sistema. */
.rb-confirm { max-width: 440px; }

.rb-confirm-body {
    display: flex;
    align-items: flex-start;
    gap: var(--rb-space-3);
    padding: var(--rb-space-4);
}

.rb-confirm-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    background: var(--rb-primary-bg);
    color: var(--rb-primary-text);
}
.rb-confirm-danger .rb-confirm-icon {
    background: var(--rb-danger-bg);
    color: #B91C1C;
}

.rb-confirm-content { flex: 1; min-width: 0; }

.rb-confirm-title {
    font-family: var(--rb-font-display);
    font-size: var(--rb-font-size-lg);
    font-weight: 600;
    color: var(--rb-text);
    margin: 0 0 var(--rb-space-1);
}

.rb-confirm-message {
    font-size: var(--rb-font-size-sm);
    color: var(--rb-text-secondary);
    line-height: 1.5;
    margin: 0;
    word-break: break-word;
}

/* --- Alert --- */
.rb-alert {
    padding: var(--rb-space-3) var(--rb-space-4);
    border-radius: var(--rb-radius-md);
    font-size: var(--rb-font-size-sm);
    display: flex;
    align-items: flex-start;
    gap: var(--rb-space-2);
}
.rb-alert-success { background: #F0FDF4; color: #166534; border: 1px solid #BBF7D0; }
.rb-alert-danger  { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.rb-alert-warning { background: #FFFBEB; color: #92400E; border: 1px solid #FDE68A; }
.rb-alert-info    { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }

/* --- Toast --- */
.rb-toast-container {
    position: fixed;
    top: var(--rb-space-4);
    right: var(--rb-space-4);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--rb-space-2);
    pointer-events: none;
}
.rb-toast {
    pointer-events: auto;
    padding: var(--rb-space-3) var(--rb-space-4);
    border-radius: var(--rb-radius-md);
    background: white;
    box-shadow: var(--rb-shadow-lg);
    font-size: var(--rb-font-size-sm);
    display: flex;
    align-items: center;
    gap: var(--rb-space-2);
    min-width: 300px;
    max-width: 450px;
    animation: rb-toast-in 0.3s ease;
    border-left: 4px solid;
}
.rb-toast-success { border-left-color: var(--rb-success); }
.rb-toast-error   { border-left-color: var(--rb-danger); }
.rb-toast-warning { border-left-color: var(--rb-warning); }
.rb-toast-info    { border-left-color: var(--rb-info); }
.rb-toast-primary { border-left-color: var(--rb-primary); }

/* Piezas internas del toast (las genera rbToast en site.js — sin estilos inline) */
.rb-toast-icon { flex-shrink: 0; font-size: 1rem; line-height: 1; }
.rb-toast-success .rb-toast-icon { color: #15803D; }
.rb-toast-error   .rb-toast-icon { color: #B91C1C; }
.rb-toast-warning .rb-toast-icon { color: #A16207; }
.rb-toast-info    .rb-toast-icon { color: #1D4ED8; }
.rb-toast-primary .rb-toast-icon { color: var(--rb-primary-text); }

.rb-toast-message {
    flex: 1;
    color: var(--rb-text);
    line-height: 1.4;
    word-break: break-word;
}

.rb-toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--rb-text-muted);
    font-size: 1.125rem;
    line-height: 1;
    padding: 0 0 0 var(--rb-space-1);
    border-radius: var(--rb-radius-sm);
    transition: color 0.15s;
}
.rb-toast-close:hover { color: var(--rb-text); }

.rb-toast.rb-toast-leaving {
    animation: rb-toast-out 0.3s ease forwards;
}

@keyframes rb-toast-in {
    from { opacity: 0; transform: translateX(100%); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes rb-toast-out {
    from { opacity: 1; }
    to   { opacity: 0; transform: translateX(100%); }
}

/* --- Spinner / Loading --- */
.rb-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--rb-border);
    border-top-color: var(--rb-primary);
    border-radius: 50%;
    animation: rb-spin 0.6s linear infinite;
}
.rb-spinner-sm { width: 12px; height: 12px; }
.rb-spinner-lg { width: 24px; height: 24px; }

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

.rb-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: inherit;
}

/* ===== 7. UTILITY CLASSES ===== */

/* Flex utilities */
.rb-flex { display: flex; }
.rb-flex-col { flex-direction: column; }
.rb-flex-wrap { flex-wrap: wrap; }
.rb-items-center { align-items: center; }
.rb-justify-between { justify-content: space-between; }
.rb-justify-end { justify-content: flex-end; }
.rb-gap-1 { gap: var(--rb-space-1); }
.rb-gap-2 { gap: var(--rb-space-2); }
.rb-gap-3 { gap: var(--rb-space-3); }
.rb-gap-4 { gap: var(--rb-space-4); }

/* Text utilities */
.rb-text-sm { font-size: var(--rb-font-size-sm); }
.rb-text-xs { font-size: var(--rb-font-size-xs); }
.rb-text-muted { color: var(--rb-text-muted); }
.rb-text-bold { font-weight: 600; }
.rb-text-medium { font-weight: 500; }

/* Spacing utilities */
.rb-mt-2 { margin-top: var(--rb-space-2); }
.rb-mt-3 { margin-top: var(--rb-space-3); }
.rb-mt-4 { margin-top: var(--rb-space-4); }
.rb-mt-5 { margin-top: var(--rb-space-5); }
.rb-mb-3 { margin-bottom: var(--rb-space-3); }
.rb-mb-4 { margin-bottom: var(--rb-space-4); }
.rb-mb-5 { margin-bottom: var(--rb-space-5); }
.rb-p-0 { padding: 0; }
.rb-p-4 { padding: var(--rb-space-4); }
.rb-p-6 { padding: var(--rb-space-6); }

/* Grid */
.rb-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--rb-space-4); }
@media (max-width: 768px) { .rb-grid-2 { grid-template-columns: 1fr; } }

/* Width */
.rb-w-full { width: 100%; }
.rb-max-w-sm { max-width: 400px; }
.rb-max-w-md { max-width: 600px; }

/* Divider */
.rb-divider { border-top: 1px solid var(--rb-border); margin: var(--rb-space-4) 0; }

/* Section header (for Metricas-style sections) */
.rb-section-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--rb-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--rb-space-3);
}

/* Stat row (for TenantDetalle-style key-value rows) */
.rb-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Avatar circle */
.rb-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--rb-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    flex-shrink: 0;
}
.rb-avatar-sm { width: 24px; height: 24px; font-size: 0.6rem; }
.rb-avatar-lg { width: 36px; height: 36px; font-size: 0.85rem; }

/* Integration card (for Config page style) */
.rb-integration-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--rb-space-3);
    border: 1px solid var(--rb-border);
    border-radius: var(--rb-radius-md);
}
.rb-integration-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--rb-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: white;
}

/* Responsive helpers */
.rb-responsive-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--rb-space-4);
}

.rb-responsive-flex {
    display: flex;
    gap: var(--rb-space-4);
}

/* ===== 8. RESPONSIVE ===== */

/* Tablet: sidebar icon-only */
@media (max-width: 991.98px) {
    .rb-sidebar {
        width: var(--rb-sidebar-collapsed);
    }

    .rb-sidebar-brand-text,
    .rb-sidebar-section-title,
    .rb-nav-item span,
    .rb-nav-badge,
    .rb-sidebar-user-info {
        display: none;
    }

    .rb-nav-item {
        justify-content: center;
        padding: var(--rb-space-3);
    }

    .rb-sidebar-brand {
        justify-content: center;
        padding: 0;
        background: #1E293B;
    }

    .rb-sidebar-user {
        justify-content: center;
    }

    .rb-main {
        margin-left: var(--rb-sidebar-collapsed);
    }
}

/* Mobile: sidebar hidden, hamburger */
@media (max-width: 767.98px) {
    .rb-sidebar {
        transform: translateX(-100%);
        width: var(--rb-sidebar-width);
        background: #1E293B;
    }

    .rb-sidebar.open {
        transform: translateX(0);
    }

    .rb-sidebar-brand-text,
    .rb-sidebar-section-title,
    .rb-nav-item span,
    .rb-nav-badge,
    .rb-sidebar-user-info {
        display: revert;
    }

    .rb-nav-item {
        justify-content: flex-start;
        padding: var(--rb-space-2) var(--rb-space-3);
    }

    .rb-sidebar-brand {
        justify-content: flex-start;
        padding: 0 var(--rb-space-5);
        background: #1E293B;
    }

    .rb-sidebar-user {
        justify-content: flex-start;
    }

    .rb-main {
        margin-left: 0;
    }

    .rb-topbar-toggle {
        display: flex;
    }

    .rb-sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 1025;
    }

    .rb-sidebar-backdrop.open {
        display: block;
    }

    .rb-content {
        padding: var(--rb-space-4);
    }

    .rb-kpi-grid {
        grid-template-columns: 1fr 1fr;
    }

    .rb-page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Responsive tables */
    .rb-table th,
    .rb-table td {
        padding: var(--rb-space-2) var(--rb-space-2);
        font-size: 0.8rem;
    }

    /* Responsive buttons - touch targets */
    .rb-btn {
        min-height: 40px;
    }

    .rb-btn-sm {
        min-height: 36px;
        padding: 0.375rem 0.75rem;
    }

    .rb-btn-ghost {
        min-height: 40px;
        padding: 0.5rem 0.75rem;
    }

    .rb-responsive-grid-2 {
        grid-template-columns: 1fr;
    }

    .rb-responsive-flex {
        flex-direction: column;
    }
}

@media (max-width: 575.98px) {
    .rb-kpi-grid {
        grid-template-columns: 1fr;
    }

    .rb-content {
        padding: var(--rb-space-3);
    }

    .rb-page-header h1 {
        font-size: 1.25rem;
    }
}

/* ===== 9. ACCESSIBILITY ===== */

/* Skip link -- visible only on focus for keyboard navigation */
.rb-skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--rb-primary);
    color: white;
    padding: 8px 16px;
    z-index: 10000;
    font-size: var(--rb-font-size-sm);
    border-radius: 0 0 var(--rb-radius-md) 0;
    transition: top 0.2s;
    text-decoration: none;
}
.rb-skip-link:focus {
    top: 0;
}

/* Focus visible -- consistent outline across the application */
:focus-visible {
    outline: 2px solid var(--rb-primary);
    outline-offset: 2px;
}

/* Screen reader only -- visually hidden but accessible to assistive tech */
.rb-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ===== 10. AUTOCOMPLETE (combobox) ===== */

.rb-autocomplete {
    position: relative;
}

.rb-autocomplete-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 50;
    max-height: 280px;
    overflow-y: auto;
    margin: 0;
    padding: 4px;
    list-style: none;
    background: var(--rb-surface);
    border: 1px solid var(--rb-border);
    border-radius: var(--rb-radius-md);
    box-shadow: var(--rb-shadow-lg);
}

.rb-autocomplete-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--rb-space-3);
    width: 100%;
    padding: 0.5rem 0.625rem;
    border: 0;
    border-radius: var(--rb-radius-sm);
    background: transparent;
    text-align: left;
    font-family: var(--rb-font);
    font-size: var(--rb-font-size-sm);
    color: var(--rb-text);
    cursor: pointer;
}

.rb-autocomplete-option:hover,
.rb-autocomplete-option.is-active {
    background: var(--rb-bg-alt);
}

.rb-autocomplete-option:focus-visible {
    outline: 2px solid var(--rb-primary);
    outline-offset: -2px;
}

.rb-autocomplete-option-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.rb-autocomplete-option-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rb-autocomplete-option-meta {
    font-size: var(--rb-font-size-xs);
    color: var(--rb-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rb-autocomplete-option-create {
    color: var(--rb-primary-text);
    font-weight: 500;
}

.rb-autocomplete-empty {
    padding: 0.5rem 0.625rem;
    font-size: var(--rb-font-size-sm);
    color: var(--rb-text-muted);
}

.rb-autocomplete-selected {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--rb-space-3);
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--rb-border);
    border-radius: var(--rb-radius-md);
    background: var(--rb-bg-alt);
}

.rb-autocomplete-panel {
    display: flex;
    flex-direction: column;
    gap: var(--rb-space-3);
    margin-top: var(--rb-space-2);
    padding: var(--rb-space-3);
    border: 1px dashed var(--rb-border);
    border-radius: var(--rb-radius-md);
    background: var(--rb-bg-alt);
}
