/* ===========================================================
   RA.AU - Estilos profesionales (Bootstrap 5.3 + temas claro/oscuro)
   Inspiración: SaaS/fintech moderno (Linear, Stripe, Vercel)
   =========================================================== */

:root {
    color-scheme: light dark;

    /* Paleta corporativa (indigo + slate) */
    --raau-primary:    #4f46e5;   /* indigo-600 */
    --raau-primary-2:  #6366f1;   /* indigo-500 */
    --raau-primary-3:  #818cf8;   /* indigo-400 */
    --raau-accent:     #06b6d4;   /* cyan-500  */
    --raau-success:    #10b981;
    --raau-warning:    #f59e0b;
    --raau-danger:     #ef4444;

    --raau-ink:        #0f172a;   /* slate-900 (texto headings) */
    --raau-ink-soft:   #475569;   /* slate-600 (texto secundario) */
    --raau-line:       #e2e8f0;   /* slate-200 (bordes sutiles)  */

    --raau-radius:     14px;
    --raau-radius-sm:  10px;
    --raau-shadow-sm:  0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.05);
    --raau-shadow:     0 4px 12px rgba(15,23,42,.06), 0 2px 4px rgba(15,23,42,.04);
    --raau-shadow-lg:  0 12px 32px rgba(15,23,42,.10), 0 4px 12px rgba(15,23,42,.06);
    --raau-bg-soft:    #f8fafc;   /* slate-50 */
    --raau-bg-hover:   #f1f5f9;   /* slate-100 */
}

[data-bs-theme="dark"] {
    --raau-ink:        #f1f5f9;
    --raau-ink-soft:   #94a3b8;
    --raau-line:       #1e293b;
    --raau-bg-soft:    #0b1220;
    --raau-bg-hover:   #111a2c;
    --raau-shadow-sm:  0 1px 2px rgba(0,0,0,.4), 0 1px 3px rgba(0,0,0,.35);
    --raau-shadow:     0 4px 14px rgba(0,0,0,.45);
    --raau-shadow-lg:  0 16px 40px rgba(0,0,0,.55);
}

/* ---------- Base ---------- */
html, body { min-height: 100vh; }

body {
    background: var(--raau-bg-soft);
    color: var(--bs-body-color);
    font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-feature-settings: 'cv11', 'ss01', 'ss03';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color .25s ease, color .25s ease;
}
[data-bs-theme="dark"] body { background: #060a14; }

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--raau-ink);
}
h2 { font-size: 1.55rem; }
h6.text-uppercase { letter-spacing: .08em; font-size: .72rem; font-weight: 600; }

