/* ============================================================
   Setegua Theme — Tokens + Shell (sidebar, navbar, content-area)
   ------------------------------------------------------------
   Responsabilidad única: variables de diseño y estructura
   global de la aplicación. Los componentes viven en
   setegua-ui.css. Se integra con el toggle [data-bs-theme="dark"].
   ============================================================ */

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

/* ---- Tema Claro (por defecto) ---- */
:root,
[data-bs-theme="light"] {
    --brand-primary: #1f2151;
    --brand-accent: #ffc62e;

    --bg-base: #f4f6f9;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f0f2f5;

    --border-color: #e0e4e8;
    --input-border: #ced4da;

    --text-primary: #2b2f32;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;

    --color-green: #00c950;
    --color-celeste: #0092b8;
    --color-blue: #155dfc;
    --color-red: #e7000b;
    --color-yellow: #ffc62e;
    --color-emerald: #00bc7d;

    --soft-green: rgba(0, 201, 80, 0.15);
    --soft-celeste: rgba(0, 146, 184, 0.15);
    --soft-blue: rgba(21, 93, 252, 0.15);
    --soft-red: rgba(231, 0, 11, 0.15);
    --soft-yellow: rgba(255, 185, 0, 0.15);
    --soft-emerald: rgba(0, 188, 125, 0.15);
}

/* ---- Tema Oscuro ---- */
[data-bs-theme="dark"] {
    --brand-primary: #1f2151;
    --brand-accent: #ffdf20;

    --bg-base: #1e1e1e;
    --bg-surface: #252526;
    --bg-surface-hover: #333333;

    --border-color: #3e3e42;
    --input-border: #495057;

    --text-primary: #ffffff;
    --text-secondary: #a0a0a5;
    --text-muted: #6c757d;

    --color-green: #05df72;
    --color-celeste: #00d3f2;
    --color-blue: #50a2ff;
    --color-red: #fb2c36;
    --color-yellow: #ffdf20;
    --color-emerald: #00d492;

    --soft-green: rgba(5, 223, 114, 0.15);
    --soft-celeste: rgba(0, 211, 242, 0.15);
    --soft-blue: rgba(80, 162, 255, 0.15);
    --soft-red: rgba(251, 44, 54, 0.15);
    --soft-yellow: rgba(255, 223, 32, 0.15);
    --soft-emerald: rgba(0, 212, 146, 0.15);
}

