/* Reset y configuración base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* --- VARIABLES DE COLOR PARA TEMAS --- */
:root {
    --font-family: 'Poppins', sans-serif;

    /* Tema Oscuro (Default) */
    --color-bg: #1a1a1a;
    --color-bg-gradient: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    --color-text-primary: #e0e0e0;
    --color-text-secondary: #b0b0b0;
    --color-text-title: #ffffff;
    --color-border: rgba(255, 255, 255, 0.2);
    --color-border-hover: #ffffff;
    --color-header-bg: rgba(26, 26, 26, 0.85);
    --color-card-bg: rgba(45, 45, 45, 0.9);
    --color-card-inactive-bg: #3a3a3a;
    --color-card-inactive-text: #7a7a7a;
    --color-card-detail-bg: rgba(30, 30, 30, 0.9);
    --color-option-bg: rgba(45, 45, 45, 0.8);
    --color-option-active-bg: #ffffff;
    --color-option-active-text: #1a1a1a;
    --color-icon-bg: #ffffff;
    --color-icon-text: #1a1a1a;
    --shadow-neon: 0 0 8px rgba(255, 255, 255, 0.7), 0 0 20px rgba(255, 255, 255, 0.4);
    --shadow-logo: drop-shadow(0 0 5px rgba(255, 255, 255, 0.9))
                   drop-shadow(0 0 12px rgba(255, 255, 255, 0.7))
                   drop-shadow(0 0 25px rgba(255, 255, 255, 0.5));
}

[data-theme="light"] {
    --color-bg: #f4f4f4;
    --color-bg-gradient: linear-gradient(135deg, #f4f4f4 0%, #e8e8e8 100%);
    --color-text-primary: #333333;
    --color-text-secondary: #666666;
    --color-text-title: #000000;
    --color-border: rgba(0, 0, 0, 0.2);
    --color-border-hover: #000000;
    --color-header-bg: rgba(255, 255, 255, 0.85);
    --color-card-bg: rgba(255, 255, 255, 0.9);
    --color-card-inactive-bg: #cccccc;
    --color-card-inactive-text: #888888;
    --color-card-detail-bg: rgba(240, 240, 240, 0.9);
    --color-option-bg: rgba(230, 230, 230, 0.8);
    --color-option-active-bg: #1a1a1a;
    --color-option-active-text: #ffffff;
    --color-icon-bg: #1a1a1a;
    --color-icon-text: #ffffff;
    --shadow-neon: 0 0 8px rgba(0, 0, 0, 0.4), 0 0 20px rgba(0, 0, 0, 0.2);
    --shadow-logo: none;
}
/* --- FIN VARIABLES --- */


body {
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text-primary);
    line-height: 1.5;
    transition: background 0.3s ease, color 0.3s ease;
}

/* --- PRELOADER --- */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    background: var(--color-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}
#preloader.loaded {
    opacity: 0;
    visibility: hidden;
}
.preloader-logo {
    width: 200px;
    height: auto;
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 1))
            drop-shadow(0 0 20px rgba(255, 255, 255, 0.8))
            drop-shadow(0 0 40px rgba(255, 255, 255, 0.6));
}
[data-theme="light"] .preloader-logo {
    filter: none;
}

/* --- PARTICLE BACKGROUND --- */
#particles-js {
    position: fixed;
    width: 100%;
    height: 100%;
    background-color: var(--color-bg);
    background-image: var(--color-bg-gradient);
    z-index: -1;
}

/* Solución para fondo en pantalla completa (CORREGIDO) */
:root:fullscreen,
:root:-webkit-full-screen {
    /* La línea de background se elimina para que el contenedor de partículas sea visible */
}

body:fullscreen,
body:-webkit-full-screen {
    background: transparent;
}

/* Botones flotantes */
.fullscreen-btn, .theme-toggle-btn {
    position: fixed;
    z-index: 1001;
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 10px 12px;
    color: var(--color-text-primary);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}
.fullscreen-btn:hover, .theme-toggle-btn:hover {
    transform: scale(1.05);
    background: var(--color-icon-bg);
    color: var(--color-icon-text);
}
.fullscreen-btn { top: 15px; right: 15px; }
.theme-toggle-btn { top: 15px; right: 70px; }


/* Estilos para el Header */
.header {
    position: sticky;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--color-header-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--color-border);
    transition: transform 0.4s ease-in-out, background 0.3s ease;
}
.header.header-hidden { transform: translateY(-100%); }
.header-logo {
    height: 50px;
    width: auto;
    filter: var(--shadow-logo);
}
.header-text h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text-title);
    margin: 0;
}
.header-text p {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin: 0;
    font-weight: 300;
}

/* Contenedor Principal */
.main-container {
    display: grid;
    grid-template-columns: 1fr 280px;
    grid-template-areas: "main sidebar";
    height: 100vh;
    gap: 1rem;
    padding: 1rem;
    padding-top: 90px;
    max-width: 100%;
    margin: 0 auto;
    background: transparent; /* El fondo lo maneja #particles-js */
}

/* Configurador principal */
.configurator {
    grid-area: main;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
    max-height: calc(100vh - 110px);
    padding-right: 0.8rem;
    scroll-behavior: smooth;
}
.configurator::-webkit-scrollbar { width: 8px; }
.configurator::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.1); }
.configurator::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 4px; }
.configurator::-webkit-scrollbar-thumb:hover { background: var(--color-border-hover); }

