:root {
    /* Default Dark Theme - refreshed commercial palette */
    --bg-color: #0b1220;
    --sidebar-bg: #0f1b2f;
    --card-bg: #111d30;
    --text-primary: #e8edf5;
    --text-secondary: #8aa0c2;
    --accent-color: #0ea5e9;
    --accent-hover: #0284c7;
    --success-color: #22c55e;
    --danger-color: #f87171;
    --warning-color: #fbbf24;
    --border-color: #1f2d46;
    --glass-bg: rgba(20, 32, 54, 0.78);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow-sm: 0 10px 30px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 20px 50px rgba(0, 0, 0, 0.35);
    --input-bg: rgba(255, 255, 255, 0.03);
    --header-bg: rgba(17, 29, 48, 0.9);
    --table-header-bg: rgba(255, 255, 255, 0.04);
    --table-header-text: #cbd5e1;
    --net-card-bg: #0c1424;
}

/* Light Theme Overrides */
body.light-theme {
    --bg-color: #e9edf2;
    --sidebar-bg: #f6f8fb;
    --card-bg: #f9fafc;
    --text-primary: #1f2937;
    --text-secondary: #556072;
    --accent-color: #0d99d6;
    --accent-hover: #0a81b6;
    --border-color: #cdd6e3;
    --glass-bg: rgba(250, 252, 255, 0.9);
    --glass-border: rgba(12, 33, 61, 0.06);
    --shadow-sm: 0 8px 24px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 16px 40px rgba(15, 23, 42, 0.1);
    --input-bg: #f1f4f8;
    --header-bg: #e3e8ef;
    --table-header-bg: #e6ecf3;
    --table-header-text: #2c3a4f;
    --net-card-bg: #0c1424; /* Mantener la tarjeta de excedente con fondo oscuro */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
    width: 100%;
    max-width: 100%;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100%;
    /* Changed from 100vh to 100% for better mobile support */
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    /* allow vertical scrolling at high zoom */
    margin: 0;
}

/* Responsive Images & Videos */
img,
video,
iframe {
    max-width: 100%;
    height: auto;
}

/* Dashboard specific lock */
.dashboard-mode {
    overflow: auto !important;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

/* Layout */
#app {
    display: flex;
    flex: 1 0 100%;
    align-self: stretch;
    min-height: 100vh;
    /* Cambiado de height: 100vh a min-height: 100vh */
    width: 100%;
    max-width: 100%;
}

/* En landing/login (sin dashboard) el app se muestra como bloque para ocupar todo el ancho */
body:not(.dashboard-mode) #app {
    display: block;
    width: 100%;
    max-width: 100%;
}

.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 100vh;
    /* Mantener min-height: 100vh */
    padding: 1rem;
    background: radial-gradient(circle at top right, #1e1b4b, transparent 40%),
        radial-gradient(circle at bottom left, #0f172a, transparent 40%);
}

/* Asegurar que el auth-container ocupe todo el #app cuando esté activo */
#app:has(.auth-container) {
    height: 100vh;
    /* Fuerza altura completa cuando hay auth-container */
}

/* Opcional: Si el problema persiste, añade esto */
body:has(.auth-container) {
    overflow: hidden;
    /* Previene scroll en el body */
}

/* Otra solución alternativa más directa: */
.auth-view .auth-container {
    position: fixed;
    /* O absolute */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    min-height: 100vh;
    z-index: 1000;
}