code {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .85em;
    color: var(--raau-primary);
    background: rgba(99,102,241,.08);
    padding: 1px 6px;
    border-radius: 6px;
}
[data-bs-theme="dark"] code { background: rgba(99,102,241,.18); color: #c7d2fe; }

a { color: var(--raau-primary); text-decoration: none; }
a:hover { color: var(--raau-primary-2); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Navbar ---------- */
.navbar-raau {
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid rgba(255,255,255,.05);
    --bs-navbar-color: rgba(255,255,255,.78);
    --bs-navbar-hover-color: #ffffff;
    --bs-navbar-active-color: #ffffff;
    --bs-navbar-brand-color: #ffffff;
    --bs-navbar-brand-hover-color: #ffffff;
    --bs-navbar-toggler-border-color: rgba(255,255,255,.15);
    --bs-navbar-toggler-icon-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255,255,255,0.85%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
    min-height: 60px;
    padding-top: .35rem;
    padding-bottom: .35rem;
}

.navbar-raau .navbar-brand {
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
}
.navbar-raau .navbar-brand i {
    background: linear-gradient(135deg, var(--raau-primary-3), var(--raau-accent));
    color: #fff;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    box-shadow: 0 4px 10px rgba(99,102,241,.4);
}

.navbar-raau .nav-link {
    font-weight: 500;
    font-size: .92rem;
    padding: .45rem .8rem;
    border-radius: 8px;
    margin: 0 2px;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    transition: background-color .15s ease, color .15s ease;
}
.navbar-raau .nav-link:hover { background: rgba(255,255,255,.08); }
.navbar-raau .nav-link.active,
.navbar-raau .nav-item.show > .nav-link { background: rgba(99,102,241,.22); color: #fff; }

.navbar-raau .nav-link i { opacity: .85; }

.navbar-raau .dropdown-menu {
    border: 1px solid var(--raau-line);
    box-shadow: var(--raau-shadow-lg);
    border-radius: var(--raau-radius-sm);
    overflow: hidden;
    padding: .35rem;
    margin-top: .35rem;
}
.navbar-raau .dropdown-item {
    border-radius: 8px;
    padding: .5rem .7rem;
    font-size: .9rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.navbar-raau .dropdown-item:hover,
.navbar-raau .dropdown-item:focus { background: var(--raau-bg-hover); color: var(--raau-primary); }
.navbar-raau .dropdown-item.active { background: var(--raau-primary); color: #fff; }
.navbar-raau .dropdown-header { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--raau-ink-soft); }

/* Botón de tema */
#themeToggle {
    transition: transform .25s ease;
    border-color: rgba(255,255,255,.25);
    color: #fff;
}
#themeToggle:hover { transform: rotate(-12deg); background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.4); }

/* ---------- Cards ---------- */
.card {
    background: var(--bs-body-bg);
    border: 1px solid var(--raau-line);
    border-radius: var(--raau-radius);
    box-shadow: var(--raau-shadow-sm);
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.card-header, .card-footer { background: transparent; border-color: var(--raau-line); }
.card-header { padding: 1rem 1.25rem; }
.card-body { padding: 1.25rem; }

.card.shadow-sm { box-shadow: var(--raau-shadow) !important; }
.card.hover-shadow:hover,
.card.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: var(--raau-shadow-lg);
    border-color: var(--raau-primary-3);
}

/* Hero / cards de marca */
.card.bg-primary,
.card-hero {
    background: linear-gradient(135deg, var(--raau-primary), var(--raau-primary-2)) !important;
    color: #fff !important;
    border: 0;
    box-shadow: 0 12px 28px rgba(79,70,229,.28);
}
.card.bg-primary .text-body-secondary,
.card-hero .text-body-secondary { color: rgba(255,255,255,.8) !important; }

/* ---------- Botones ---------- */
.btn {
    border-radius: var(--raau-radius-sm);
    font-weight: 500;
    font-size: .9rem;
    padding: .5rem 1rem;
    transition: transform .12s ease, box-shadow .15s ease, background-color .15s ease;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: .35rem .7rem; font-size: .82rem; border-radius: 8px; }
.btn-lg { padding: .7rem 1.4rem; font-size: 1rem; border-radius: 12px; }

.btn-primary {
    background: var(--raau-primary);
    border-color: var(--raau-primary);
}
.btn-primary:hover, .btn-primary:focus {
    background: #4338ca;
    border-color: #4338ca;
    box-shadow: 0 6px 18px rgba(79,70,229,.35);
}

.btn-outline-primary { border-color: var(--raau-primary); color: var(--raau-primary); }
.btn-outline-primary:hover { background: var(--raau-primary); border-color: var(--raau-primary); }

.btn-light { background: var(--raau-bg-hover); border-color: var(--raau-line); color: var(--raau-ink); }
.btn-light:hover { background: var(--raau-line); }

/* ---------- Tablas ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .85rem 1rem; vertical-align: middle; }
.table thead th {
    text-transform: uppercase;
    font-size: .72rem;
    letter-spacing: .06em;
    color: var(--raau-ink-soft);
    font-weight: 600;
    border-bottom: 1px solid var(--raau-line);
    background: var(--raau-bg-soft);
}
[data-bs-theme="dark"] .table thead th { background: rgba(255,255,255,.02); }

.table-hover > tbody > tr:hover > * {
    background-color: var(--raau-bg-hover);
    --bs-table-color-state: var(--bs-body-color);
}

/* ---------- Formularios ---------- */
.form-control, .form-select {
    border-radius: var(--raau-radius-sm);
    padding: .55rem .85rem;
    border-color: var(--raau-line);
    font-size: .92rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:hover, .form-select:hover { border-color: #cbd5e1; }
.form-control:focus, .form-select:focus {
    border-color: var(--raau-primary);
    box-shadow: 0 0 0 4px rgba(79,70,229,.15);
}
.form-label { font-weight: 500; font-size: .88rem; color: var(--raau-ink); margin-bottom: .35rem; }
.form-text { font-size: .78rem; color: var(--raau-ink-soft); }
.input-group > .input-group-text { background: var(--raau-bg-soft); border-color: var(--raau-line); }

/* Switches más prominentes */
.form-check-input:checked {
    background-color: var(--raau-primary);
    border-color: var(--raau-primary);
}
.form-switch .form-check-input { width: 2.4em; height: 1.3em; }

/* ---------- Badges ---------- */
.badge {
    font-weight: 500;
    font-size: .72rem;
    padding: .35em .6em;
    border-radius: 6px;
    letter-spacing: .01em;
    display: inline-flex;
    align-items: center;
    gap: .25rem;
}
.badge.bg-light { color: var(--raau-ink); border: 1px solid var(--raau-line); }
[data-bs-theme="dark"] .badge.bg-light { background: rgba(255,255,255,.08) !important; color: var(--raau-ink); border-color: rgba(255,255,255,.1); }

/* ---------- Alerts ---------- */
.alert {
    border: 1px solid transparent;
    border-radius: var(--raau-radius-sm);
    padding: .85rem 1rem;
    font-size: .9rem;
}
.alert-success { background: rgba(16,185,129,.08); border-color: rgba(16,185,129,.25); color: #047857; }
.alert-warning { background: rgba(245,158,11,.08); border-color: rgba(245,158,11,.3);  color: #b45309; }
.alert-danger  { background: rgba(239,68,68,.08);  border-color: rgba(239,68,68,.3);   color: #b91c1c; }
.alert-info    { background: rgba(6,182,212,.08);  border-color: rgba(6,182,212,.3);   color: #0e7490; }
[data-bs-theme="dark"] .alert-success { color: #6ee7b7; }
[data-bs-theme="dark"] .alert-warning { color: #fcd34d; }
[data-bs-theme="dark"] .alert-danger  { color: #fca5a5; }
[data-bs-theme="dark"] .alert-info    { color: #67e8f9; }

/* ---------- Breadcrumb ---------- */
.breadcrumb {
    font-size: .85rem;
    margin-bottom: 0;
}
.breadcrumb-item + .breadcrumb-item::before { color: var(--raau-ink-soft); content: "›"; }
.breadcrumb-item a { color: var(--raau-ink-soft); }

/* ---------- Page header ---------- */
.page-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
}
.page-header h2 { margin-bottom: .25rem; }
.page-header p { color: var(--raau-ink-soft); margin-bottom: 0; }

/* ---------- Empty states ---------- */
.empty-state {
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--raau-ink-soft);
}
.empty-state i { font-size: 3rem; opacity: .3; }

/* ---------- Barra de empresas (sub-navbar) ---------- */
.empresas-bar {
    background: var(--bs-body-bg);
    border-bottom-color: var(--raau-line) !important;
    box-shadow: 0 1px 0 var(--raau-line);
}
.empresas-bar::-webkit-scrollbar { height: 6px; }
.empresas-bar::-webkit-scrollbar-thumb { background: var(--raau-line); }

.empresa-pill {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    transition: transform .15s ease, box-shadow .15s ease;
    border-width: 1px;
    white-space: nowrap;
}
.empresa-pill:hover { transform: translateY(-1px); }
.empresa-pill.active,
.empresa-pill.btn-primary {
    box-shadow: 0 4px 12px rgba(79,70,229,.28);
    border-color: var(--raau-primary);
}
.empresa-pill code { background: transparent; padding: 0; color: inherit; }

/* ---------- Selector centrado de empresa (navbar) ---------- */
.raau-empresa-prompt {
    min-height: calc(100vh - 60px - 100px);
    padding: 2rem 1rem;
}
.raau-empresa-selector {
    min-width: 280px;
    max-width: 460px;
}
.raau-empresa-select {
    background-color: rgba(255,255,255,.10);
    color: #fff;
    border: 1px solid rgba(255,255,255,.25);
    font-weight: 600;
    font-size: .9rem;
    border-radius: 999px;
    padding: .35rem 2rem .35rem 1rem;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    transition: background-color .15s ease, border-color .15s ease;
}
.raau-empresa-select:hover {
    background-color: rgba(255,255,255,.18);
    border-color: rgba(255,255,255,.4);
    color: #fff;
}
.raau-empresa-select:focus {
    background-color: rgba(255,255,255,.20);
    border-color: var(--raau-primary-3);
    box-shadow: 0 0 0 4px rgba(129,140,248,.25);
    color: #fff;
}
.raau-empresa-select option {
    background: #0f172a;
    color: #fff;
    font-weight: 500;
}
@media (max-width: 991.98px) {
    .raau-empresa-selector { min-width: 100%; max-width: 100%; }
}

/* ---------- Sidebar / Shell de gestión ---------- */
.raau-shell {
    display: flex;
    align-items: stretch;
    min-height: calc(100vh - 60px);
    position: relative;
}

.raau-sidebar {
    flex: 0 0 260px;
    width: 260px;
    background: var(--bs-body-bg);
    border-right: 1px solid var(--raau-line);
    position: sticky;
    top: 60px;
    align-self: flex-start;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    z-index: 1015;
    padding: 0;
}
[data-bs-theme="dark"] .raau-sidebar { background: #0a1120; }

.raau-sidebar-mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--raau-line);
}

.raau-sidebar-section {
    padding: .85rem .5rem .25rem;
    border-bottom: 1px solid var(--raau-line);
}
.raau-sidebar-section:last-of-type { border-bottom: 0; }

.raau-sidebar-title {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--raau-ink-soft);
    padding: .35rem .65rem .55rem;
}
.raau-sidebar-title i { font-size: .85rem; color: var(--raau-primary); }

.raau-sidebar-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .5rem .75rem;
    margin: 1px .25rem;
    border-radius: 8px;
    color: var(--raau-ink);
    font-size: .88rem;
    font-weight: 500;
    text-decoration: none;
    transition: background-color .12s ease, color .12s ease, transform .1s ease;
}
.raau-sidebar-link:hover {
    background: var(--raau-bg-hover);
    color: var(--raau-primary);
    text-decoration: none;
    transform: translateX(2px);
}
.raau-sidebar-link.active {
    background: rgba(79,70,229,.10);
    color: var(--raau-primary);
}
.raau-sidebar-link i {
    font-size: 1rem;
    flex-shrink: 0;
    width: 18px;
    text-align: center;
}
.raau-sidebar-link span { flex: 1; }
.raau-sidebar-link.link-create {
    border-left: 3px solid transparent;
    padding-left: calc(.75rem - 3px);
}
.raau-sidebar-link.link-create:hover { border-left-color: var(--raau-primary); }
.raau-sidebar-link.sub {
    padding-left: 2rem;
    font-size: .82rem;
    opacity: .85;
}

.raau-sidebar-footer {
    border-top: 1px solid var(--raau-line);
    margin-top: .5rem;
}
.raau-sidebar-footer kbd {
    background: var(--raau-bg-hover);
    border: 1px solid var(--raau-line);
    color: var(--raau-ink);
    border-radius: 4px;
    padding: 1px 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: .7rem;
}

.raau-main {
    flex: 1 1 auto;
    min-width: 0;
    padding: 1.5rem;
    background: var(--raau-bg-soft);
}

/* Backdrop oscuro para móvil */
.raau-sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1044;
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease;
}
.raau-sidebar-backdrop.show { opacity: 1; visibility: visible; }

/* Botón flotante para abrir sidebar en móvil */
.raau-sidebar-toggle {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    z-index: 1030;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    box-shadow: 0 6px 18px rgba(79,70,229,.45);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    padding: 0;
}

@media (max-width: 991.98px) {
    .raau-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        max-height: 100vh;
        z-index: 1045;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 8px 0 32px rgba(0,0,0,.18);
    }
    .raau-sidebar.show { transform: translateX(0); }
    .raau-main { padding: 1rem; }
}

/* ---------- Footer ---------- */
footer {
    font-size: .85rem;
    background: transparent !important;
    border-top: 1px solid var(--raau-line) !important;
    color: var(--raau-ink-soft);
    padding: 1.25rem 0;
}

/* ---------- Scrollbar (cosmético) ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--raau-line); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #cbd5e1; background-clip: padding-box; border: 2px solid transparent; }

/* ---------- Estilos legacy (login dark) ---------- */
.bg-panel { background: linear-gradient(135deg, #0b1220, #111827); border: 1px solid #1e293b; }
.card-dark { background: #0f172a; border: 1px solid #1e293b; color: #fff; border-radius: var(--raau-radius); }
.shadow-soft { box-shadow: 0 24px 60px rgba(0,0,0,.45); }
.text-secondary-light { color: #94a3b8; }

/* ---------- Animaciones suaves de entrada ---------- */
@keyframes raauFadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
main > .container, main > .container-fluid { animation: raauFadeUp .25s ease both; }
