/* 
   ISP Panel Pro - Modern UI v4.0 
   Optimized for Clarity, Contrast, and Performance
*/

:root {
    /* --- CARRIER-GRADE PALETTE (Bluish-Gray) --- */
    --bg-body: #12141a;
    /* Professional Dark Base */
    --bg-surface: #1f2229;
    /* Card/Surface */
    --bg-surface-hover: #2a2e37;
    --bg-element: rgba(255, 255, 255, 0.05);
    /* Thin borders/separators */

    /* Functional Accents */
    --success: #10b981;
    /* Emerald Green - Optimal */
    --warning: #f59e0b;
    /* Soft Amber - Latency/Signal */
    --danger: #e11d48;
    /* Crimson Red - Down */
    --primary: #3b82f6;
    /* Soft Blue - Navigation/Action */

    /* Text Hierarchy */
    --text-primary: #f8fafc;
    /* Whiteish */
    --text-secondary: #94a3b8;
    /* Technical/Meta */
    --text-muted: #64748b;
    /* Visual noise reduction */

    /* Typography */
    --font-ui: 'Inter', system-ui, sans-serif;
    --font-technical: 'JetBrains Mono', 'Roboto Mono', monospace;

    /* Spacing & Borders */
    --grid: 8px;
    --radius: 10px;
    --sidebar-width: 260px;
    --header-height: 64px;

    /* Performance UX */
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --shadow: 0 4px 20px -5px rgba(0, 0, 0, 0.5);
}

/* --- RESET & BASE --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    outline: none;
}

body {
    font-family: var(--font-ui);
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100vh;
    height: 100dvh;
    /* Dynamic Viewport Height for Mobile */
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- APP SHELL --- */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: auto 1fr;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow-x: hidden;
    /* Prevent horizontal jitter */
}

/* --- SIDEBAR --- */
.sidebar {
    background-color: var(--bg-surface);
    border-right: 1px solid var(--bg-element);
    display: flex;
    flex-direction: column;
    grid-row: 1 / -1;
    z-index: 50;
    transition: transform 0.3s ease;
    background: linear-gradient(180deg, var(--bg-surface) 0%, #020617 100%);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--bg-element);
}

.brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-section {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-tertiary);
    font-weight: 800;
    letter-spacing: 0.08em;
    margin: 1.5rem 0 0.5rem 0.5rem;
}

.nav-section:first-child {
    margin-top: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius);
    transition: var(--transition);
    font-weight: 500;
    font-size: 0.9rem;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.03);
    color: white;
}

.nav-link.active {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--primary);
    font-weight: 600;
}

/* --- MAIN AREA --- */
.main-area {
    display: flex;
    flex-direction: column;
    background-color: var(--bg-body);
    overflow: hidden;
    position: relative;
}

/* Top Nav */
.top-nav {
    height: var(--header-height);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: rgba(2, 6, 23, 0.7);
    /* Translucent */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--bg-element);
    position: sticky;
    top: 0;
    z-index: 40;
}

.content-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    scroll-behavior: smooth;
}

/* --- COMPONENTS --- */

/* Cards */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--bg-element);
    border-radius: var(--radius);
    padding: calc(var(--grid) * 3);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.card:hover {
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: calc(var(--grid) * 2);
    padding-bottom: var(--grid);
    border-bottom: 1px solid var(--bg-element);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: white;
    letter-spacing: -0.01em;
}

/* Inputs */
.form-input,
.form-control {
    width: 100%;
    padding: 0.625rem 1rem;
    background-color: #1e293b;
    /* Slightly lighter than body */
    border: 1px solid var(--bg-element);
    border-radius: 0.5rem;
    color: white;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.form-input:focus,
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    gap: 0.5rem;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-secondary {
    background-color: var(--bg-element);
    color: white;
}

.btn-secondary:hover {
    background-color: var(--bg-surface-hover);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-success {
    background-color: var(--success);
    color: white;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

/* Tables - Modern Look */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--bg-element);
}

table.w-full {
    width: 100%;
    border-collapse: collapse;
}

thead tr {
    background-color: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--bg-element);
}

thead th {
    text-align: left;
    padding: 1rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-tertiary);
    font-weight: 700;
    letter-spacing: 0.05em;
}