body.light-theme .auth-container {
    background: radial-gradient(circle at top right, #dbeafe, transparent 40%),
        radial-gradient(circle at bottom left, #e0f2fe, transparent 40%);
}

.dashboard-container {
    display: flex;
    flex: 1;
    /* Fill remaining space */
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 100%;
    overflow: auto;
    /* enable scrolling */
}

/* Modals/Auth Card - Increased default width */
.auth-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    padding: 2.5rem;
    border-radius: 1rem;
    width: 100%;
    max-width: 600px;
    /* Increased from 400px */
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Sidebar */
.sidebar {
    width: 230px;
    /* Standardize full width */
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    transition: width 0.3s ease, padding 0.3s ease;
    z-index: 50;
    overflow-x: hidden;
    white-space: nowrap;
}

.sidebar.collapsed {
    width: 80px;
    /* Increase to safe width */
    padding: 1rem 0;
    align-items: center;
}

.sidebar-header {
    height: 50px;
    display: flex;
    align-items: center;
    color: var(--accent-color);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
    padding: 0 0.5rem;
    width: 100%;
    overflow: hidden;
}

/* Collapsed State Overrides */
.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 0;
    width: 100%;
}

.sidebar.collapsed .sidebar-header-text {
    display: none !important;
}

.sidebar.collapsed .sidebar-header .material-icons-round {
    margin: 0 !important;
    font-size: 2rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.75rem;
}

.sidebar.collapsed .nav-link-text {
    display: none;
}

.nav-link:hover,
.nav-link.active {
    background-color: rgba(14, 165, 233, 0.12);
    color: var(--accent-color);
}

.nav-link .material-icons-round {
    font-size: 1.25rem;
}

/* Mobile Toggle */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 60;
    width: 42px;
    height: 42px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    color: var(--text-primary);
    align-items: center;
    justify-content: center;
    padding: 0;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        height: 100%;
        width: 200px !important;
        /* Always full width on mobile when open */
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    }

    .sidebar.mobile-open {
        left: 0;
    }

    .mobile-toggle {
        display: flex;
    }

    .main-content {
        padding-top: 4rem;
        /* Space for toggle */
    }
}

/* Main Content */
.main-content {
    flex: 1;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 2rem;
    overflow-y: auto;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.8rem;
    font-weight: 600;
}

/* Cards & Widgets */
.grid-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.landing-plans-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

.landing-video-shell {
    position: relative;
    width: 100%;
    max-width: 1300px;
    margin: 0 auto;
}

.landing-video-frame {
    aspect-ratio: 16 / 9;
    background: #000;
    color: #fff;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1), 0 20px 50px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.landing-video-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 110%;
    height: 110%;
    background: var(--accent-color);
    filter: blur(80px);
    opacity: 0.15;
    border-radius: 2rem;
    z-index: -1;
}

.landing-video-frame iframe {
    width: 100%;
    height: 100%;
    display: block;
}

@media (max-width: 1200px) {
    .landing-plans-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
    transition: transform 0.2s;
    box-shadow: var(--shadow-sm);
}

.card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-color);
    box-shadow: var(--shadow-md);
}

/* Stats */
.stat-title {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    background-color: var(--input-bg);
    color: var(--text-primary);
    font-family: inherit;
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    background-color: var(--accent-color);
    color: white;
    border: none;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    width: 100%;
}

.btn:hover {
    background-color: var(--accent-hover);
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    transition: background-color 0.2s;
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Tables */
.table-container {
    background-color: var(--card-bg);
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background-color: var(--table-header-bg);
    color: var(--table-header-text);
    font-weight: 600;
}

.table tr:last-child td {
    border-bottom: none;
}

/* Utilities */
.text-success {
    color: var(--success-color);
}

.text-danger {
    color: var(--danger-color);
}

.mt-4 {
    margin-top: 1rem;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Loading */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    width: 100%;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #app {
        flex-direction: column;
    }

    .auth-card {
        max-width: 90%;
    }

    .grid-dashboard {
        grid-template-columns: 1fr;
    }

    .landing-plans-grid {
        grid-template-columns: 1fr;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
    }

    .hero h1 {
        font-size: 2.5rem;
    }

    .hero p {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .auth-card {
        padding: 1.5rem;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    .header h1 {
        font-size: 2rem;
    }
}

.loader {
    width: 48px;
    height: 48px;
    border: 5px solid var(--border-color);
    border-bottom-color: var(--accent-color);
    border-radius: 50%;
    animation: rotation 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Landing Mode: Independent Layout */
body.landing-mode {
    overflow: auto !important;
    /* Force scroll */
    height: auto !important;
}

body.landing-mode #app {
    display: block !important;
    /* Disable flex row found in #app */
    height: auto !important;
    /* Allow growth */
    width: 100% !important;
}

body.landing-mode .dashboard-container {
    display: none !important;
    /* Safety */
}