/* Selector de paquetes */
.package-selector .option {
    padding: 0.75rem 1.5rem;
    background: var(--color-option-bg);
    border: 2px solid var(--color-border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    color: var(--color-text-primary);
    backdrop-filter: blur(10px);
    font-size: 0.9rem;
}
.package-selector .option:hover {
    border-color: var(--color-border-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}
.package-selector .option.active {
    background: var(--color-option-active-bg);
    color: var(--color-option-active-text);
    border-color: var(--color-option-active-bg);
    font-weight: 600;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

/* Tarjetas de módulos */
.module-card {
    background: var(--color-card-bg);
    border: 2px solid var(--color-border);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.4s ease;
    backdrop-filter: blur(10px);
    opacity: 0;
    transform: translateY(30px);
    animation: slideInUp 0.6s ease forwards;
}
@keyframes slideInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}
.module-icon {
    background: var(--color-icon-bg);
    color: var(--color-icon-text);
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}
.module-info h4 {
    color: var(--color-text-title);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
}
.module-info p {
    color: var(--color-text-secondary);
    font-size: 0.85rem;
    line-height: 1.4;
}
.details-btn {
    background: none;
    border: 2px solid var(--color-border);
    color: var(--color-text-primary);
    padding: 0.4rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}
.details-btn:hover {
    background: rgba(0,0,0,0.05);
    border-color: var(--color-border-hover);
}

/* Detalles del módulo */
.module-details {
    background: var(--color-card-detail-bg);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease;
    opacity: 0;
}
.module-card.expanded .module-details {
    max-height: 350px;
    opacity: 1;
}
.detail-item {
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}
.detail-icon {
    background: rgba(0, 0, 0, 0.05);
    color: var(--color-text-primary);
    flex-shrink: 0;
    width: 35px;
    height: 35px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}
[data-theme="dark"] .detail-icon {
    background: rgba(255, 255, 255, 0.1);
}
.detail-item h5 {
    color: var(--color-text-title);
    font-weight: 600;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}
.detail-item p {
    color: var(--color-text-secondary);
    font-size: 0.8rem;
}


/* Panel de resumen */
.summary-panel {
    grid-area: sidebar;
    position: sticky;
    top: 90px;
    height: fit-content;
    max-height: calc(100vh - 110px);
}
.summary-card {
    background: var(--color-card-detail-bg);
    border: 2px solid var(--color-border);
    border-radius: 16px;
    padding: 1.5rem;
    backdrop-filter: blur(15px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}
.summary-card h3 {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
    color: var(--color-text-title);
}
.price-display {
    text-align: center;
    margin-bottom: 1.5rem;
    padding: 1.2rem;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 12px;
    border: 1px solid var(--color-border);
    transition: transform 0.3s ease;
}
[data-theme="dark"] .price-display {
    background: rgba(255, 255, 255, 0.05);
}
.total-price {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--color-text-title);
    margin-bottom: 0.4rem;
}
.currency {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
}

.payment-terms {
    background: rgba(0, 0, 0, 0.05);
    padding: 1.2rem;
    border-radius: 10px;
    border: 1px solid var(--color-border);
    margin-top: 1.5rem;
    margin-bottom: 1.2rem;
}
[data-theme="dark"] .payment-terms {
    background: rgba(45, 45, 45, 0.5);
}

.package-description {
    background: rgba(0, 0, 0, 0.05);
    padding: 1.2rem;
    border-radius: 10px;
    border: 1px solid var(--color-border);
    text-align: center;
}
[data-theme="dark"] .package-description {
    background: rgba(255, 255, 255, 0.1);
}
.package-description h4 {
    color: var(--color-text-title);
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.4rem;
}
.package-description p {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}


/* Estados de Módulos */
.module-card.active-neon {
    border-color: var(--color-border-hover);
    box-shadow: var(--shadow-neon);
}
.module-card.always-inactive {
    opacity: 0.4 !important;
    filter: grayscale(100%) !important;
    border-color: var(--color-border) !important;
    cursor: not-allowed;
    box-shadow: none !important;
}
.module-card.always-inactive .module-icon {
    background: var(--color-card-inactive-bg);
    color: var(--color-card-inactive-text);
    box-shadow: none;
}

.package-selector { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }
.modules-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0.8rem; padding-bottom: 1rem; }
.module-main-content { padding: 1rem; display: flex; align-items: flex-start; gap: 0.75rem; }
.module-card.expanded .details-btn i { transform: rotate(180deg); transition: transform 0.3s ease; }
.details-content { padding: 1rem; }
.detail-item:last-child { margin-bottom: 0; border-bottom: none; padding-bottom: 0; }
.payment-terms p { font-size: 0.8rem; text-align: center; }
.module-card:not(.active) { opacity: 0.6; pointer-events: none; filter: grayscale(90%); }
.module-card.active { opacity: 1; filter: grayscale(0%); }
@keyframes priceUpdate { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.price-updating { animation: priceUpdate 0.4s ease-out; }

/* Responsive */
@media (max-width: 1200px) {
    .main-container { grid-template-columns: 1fr; grid-template-areas: "main" "sidebar"; height: auto; }
    .summary-panel { position: static; max-height: none; }
    .configurator { max-height: none; overflow-y: visible; padding-right: 0; }
}

@media (max-width: 768px) {
    .header { flex-direction: column; gap: 0.5rem; padding-bottom: 1rem; text-align: center; }
    .header-text { text-align: center; }
    .header-text h1 { font-size: 1.2rem; }
    .main-container { padding-top: 130px; }
    .modules-grid { grid-template-columns: 1fr; }
    .package-selector { flex-direction: column; align-items: center; }
    .option { width: 100%; max-width: 300px; text-align: center; }
    .fullscreen-btn { top: 10px; right: 10px; }
    .theme-toggle-btn { top: 10px; right: 60px; }
    .module-card { animation-delay: 0s !important; }
}