tbody tr {
    border-bottom: 1px solid rgba(51, 65, 85, 0.5);
    /* Subtle separator */
    transition: background-color 0.15s;
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

td {
    padding: calc(var(--grid) * 2);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Technical Data Typography */
.tech-data {
    font-family: var(--font-technical);
    font-size: 0.85rem;
    letter-spacing: -0.02em;
    color: var(--text-muted);
}

/* Performance UX: Skeleton Screens */
.skeleton {
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.03) 25%,
            rgba(255, 255, 255, 0.08) 50%,
            rgba(255, 255, 255, 0.03) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
    display: inline-block;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 1em;
    width: 100%;
    margin-bottom: 4px;
}

.skeleton-title {
    height: 1.5em;
    width: 60%;
    margin-bottom: 12px;
}

.skeleton-circle {
    height: 40px;
    width: 40px;
    border-radius: 50%;
}

/* Utilities */
.text-xs {
    font-size: 0.75rem;
}

.text-sm {
    font-size: 0.875rem;
}

.font-bold {
    font-weight: 700;
}

.font-mono {
    font-family: 'JetBrains Mono', monospace;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-element);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* --- RESPONSIVE MOBILE --- */
@media (max-width: 768px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        left: 0;
        transform: translateX(-100%);
        width: 85%;
        max-width: 320px;
        height: 100vh;
        height: 100dvh;
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .content-wrapper {
        padding: 1rem;
        padding-top: 1.5rem;
    }

    /* Diag Mobile */
    .diag-layout {
        display: flex;
        flex-direction: column;
        height: auto !important;
        min-height: calc(100dvh - 120px);
    }

    .diag-sidebar {
        width: 100% !important;
        border-right: none !important;
        border-bottom: 1px solid var(--bg-element);
    }
}

/* --- DIAGNOSTIC LAYOUT (Desktop) --- */
.diag-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: calc(100vh - 120px);
}

.diag-sidebar {
    width: 280px;
}

/* Fade In Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

/* --- PAGES --- */
/* --- MODULE BACKGROUNDS (Glassmorphism + Technical Assets) --- */
.page {
    position: relative;
    border-radius: var(--radius);
    overflow: visible;
    min-height: 85vh;
    padding: 1.5rem;
    background-size: cover;
    background-attachment: fixed;
    background-position: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
    animation: fadeIn 0.4s ease-out forwards;
}

#page-dashboard {
    background: linear-gradient(rgba(18, 24, 40, 0.9), rgba(18, 24, 40, 0.85)),
        url('../img/dashboard-bg.png') no-repeat center center;
    background-size: cover;
}

#page-clientes,
#page-cobranzas {
    background: linear-gradient(rgba(18, 20, 26, 0.9), rgba(18, 20, 26, 0.88)),
        url('../img/connectivity-bg.png') no-repeat center center;
    background-size: cover;
}

#page-routers {
    background: linear-gradient(rgba(18, 20, 26, 0.88), rgba(18, 20, 26, 0.88)),
        url('../img/enterprise-bg.png') no-repeat center center;
    background-size: cover;
}

#page-diagnostico {
    background: linear-gradient(rgba(26, 20, 40, 0.9), rgba(20, 18, 30, 0.88)),
        url('../img/diagnostics-bg.png') no-repeat center center;
    background-size: cover;
}

#page-finanzas {
    background: linear-gradient(rgba(18, 30, 40, 0.9), rgba(18, 20, 26, 0.88)),
        url('../img/financial-tech-bg.png') no-repeat center center;
    background-size: cover;
}

#page-logs,
#page-config,
#page-ia,
#page-cortes {
    background: linear-gradient(rgba(15, 20, 25, 0.92), rgba(10, 15, 20, 0.9)),
        url('../img/server-rack-bg.png') no-repeat center center;
    background-size: cover;
}

/* LIVE PULSE & NOTIFICATIONS */
.live-pulse {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 99px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.pulse-dot {
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    position: relative;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

.pulse-dot::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: inherit;
    border-radius: 50%;
    animation: pulse-ring 1.5s cubic-bezier(0.455, 0.03, 0.515, 0.955) infinite;
}

@keyframes pulse-ring {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    100% {
        transform: scale(3.5);
        opacity: 0;
    }
}

.sys-alert-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    background: rgba(244, 63, 94, 0.1);
    border: 1px solid rgba(244, 63, 94, 0.2);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    color: #fca5a5;
    animation: slideDown 0.4s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}