/* ---- Body / Contenido base ---- */
body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Inter sólo en el área de contenido — sidebar conserva Roboto */
.content-area,
.top-navbar {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-feature-settings: 'cv11', 'ss01', 'ss03';
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

.top-navbar {
    background-color: var(--bg-surface);
}

.content-area h1,
.content-area h2,
.content-area h3,
.content-area h4,
.content-area h5,
.content-area h6 {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    letter-spacing: -0.02em;
}

/* ============================================================
   SIDEBAR (mantiene estructura y fuente Roboto de layout.css)
   ============================================================ */
.sidebar {
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    box-shadow: none;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    scrollbar-color: var(--border-color) var(--bg-surface);
}

.sidebar::-webkit-scrollbar-track {
    background: var(--bg-surface);
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border: 3px solid var(--bg-surface);
}

.sidebar .sidebar-header {
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    font-weight: 600;
    font-size: 1.2rem;
}

.sidebar .sidebar-header .bi {
    color: var(--text-primary);
}

.sidebar .nav-link {
    color: var(--text-secondary);
    font-weight: 500;
    border-radius: 8px;
    padding: 0.65rem 1rem;
    margin: 0.15rem 0.75rem;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.sidebar .nav-link:hover {
    color: var(--text-primary);
    background-color: var(--bg-surface-hover);
}

.sidebar .nav-link.active {
    background-color: var(--brand-primary);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(31, 33, 81, 0.3);
}

.sidebar .nav-link.active .bi {
    color: var(--color-yellow);
}

.sidebar .nav-link .bi {
    color: inherit;
}

.sidebar .dropdown-toggle::after {
    margin-left: auto;
    transition: transform 0.2s ease-in-out;
}

.sidebar .submenu {
    background-color: transparent;
    padding-left: 0.25rem;
    margin: 0 0.75rem 0.25rem 0.75rem;
    border-radius: 0 0 8px 8px;
}

.sidebar .submenu .nav-link {
    padding: 0.5rem 1rem 0.5rem 2.75rem;
    font-size: 0.875rem;
    margin: 0.1rem 0;
}

.sidebar .submenu .nav-link:hover,
.sidebar .submenu .nav-link.active {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
    box-shadow: none;
}

.sidebar .submenu .nav-link.active {
    color: var(--color-blue);
}

.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 0.5rem;
    margin-top: auto;
}

.sidebar-footer .nav-link {
    color: var(--color-red);
}

.sidebar-footer .nav-link:hover {
    color: var(--color-red);
    background-color: var(--soft-red);
}

.sidebar-footer .btn-link {
    color: var(--color-red);
    text-decoration: none;
    padding: 0.65rem 1rem;
    margin: 0.15rem 0.75rem;
    border-radius: 8px;
    font-weight: 500;
    width: calc(100% - 1.5rem);
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: background-color 0.2s ease;
}

.sidebar-footer .btn-link:hover {
    color: var(--color-red);
    background-color: var(--soft-red);
}

/* ============================================================
   TOP NAVBAR
   ============================================================ */
.top-navbar {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    box-shadow: none;
    height: 70px;
    padding: 0 2rem;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.top-navbar .navbar-brand {
    color: var(--text-primary);
    font-weight: 600;
}

.top-navbar .navbar-toggler {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.4rem;
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.top-navbar .navbar-toggler:hover {
    color: var(--color-yellow);
    background-color: var(--soft-yellow);
}

.nav-icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.15rem;
    padding: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease;
    margin-left: 0.25rem;
}

.nav-icon-btn:hover {
    color: var(--color-yellow);
    background-color: var(--soft-yellow);
}

/* User profile dropdown */
.top-navbar .user-profile {
    margin-left: 0.5rem;
    padding-left: 1rem;
    border-left: 1px solid var(--border-color);
}

.top-navbar .user-profile img,
.top-navbar .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0;
}

.top-navbar .user-avatar {
    background-color: var(--brand-primary);
    color: var(--color-yellow);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.top-navbar .user-profile .username {
    color: var(--text-primary);
    font-weight: 500;
    margin-left: 0.6rem;
}

.top-navbar .user-profile .dropdown-toggle::after {
    color: var(--text-secondary);
    margin-left: 0.35rem;
}

/* Dropdown menu afinado para tema oscuro */
/* ============================================================
   SEARCH BAR
   ============================================================ */
.search-container {
    position: relative;
    display: none;
    margin-left: 0.5rem;
}

.search-container.active {
    display: flex !important;
    align-items: center;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    font-size: 1rem;
    pointer-events: none;
}

.search-input {
    width: 280px;
    padding: 0.5rem 2.5rem 0.5rem 2.25rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-surface);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(31, 33, 81, 0.1);
}

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

.search-close {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 4px;
    cursor: pointer;
    border-radius: 4px;
    transition: color 0.2s ease, background-color 0.2s ease;
}

.search-close:hover {
    color: var(--text-primary);
    background-color: var(--bg-surface-hover);
}

.search-results {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    display: none;
}

.search-results.active {
    display: block;
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 0.65rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: background-color 0.15s ease;
    gap: 0.75rem;
}

.search-result-item:hover {
    background-color: var(--bg-surface-hover);
}

.search-result-item .bi {
    color: var(--text-secondary);
    font-size: 1rem;
}

.search-result-item span {
    font-size: 0.875rem;
    font-weight: 500;
}

.search-result-item mark {
    background-color: var(--soft-yellow);
    color: var(--text-primary);
    padding: 0 2px;
    border-radius: 2px;
}

.search-no-results {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.search-section-title {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    background-color: var(--bg-base);
    border-bottom: 1px solid var(--border-color);
}

/* Highlight cuando hay búsqueda activa en sidebar */
.sidebar.searching .nav-item {
    opacity: 0.4;
}

.sidebar.searching .nav-item.highlighted {
    opacity: 1;
}

[data-bs-theme="dark"] .dropdown-menu {
    --bs-dropdown-bg: var(--bg-surface);
    --bs-dropdown-color: var(--text-primary);
    --bs-dropdown-border-color: var(--border-color);
    --bs-dropdown-link-color: var(--text-primary);
    --bs-dropdown-link-hover-bg: var(--bg-surface-hover);
    --bs-dropdown-link-hover-color: var(--text-primary);
    --bs-dropdown-divider-bg: var(--border-color);
}
