/* ============================================================================
   SPURA HUB v3 — Layout (Shell, Sidebar, Topbar, Page Content)
   ============================================================================ */

/* ─── App Shell ───────────────────────────────────────────────────────── */

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ─────────────────────────────────────────────────────────── */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--ink-900);
    border-right: none;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

/* Brillo sutil en la parte superior del sidebar */
.sidebar::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 200px;
    background: linear-gradient(180deg, rgba(20, 184, 166, .06) 0%, transparent 100%);
    pointer-events: none;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.125rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
    position: relative;
}
.sidebar-brand-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    filter: brightness(0) invert(1);
    opacity: .9;
}
.sidebar-brand-name {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -.01em;
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
    -webkit-text-fill-color: unset;
    color: rgba(255, 255, 255, .92);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.875rem 0;
    /* scrollbar-width: Firefox; -webkit-scrollbar fallback handles Chrome/Safari */
    scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.sidebar-section { margin-bottom: 1.25rem; }
.sidebar-section-title {
    padding: 0.375rem 1.25rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, .25);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 400;
    color: rgba(255, 255, 255, .5);
    text-decoration: none;
    transition: all 0.15s ease;
    position: relative;
}
.sidebar-link:hover {
    background: rgba(255, 255, 255, .04);
    color: rgba(255, 255, 255, .8);
    text-decoration: none;
}
.sidebar-link.active {
    background: rgba(255, 255, 255, .07);
    color: rgba(255, 255, 255, .95);
    font-weight: 500;
}
/* Indicador de item activo */
.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    background: var(--brand-400);
    border-radius: 0 3px 3px 0;
}

/* Tema oscuro — el sidebar ya es oscuro, mantenemos coherencia */
:root[data-theme='dark'] .sidebar-link.active {
    background: rgba(255, 255, 255, .07);
    color: rgba(255, 255, 255, .95);
}

.sidebar-link-icon {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    opacity: .75;
    transition: opacity .15s;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.sidebar-link:hover .sidebar-link-icon,
.sidebar-link.active .sidebar-link-icon {
    opacity: 1;
}

.sidebar-link-badge {
    margin-left: auto;
    padding: 2px 7px;
    font-size: 0.6875rem;
    font-weight: 600;
    background: var(--brand-500);
    color: white;
    border-radius: var(--radius-full);
}

.sidebar-footer {
    padding: 0.875rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, .06);
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: rgba(255, 255, 255, .85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, .3);
    margin-top: 1px;
}

/* Avatar en sidebar */
.sidebar-footer .avatar {
    background: linear-gradient(135deg, var(--brand-400), var(--brand-700));
    box-shadow: 0 2px 6px rgba(13, 148, 136, .3);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    z-index: 99;
}

/* ─── Topbar ──────────────────────────────────────────────────────────── */

.topbar {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    gap: 1rem;
    height: var(--topbar-height);
    padding: 0 1.5rem;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    z-index: 50;
}

.topbar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
}
.topbar-toggle:hover { background: var(--bg-secondary); }

.topbar-search {
    flex: 1;
    max-width: 380px;
}
.topbar-search-wrapper {
    position: relative;
}
.topbar-search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
    color: var(--text-muted);
    pointer-events: none;
}
.topbar-search-wrapper .form-input {
    padding-left: 2.25rem;
    padding-right: 3rem;
    background: var(--bg-secondary);
    border-color: transparent;
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
}
.topbar-search-wrapper .form-input:focus {
    background: var(--bg-surface);
    border-color: var(--brand-500);
    border-radius: var(--radius-md);
}
/* Atajo ⌘K */
.topbar-search-wrapper .search-kbd {
    position: absolute;
    right: 0.625rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 2px;
    pointer-events: none;
}
.topbar-search-wrapper .search-kbd kbd {
    font-family: var(--font-sans);
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1px 5px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: auto;
}
.topbar-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: none;
    border: none;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}
.topbar-action-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}
.topbar-notification-dot {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 7px;
    height: 7px;
    background: var(--danger-500);
    border-radius: 50%;
    border: 1.5px solid var(--bg-surface);
}

/* ─── Main Content ────────────────────────────────────────────────────── */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
}

.page-content {
    padding: 1.75rem 1.75rem;
}

/* ─── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-backdrop.show {
        display: block;
    }
    .main-content {
        margin-left: 0;
    }
    .topbar-toggle {
        display: flex;
    }
    .topbar-search {
        max-width: 200px;
    }
    .stats-row {
        grid-template-columns: 1fr 1fr;
    }
    .content-grid {
        grid-template-columns: 1fr;
    }
    .page-header {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .stats-row {
        grid-template-columns: 1fr;
    }
    .page-content {
        padding: 1rem;
    }
}
