/* ==========================================================================
   P2P HUB PRO - DASHBOARD ROOT (GLASSMORPHISM)
   ========================================================================== */

:root {
    --bg-dark: #07090C;
    --bg-panel: rgba(18, 22, 28, 0.65);
    --bg-panel-hover: rgba(28, 33, 39, 0.85);

    --accent-yellow: #FCD535;
    --accent-glow: rgba(252, 213, 53, 0.4);

    --text-main: #EAECEF;
    --text-muted: #848E9C;

    --success: #0ECB81;
    --danger: #F6465D;
    --warning: #F0B90B;

    --border-glass: rgba(255, 255, 255, 0.05);
    --border-accent: rgba(252, 213, 53, 0.2);

    --font-heading: 'Outfit', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;

    --ticker-height: 34px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    margin: 0;
    padding: var(--ticker-height) 0 0;
    font-family: var(--font-body);
    background-color: var(--bg-dark);
    background-image: radial-gradient(circle at 15% 50%, rgba(252, 213, 53, 0.03), transparent 25%),
                      radial-gradient(circle at 85% 30%, rgba(252, 213, 53, 0.03), transparent 25%);
    color: var(--text-main);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ==========================================================================
   TICKER BANCARIO
   ========================================================================== */
.ticker-wrap {
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    height: var(--ticker-height);
    z-index: 1000;
    overflow: hidden;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.8);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.ticker {
    display: inline-block;
    white-space: nowrap;
    padding-left: 100%;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.3px;
    animation: ticker-anim 40s linear infinite;
}
.ticker:hover { animation-play-state: paused; }
@keyframes ticker-anim {
    0% { transform: translate3d(0, 0, 0); }
    100% { transform: translate3d(-100%, 0, 0); }
}
.ticker-wrap.normal { background: linear-gradient(90deg, #0d1117, #161b22); color: #58a6ff; }
.ticker-wrap.warning { background: linear-gradient(90deg, #d29922, #b07d12); color: #000; }
.ticker-wrap.danger { background: linear-gradient(90deg, #f85149, #b92b27); color: #fff; }

@media (prefers-reduced-motion: reduce) {
    .ticker { animation: none; padding-left: 16px; }
}

/* ==========================================================================
   MENÚ LATERAL
   ========================================================================== */
.floating-nav {
    width: 290px;
    flex-shrink: 0;
    height: calc(100vh - var(--ticker-height) - 32px);
    margin: 16px 0 16px 16px;
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    z-index: 100;
    transition: transform 0.3s ease;
}

.logo-container {
    display: flex;
    align-items: center;
    padding: 22px 24px 16px;
    gap: 12px;
}
.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent-yellow), #d4b228);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-size: 1.5rem;
    box-shadow: 0 0 15px var(--accent-glow);
}
.logo-text {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.4rem;
    letter-spacing: 1px;
    margin: 0;
    background: linear-gradient(to right, #FFF, var(--accent-yellow));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.app-count {
    margin-left: auto;
    font-size: 0.72rem;
    color: var(--text-muted);
    border: 1px solid var(--border-glass);
    border-radius: 999px;
    padding: 2px 8px;
}

.nav-links {
    list-style: none;
    padding: 0 12px 12px;
    margin: 0;
    overflow-y: auto;
    flex-grow: 1;
}
.nav-links::-webkit-scrollbar { width: 4px; }
.nav-links::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); border-radius: 4px; }

.nav-section {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 1.2px;
    padding: 14px 10px 6px;
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
    border-radius: 8px;
}
.nav-section:hover, .nav-section:focus-visible { color: var(--text-main); outline: none; }
.nav-section > i:first-child { width: 16px; text-align: center; font-size: 0.8rem; }
.section-count { margin-left: auto; font-size: 0.65rem; opacity: 0.7; }
.nav-section .chevron { font-size: 0.65rem; transition: transform 0.2s ease; }
.nav-section.collapsed .chevron { transform: rotate(-90deg); }

.nav-item {
    display: flex;
    align-items: center;
    padding: 9px 12px;
    margin-bottom: 2px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
    font-size: 0.88rem;
    font-weight: 500;
    border-left: 3px solid transparent;
}
.nav-item i {
    width: 22px;
    font-size: 0.95rem;
    margin-right: 10px;
    text-align: center;
}
.nav-item .link-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover, .nav-item:focus-visible {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    outline: none;
}
.nav-item.active {
    background: linear-gradient(90deg, rgba(252, 213, 53, 0.1), transparent);
    color: var(--accent-yellow);
    border-left-color: var(--accent-yellow);
}
.overlap-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(132, 142, 156, 0.5);
    margin-left: 6px;
    flex-shrink: 0;
}

/* Apps en desarrollo / no terminadas: nombre en rojo */
.nav-item.wip .link-text { color: #f6465d; }
.nav-item.wip i { color: #f6465d; opacity: .8; }
.wip-badge { color: #f6465d; margin-left: 6px; font-weight: 700; }

.hidden-by-section, .search-hidden { display: none !important; }
body.is-searching .nav-item.hidden-by-section:not(.search-hidden) { display: flex !important; }
.nav-empty { color: var(--text-muted); font-size: 0.85rem; padding: 16px 12px; }

.user-profile {
    padding: 14px 16px 14px 20px;
    border-top: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    gap: 12px;
}
.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--accent-yellow);
    color: #12161C;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-name { font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.72rem; color: var(--success); }

/* ==========================================================================
   ÁREA PRINCIPAL Y TOPBAR
   ========================================================================== */
.main-content {
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 16px;
    height: calc(100vh - var(--ticker-height));
}

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    padding: 0 6px;
}

.search-box {
    background: var(--bg-panel);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 9px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    width: min(420px, 100%);
    backdrop-filter: blur(10px);
    transition: var(--transition);
}
.search-box:focus-within { border-color: var(--border-accent); box-shadow: 0 0 0 3px rgba(252, 213, 53, 0.08); }
.search-box i { color: var(--text-muted); }
.search-box input {
    background: none;
    border: none;
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 0.9rem;
    width: 100%;
    outline: none;
}
.search-kbd {
    font-family: var(--font-body);
    font-size: 0.68rem;
    color: var(--text-muted);
    border: 1px solid var(--border-glass);
    border-radius: 6px;
    padding: 2px 6px;
    white-space: nowrap;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-left: auto;
    min-width: 0;
}
.current-app {
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid;
}
.status-indicator .pulse-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-indicator.online { background: rgba(14, 203, 129, 0.1); color: var(--success); border-color: rgba(14, 203, 129, 0.2); }
.status-indicator.online .pulse-dot { background: var(--success); animation: pulse 2s infinite; }
.status-indicator.offline { background: rgba(246, 70, 93, 0.1); color: var(--danger); border-color: rgba(246, 70, 93, 0.25); }
.status-indicator.offline .pulse-dot { background: var(--danger); }
.status-indicator.checking { background: rgba(132, 142, 156, 0.1); color: var(--text-muted); border-color: var(--border-glass); }
.status-indicator.checking .pulse-dot { background: var(--text-muted); }

.icon-btn {
    background: var(--bg-panel);
    border: 1px solid var(--border-glass);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.icon-btn.small { width: 34px; height: 34px; border-radius: 10px; }
.icon-btn:hover, .icon-btn:focus-visible {
    background: var(--bg-panel-hover);
    border-color: var(--accent-yellow);
    color: var(--accent-yellow);
    outline: none;
}
.menu-toggle { display: none; }

/* ==========================================================================
   CONTENEDOR DE APPS (IFRAME)
   ========================================================================== */
.iframe-glass-container {
    flex-grow: 1;
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}
.iframe-glass-container::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-yellow), transparent);
    opacity: 0.5;
    z-index: 1;
}
iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}
.iframe-loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: var(--accent-yellow);
    background: rgba(7, 9, 12, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 2;
}
.iframe-loader.visible { opacity: 1; }

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(14, 203, 129, 0.7); }
    70% { box-shadow: 0 0 0 8px rgba(14, 203, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(14, 203, 129, 0); }
}

