/* ================================================================
   STC ALLCONTROL — MAIN STYLESHEET
   Layout: Sidebar + Tabs + Iframe panels
   ================================================================ */

/* ======================== VARIABLES ======================== */
:root {
    --neon-blue: #3b82f6;
    --neon-cyan: #06b6d4;
    --neon-indigo: #6366f1;
    --neon-emerald: #10b981;
    --neon-amber: #f59e0b;
    --neon-rose: #ec4899;
    --neon-violet: #8b5cf6;
    --neon-red: #ef4444;

    --sidebar-w: 240px;
    --sidebar-w-collapsed: 0px;
    --header-h: 46px;
    --tabbar-h: 38px;

    --bg-body: #0a0f1a;
    --bg-sidebar: rgba(6, 10, 20, 0.97);
    --bg-header: rgba(8, 12, 22, 0.96);
    --bg-tabbar: rgba(12, 18, 30, 0.92);
    --bg-tab: rgba(30, 41, 59, 0.5);
    --bg-tab-active: rgba(30, 41, 59, 0.85);
    --bg-tab-hover: rgba(30, 41, 59, 0.7);
    --glass: rgba(15, 23, 42, 0.6);
    --glass-border: rgba(148, 163, 184, 0.1);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-dim: #475569;
    --accent: var(--neon-blue);
    --accent-glow: rgba(59, 130, 246, 0.25);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body.theme-light {
    --bg-body: #f0f4f8;
    --bg-tabbar: rgba(241, 245, 249, 0.95);
    --bg-tab: rgba(226, 232, 240, 0.6);
    --bg-tab-active: rgba(255, 255, 255, 0.9);
    --bg-tab-hover: rgba(226, 232, 240, 0.8);
    --glass-border: rgba(148, 163, 184, 0.2);
    --accent-glow: rgba(59, 130, 246, 0.15);
}

/* Light theme — keep sidebar & header dark always */
body.theme-light .sidebar,
body.theme-light .sidebar::before,
body.theme-light .sidebar::after { /* no changes — stays dark */ }

body.theme-light .top-header {
    background-color: rgba(8, 12, 22, 0.96);
    background-image: url('../banner.png');
    background-size: cover;
    background-position: center;
}

body.theme-light .header-clock {
    color: #94a3b8;
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(148, 163, 184, 0.1);
}

body.theme-light .ctrl-btn {
    background: #ffffff;
    color: #0f172a;
    border: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

body.theme-light .top-title {
    color: rgba(255,255,255,0.9);
    -webkit-text-fill-color: rgba(255,255,255,0.9);
}

/* Sidebar text stays light in both themes */
body.theme-light .sidebar .user-name,
body.theme-light .sidebar .nav-label,
body.theme-light .sidebar .nav-item:hover .nav-label,
body.theme-light .sidebar .nav-item.active .nav-label,
body.theme-light .sidebar .footer-user-name { color: #e2e8f0; }

body.theme-light .sidebar .user-role,
body.theme-light .sidebar .nav-section-title,
body.theme-light .sidebar .footer-user-role { color: #64748b; }

body.theme-light .sidebar .nav-icon,
body.theme-light .sidebar .nav-label { color: #94a3b8; }

body.theme-light .sidebar .nav-item:hover .nav-icon,
body.theme-light .sidebar .nav-item:hover .nav-label { color: #e2e8f0; }

body.theme-light .sidebar .nav-item.active .nav-icon { color: var(--neon-blue); }
body.theme-light .sidebar .nav-item.active .nav-label { color: #e2e8f0; }

/* Tab bar in light theme */
body.theme-light .tab-bar {
    background: var(--bg-tabbar);
}
body.theme-light .tab-label { color: #475569; }
body.theme-light .tab-item.active .tab-label { color: #0f172a; }

/* ======================== RESET ======================== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }
body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    color: var(--text-primary);
    background: var(--bg-body);
    overflow: hidden;
    height: 100vh;
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; }

/* ======================== FONDO ======================== */
.bg-layer {
    position: fixed; inset: 0; z-index: 0;
    background: url('../banner.png') center center / cover no-repeat;
    background-color: #060a12;
    filter: brightness(0.4);
    transition: filter 0.4s;
}
body.theme-light .bg-layer { filter: brightness(0.6) saturate(0.6); }

.bg-grid {
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    background-image:
        linear-gradient(rgba(59,130,246,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(59,130,246,0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: gridMove 50s linear infinite;
}
@keyframes gridMove { 0%{transform:translate(0,0)} 100%{transform:translate(50px,50px)} }
body.theme-light .bg-grid {
    background-image:
        linear-gradient(rgba(59,130,246,0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(59,130,246,0.05) 1px, transparent 1px);
}

.bg-particles { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.bg-particles .particle {
    position: absolute; width: 2px; height: 2px;
    background: rgba(59,130,246,0.45); border-radius: 50%;
    animation: floatP linear infinite;
}
@keyframes floatP {
    0%  { transform: translateY(100vh) translateX(0); opacity:0; }
    10% { opacity:0.5; }
    90% { opacity:0.5; }
    100%{ transform: translateY(-10vh) translateX(60px); opacity:0; }
}

/* ======================== APP SHELL ======================== */
.app-shell {
    position: relative; z-index: 1;
    height: 100vh; display: flex; flex-direction: column;
}

/* ======================== TOP HEADER ======================== */
.top-header {
    height: var(--header-h);
    background: var(--bg-header);
    background-image: url('../banner.png');
    background-size: cover;
    background-position: center;
    backdrop-filter: blur(30px) saturate(150%);
    -webkit-backdrop-filter: blur(30px) saturate(150%);
    border-bottom: 1px solid var(--glass-border);
    display: flex; align-items: center;
    padding: 0 16px;
    flex-shrink: 0;
    position: relative; z-index: 200;
}

/* Animated bottom line */
.top-header::after {
    content: ''; position: absolute; bottom: -1px; left: 0;
    width: 100%; height: 2px;
    background: linear-gradient(90deg, var(--neon-blue), var(--neon-cyan), var(--neon-indigo), var(--neon-blue));
    background-size: 200% 100%;
    animation: headerGlow 4s linear infinite;
    opacity: 0.5;
}
@keyframes headerGlow { 0%{background-position:0% 0%} 100%{background-position:200% 0%} }

.top-header-left { display: flex; align-items: center; width: var(--sidebar-w); flex-shrink: 0; }
.top-header-center { flex: 1; text-align: left; }
.top-header-right { display: flex; align-items: center; gap: 8px; }

.top-title {
    font-family: 'Orbitron', monospace;
    font-size: 0.82rem; font-weight: 700;
    letter-spacing: 0.35em;
    color: rgba(255,255,255,0.9);
    -webkit-text-fill-color: rgba(255,255,255,0.9);
    text-shadow: 0 0 12px rgba(6,182,212,0.5), 0 0 24px rgba(59,130,246,0.3);
    filter: none;
}

/* Sidebar toggle — always visible, floats on sidebar edge */
.sidebar-toggle {
    position: absolute;
    left: var(--sidebar-w);
    top: 50%;
    transform: translate(-50%, -50%);
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    background: var(--neon-blue);
    border: 2px solid rgba(59,130,246,0.6);
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    font-size: 0.7rem;
    z-index: 200;
    box-shadow: 0 0 14px rgba(59,130,246,0.4);
    transition: left 0.3s ease, background 0.25s ease, box-shadow 0.25s ease;
}
.sidebar-toggle:hover {
    background: var(--neon-cyan); border-color: var(--neon-cyan);
    box-shadow: 0 0 20px rgba(6,182,212,0.5);
}
.sidebar-toggle i {
    transition: transform 0.3s ease;
}
.app-body.sidebar-collapsed .sidebar-toggle {
    left: 0;
    transform: translate(50%, -50%);
}
.app-body.sidebar-collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}

.header-clock {
    font-family: 'Orbitron', monospace;
    font-size: 0.65rem; font-weight: 600;
    color: var(--text-muted);
    padding: 5px 12px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    font-variant-numeric: tabular-nums;
}

.ctrl-btn {
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #ffffff; border-radius: 50%;
    background: rgba(0, 0, 0, 0.6); color: #ffffff;
    font-size: 1rem; cursor: pointer; transition: all 0.2s ease;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}
.ctrl-btn:hover {
    background: #f59e0b; color: #000000;
    border-color: #f59e0b;
    transform: scale(1.15);
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.6);
}

/* ======================== APP BODY ======================== */
.app-body {
    flex: 1; display: flex; overflow: hidden;
    position: relative;
}

/* ======================== SIDEBAR ======================== */
.sidebar {
    width: var(--sidebar-w);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--glass-border);
    display: flex; flex-direction: column;
    flex-shrink: 0;
    transition: width 0.3s ease, opacity 0.3s ease;
    overflow: hidden;
    z-index: 150;
    position: relative;
}

/* Banner background via pseudo-element */
.sidebar::before {
    content: '';
    position: absolute; inset: 0;
    background: url('../Fondoweb.jpg') center top / auto no-repeat;
    opacity: 0.2;
    z-index: 0;
    pointer-events: none;
}

/* Dark overlay — flat, no gradient */
.sidebar::after {
    content: '';
    position: absolute; inset: 0;
    background: rgba(6,10,20,0.55);
    z-index: 0;
    pointer-events: none;
}

/* All sidebar children above the background */
.sidebar > * {
    position: relative;
    z-index: 1;
}

.app-body.sidebar-collapsed .sidebar {
    width: var(--sidebar-w-collapsed);
    opacity: 0;
    pointer-events: none;
}

/* Sidebar header */
.sidebar-header {
    padding: 20px 16px 16px;
    border-bottom: 1px solid var(--glass-border);
    display: flex; align-items: center; gap: 14px;
    flex-shrink: 0;
}

.sidebar-logo {
    width: 50px; height: 50px; min-width: 50px;
    border-radius: 14px; object-fit: cover;
    border: 2px solid rgba(255,255,255,0.15);
    box-shadow: 0 0 16px rgba(59,130,246,0.25);
    transition: var(--transition);
}
.sidebar-logo:hover { transform: scale(1.06); box-shadow: 0 0 22px rgba(59,130,246,0.45); }

.sidebar-user { overflow: hidden; }
.user-name {
    display: block; font-size: 1rem; font-weight: 700;
    color: var(--text-primary); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.user-role {
    display: block; font-size: 0.72rem; font-weight: 500;
    color: var(--text-muted); margin-top: 2px;
}

/* Sidebar nav */
.sidebar-nav {
    flex: 1; overflow-y: auto; padding: 10px 6px;
}

.nav-section-title {
    font-size: 0.6rem; font-weight: 600;
    color: var(--text-dim); text-transform: uppercase;
    letter-spacing: 2px; padding: 12px 12px 6px;
}

.nav-items { display: flex; flex-direction: column; gap: 1px; }

.nav-item {
    display: flex; align-items: center; gap: 14px;
    padding: 11px 14px; border-radius: 8px;
    cursor: pointer; transition: var(--transition);
    position: relative; border: 1px solid transparent;
    user-select: none;
}

.nav-item:hover {
    background: rgba(148,163,184,0.08);
    border-color: rgba(148,163,184,0.06);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(59,130,246,0.2), rgba(59,130,246,0.06));
    border-color: rgba(59,130,246,0.2);
    border-radius: 8px;
}

.nav-item.active::before {
    content: ''; position: absolute; left: 0; top: 6px; bottom: 6px;
    width: 3px; border-radius: 0 3px 3px 0;
    background: var(--neon-blue);
}

.nav-icon {
    width: 20px; min-width: 20px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.95rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.nav-item:hover .nav-icon { color: var(--text-primary); }
.nav-item.active .nav-icon { color: var(--neon-blue); }

.nav-label {
    font-size: 0.78rem; font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.nav-item:hover .nav-label { color: var(--text-primary); }
.nav-item.active .nav-label { color: var(--text-primary); font-weight: 700; }

/* Sidebar scrollbar */
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--text-dim); border-radius: 2px; }

/* Sidebar footer — user info + logout */
.sidebar-footer {
    padding: 14px 14px; border-top: 1px solid var(--glass-border);
    flex-shrink: 0;
    display: flex; flex-direction: column; gap: 10px;
}

.footer-user {
    display: flex; align-items: center; gap: 10px;
}

.footer-avatar {
    width: 36px; height: 36px; min-width: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--neon-blue), var(--neon-cyan));
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 0.7rem; font-weight: 700;
    letter-spacing: 0.03em;
    box-shadow: 0 0 10px rgba(59,130,246,0.3);
}

.footer-user-info { overflow: hidden; }

.footer-user-name {
    display: block; font-size: 0.78rem; font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.footer-user-role {
    display: block; font-size: 0.62rem; font-weight: 500;
    color: var(--text-muted); margin-top: 1px;
    text-transform: uppercase; letter-spacing: 0.5px;
}

.btn-logout {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 9px 0;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    color: #f87171; font-size: 0.75rem; font-weight: 600;
    cursor: pointer; transition: var(--transition);
    text-transform: uppercase; letter-spacing: 0.05em;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}

.btn-logout i { font-size: 0.8rem; }

/* ======================== CONTENT WRAPPER ======================== */
.content-wrapper {
    flex: 1; display: flex; flex-direction: column;
    overflow: hidden; min-width: 0;
}

/* ======================== TAB BAR ======================== */
.tab-bar {
    height: var(--tabbar-h);
    background: var(--bg-tabbar);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-bottom: 1px solid var(--glass-border);
    display: flex; align-items: flex-end;
    padding: 0 4px;
    flex-shrink: 0;
    overflow: hidden;
}

.tabs-scroll {
    display: flex; align-items: flex-end;
    gap: 2px; overflow-x: auto;
    height: 100%; padding-bottom: 0;
    scrollbar-width: none;
}
.tabs-scroll::-webkit-scrollbar { display: none; }

.tab-item {
    display: flex; align-items: center; gap: 6px;
    height: 30px; padding: 0 12px;
    background: var(--bg-tab);
    border: 1px solid var(--glass-border);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    cursor: pointer; transition: var(--transition);
    white-space: nowrap; max-width: 180px;
    flex-shrink: 0; position: relative;
    margin-bottom: -1px;
}

.tab-item:hover { background: var(--bg-tab-hover); }

.tab-item.active {
    background: var(--bg-tab-active);
    border-color: rgba(59,130,246,0.2);
    z-index: 2;
}

.tab-item.active::after {
    content: ''; position: absolute; bottom: 0; left: 0; right: 0;
    height: 2px; background: var(--tab-color, var(--neon-blue));
    border-radius: 2px 2px 0 0;
}

.tab-dot {
    width: 6px; height: 6px; min-width: 6px;
    border-radius: 50%;
    background: var(--tab-color, var(--neon-blue));
}

.tab-label {
    font-size: 0.7rem; font-weight: 500;
    color: var(--text-secondary);
    overflow: hidden; text-overflow: ellipsis;
    max-width: 120px;
}

.tab-item.active .tab-label { color: var(--text-primary); font-weight: 600; }

.tab-close {
    width: 18px; height: 18px; min-width: 18px;
    display: flex; align-items: center; justify-content: center;
    border: none; background: transparent;
    color: var(--text-dim); font-size: 0.6rem;
    border-radius: 4px; cursor: pointer;
    transition: var(--transition); opacity: 0;
}

.tab-item:hover .tab-close,
.tab-item.active .tab-close { opacity: 1; }

.tab-close:hover {
    background: var(--neon-red); color: #fff;
}

/* ======================== PANELS CONTAINER ======================== */
.panels-container {
    flex: 1; position: relative; overflow: hidden;
    background: #d4d4d4;
}

.content-panel {
    position: absolute; inset: 0;
    display: none; flex-direction: column;
    overflow-y: auto;
    padding: 20px;
    background: #d4d4d4;
    color: #1a1a1a;
}

/* Override dark colors inside content panels for light bg */
.content-panel .mod-header {
    background: rgba(255,255,255,0.85);
    border-color: rgba(0,0,0,0.1);
}
.content-panel .mod-header-title h1 { color: #1a1a1a; }
.content-panel .mod-header-title small { color: #6b7280; }
.content-panel .mod-header-title i { color: #4b5563; }

.content-panel .mod-stat {
    background: rgba(255,255,255,0.8);
    border-color: rgba(0,0,0,0.08);
}
.content-panel .mod-stat-value { color: #1a1a1a; }
.content-panel .mod-stat-label { color: #6b7280; }

.content-panel .mod-tab {
    color: #6b7280;
}
.content-panel .mod-tab:hover { color: #374151; background: rgba(0,0,0,0.04); }
.content-panel .mod-tab.active { color: #1d4ed8; border-bottom-color: #1d4ed8; }

.content-panel .mod-table-wrap {
    border-color: rgba(0,0,0,0.15);
    background: #fff;
}
.content-panel .mod-table thead th {
    background: #374151;
    color: #e5e7eb;
    border-color: #4b5563;
}
.content-panel .mod-table thead th:hover {
    background: #4b5563;
    color: #fff;
}
.content-panel .mod-table tbody tr:nth-child(even) { background: #dbeafe; }
.content-panel .mod-table tbody tr:nth-child(odd) { background: #ffffff; }
.content-panel .mod-table tbody tr:hover { background: #bfdbfe; }
.content-panel .mod-table tbody td {
    color: #1e293b;
    border-color: rgba(0,0,0,0.08);
}
.content-panel .mod-table tbody td:first-child { color: #0f172a; font-weight: 600; }
.content-panel .mod-table tfoot td {
    background: #e5e7eb;
    border-color: rgba(0,0,0,0.1);
    color: #111827;
}
.content-panel .mod-table tfoot .mod-money { color: #111827 !important; }

.content-panel .mod-money { color: #111827; }

.content-panel .mod-select,
.content-panel .mod-input {
    background: #fff;
    border-color: rgba(0,0,0,0.15);
    color: #1a1a1a;
}

.content-panel .mod-btn {
    background: #e5e7eb;
    border-color: rgba(0,0,0,0.1);
    color: #374151;
}
.content-panel .mod-btn:hover {
    background: #d1d5db;
    color: #111827;
}
.content-panel .mod-btn-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.content-panel .mod-btn-primary:hover { background: #1d4ed8; }
.content-panel .mod-btn-danger { background: rgba(239,68,68,0.1); color: #dc2626; border-color: rgba(239,68,68,0.2); }

.content-panel .pf-vt,
.content-panel .pf-qt {
    background: #e5e7eb;
    border-color: rgba(0,0,0,0.08);
    color: #6b7280;
}
.content-panel .pf-vt:hover,
.content-panel .pf-qt:hover { background: #d1d5db; color: #374151; }
.content-panel .pf-vt.active,
.content-panel .pf-qt.active { background: #374151; color: #fff; border-color: #374151; }

.content-panel .pf-sec { color: #6b7280; }

.content-panel .c-stc { background: rgba(100,116,139,0.15); color: #475569; }
.content-panel .c-laam { background: rgba(6,182,212,0.12); color: #0e7490; }
.content-panel .st-pagado { background: rgba(16,185,129,0.15); color: #047857; }
.content-panel .st-pendiente { background: rgba(245,158,11,0.15); color: #b45309; }

/* Modal stays dark */
.content-panel .mod-modal-overlay { color: #e2e8f0; }

.content-panel.active { display: flex; }

/* ======================== WELCOME SCREEN ======================== */
.welcome-screen {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 14px; padding: 40px;
}

.welcome-icon {
    width: 72px; height: 72px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--neon-blue), var(--neon-cyan));
    color: #fff; font-size: 1.8rem;
    box-shadow: 0 0 20px rgba(59,130,246,0.35);
    animation: iconFloat 4s ease-in-out infinite;
}
@keyframes iconFloat { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }

.welcome-title {
    font-family: 'Orbitron', monospace;
    font-size: 1.4rem; font-weight: 800;
    background: linear-gradient(135deg, var(--text-primary), var(--neon-blue));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text; text-align: center;
}

.welcome-sub {
    font-size: 0.9rem; color: var(--text-secondary); text-align: center;
}

/* ======================== ANIMATIONS ======================== */
@keyframes fadeInUp {
    from { opacity:0; transform:translateY(20px); }
    to   { opacity:1; transform:translateY(0); }
}

/* ======================== SCROLLBAR ======================== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-dim); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ======================== RESPONSIVE ======================== */
@media (max-width: 768px) {
    :root { --sidebar-w: 200px; }
    .top-title { font-size: 0.85rem; letter-spacing: 0.1em; }
    .header-clock { display: none; }
    .tab-item { max-width: 140px; }
}

@media (max-width: 500px) {
    :root { --sidebar-w: 180px; }
    .top-title { font-size: 0.7rem; }
    .sidebar-user { display: none; }
    .sidebar-header { padding: 12px; justify-content: center; }
}