/* ==========================================================================
   RESPONSIVE (tablet / móvil)
   ========================================================================== */
.nav-backdrop { display: none; }

@media (max-width: 900px) {
    /* El menú se abre debajo de la barra superior para que el buscador siga visible. */
    .floating-nav {
        position: fixed;
        top: calc(var(--ticker-height) + 60px);
        left: 0;
        margin: 0 8px;
        height: calc(100vh - var(--ticker-height) - 70px);
        transform: translateX(calc(-100% - 16px));
        z-index: 900;
    }
    body.nav-open .floating-nav { transform: translateX(0); }
    body.nav-open .nav-backdrop {
        display: block;
        position: fixed;
        inset: calc(var(--ticker-height) + 60px) 0 0 0;
        background: rgba(0, 0, 0, 0.55);
        z-index: 800;
    }
    .topbar { position: relative; z-index: 950; }
    .menu-toggle { display: flex; }
    .main-content { padding: 10px; }
    .search-kbd, .current-app { display: none; }
    .status-indicator span { display: none; }
    .status-indicator { padding: 8px; }
    .iframe-glass-container { border-radius: 16px; }
}

/* Teléfonos angostos (Samsung S24 FE y similares, ~412px) */
@media (max-width: 480px) {
    .ticker { font-size: 0.78rem; animation-duration: 30s; }
    .main-content { padding: 8px; }
    .topbar { gap: 8px; margin-bottom: 10px; padding: 0 2px; }
    .icon-btn { width: 42px; height: 42px; }            /* objetivo táctil cómodo */
    .search-box { padding: 8px 12px; }
    .iframe-glass-container { border-radius: 14px; }
    /* El menú lateral ocupa casi toda la pantalla para tocar cómodo */
    .floating-nav { width: min(86vw, 320px); }
    .nav-item { padding: 11px 12px; font-size: 0.92rem; }  /* filas más altas para el dedo */
    .nav-section { padding: 14px 10px 6px; }
}
