/* ========================================
   SISTEMA DE CÓDIGOS - TEMA NEÓN (VERSIÓN FINAL)
   ======================================== */

/* --- VARIABLES DE COLOR Y DISEÑO --- */
:root {
    --primary-color: #32FFB5;
    --secondary-color: #764ba2;
    --glow-color: rgba(50, 255, 181, 0.25);
    --glow-border-color: rgba(50, 255, 181, 0.4);
    --bg-primary: #1A1235;
    --bg-card: #2A1F4D;
    --bg-input: rgba(0, 0, 0, 0.3);
    --text-primary: #FFFFFF;
    --text-secondary: #BCAEE5;
    --text-muted: #8c80b1;
    --border-color-subtle: #8c80b1;
    --border-focus: var(--primary-color);
    --shadow-glow: 0 0 15px var(--glow-color);
    --shadow-glow-strong: 0 0 25px var(--glow-color);
    --radius-md: 8px;
    --radius-lg: 16px;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --transition-base: 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* --- ESTILOS GENERALES Y FONDO ANIMADO --- */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
    z-index: 0;
}

/* Fondo: sin background-attachment:fixed para compatibilidad móvil */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-image: url('../images/fondo/fondo.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: scroll;
    filter: brightness(0.4);
    z-index: -2;
    animation: kenburns-effect 40s ease-in-out infinite alternate;
}

/* Scanlines — solo para inicio.php, no afecta mis_correos/buzon */
body::after {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: repeating-linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.05),
        rgba(255, 255, 255, 0.05) 1px,
        transparent 1px,
        transparent 4px
    );
    pointer-events: none;
    z-index: -1;
    animation: scanline-effect 20s linear infinite;
}

@keyframes scanline-effect {
    from { background-position: 0 0; }
    to   { background-position: 0 -400px; }
}

@keyframes kenburns-effect {
    from { transform: scale(1) translate(0, 0); }
    to   { transform: scale(1.1) translate(2%, -2%); }
}

/* --- BARRA DE NAVEGACIÓN ANTIGUA (oculta) --- */
.navbar-modern { display: none !important; }

/* --- CONTENEDOR PRINCIPAL Y TARJETA --- */
.main-container {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
    padding-top: 84px;
}
.main-card {
    width: 100%;
    max-width: 500px;
    background: var(--bg-card);
    border: 1px solid var(--glow-border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-glow-strong);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
    animation: card-glow-pulse 4s ease-in-out infinite;
}
@keyframes card-glow-pulse {
    0%   { box-shadow: 0 0 25px var(--glow-color); }
    50%  { box-shadow: 0 0 40px var(--glow-border-color); }
    100% { box-shadow: 0 0 25px var(--glow-color); }
}
.main-card.options-open { overflow: visible; }
.main-card.expanded { max-width: 800px; }
.hidden { display: none; }

/* --- OVERLAY DE LICENCIA --- */
.license-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.license-modal { max-width: 400px; width: 90%; text-align: center; }
.license-modal form { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }

/* --- ELEMENTOS DEL FORMULARIO --- */
.logo-container { text-align: center; margin-bottom: var(--spacing-md); }
.logo {
    width: 150px; height: 150px;
    object-fit: contain;
    animation: float-effect 3s ease-in-out infinite;
}
@keyframes float-effect {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-10px); }
}
.main-title {
    text-align: center;
    font-weight: 600;
    font-size: 1.8rem;
    margin-bottom: var(--spacing-lg);
    min-height: 40px;
}
.search-form { display: flex; flex-direction: column; gap: var(--spacing-lg); }
.form-group-modern { position: relative; }
.form-input-modern {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color-subtle);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 12px 12px 12px 40px;
    font-size: 1rem;
    transition: 0.3s ease;
}
.form-input-modern:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 10px var(--glow-color);
}
.form-icon {
    position: absolute;
    left: 15px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    transition: color 0.3s ease;
    font-size: 1rem;
}
.form-input-modern:focus + .form-icon,
.custom-select.open .form-icon { color: var(--primary-color); }

.btn-search-modern {
    background-color: var(--primary-color);
    color: var(--bg-primary);
    border: none;
    border-radius: 8px;
    padding: 12px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-base);
    text-transform: uppercase;
    box-shadow: 0 0 15px var(--glow-color);
    animation: button-glow-pulse 2.5s ease-in-out infinite;
}
@keyframes button-glow-pulse {
    0%   { box-shadow: 0 0 15px var(--glow-color); }
    50%  { box-shadow: 0 0 25px var(--primary-color); }
    100% { box-shadow: 0 0 15px var(--glow-color); }
}
.btn-search-modern:hover {
    transform: translateY(-3px);
    animation-play-state: paused;
    box-shadow: 0 0 30px var(--primary-color);
}

/* --- BOTONES NEÓN GENÉRICOS --- */
.neon-btn {
    background-color: var(--primary-color);
    color: var(--bg-primary);
    border: none;
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 0 15px var(--glow-color);
    transition: var(--transition-base);
}
.neon-btn:hover { box-shadow: 0 0 30px var(--primary-color); transform: translateY(-2px); }

/* --- MENÚ DESPLEGABLE PERSONALIZADO --- */
.custom-select-wrapper { position: relative; }
.custom-select { position: relative; }
.custom-select__trigger {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 12px 12px 40px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color-subtle);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-muted);
    transition: 0.3s ease;
}
.custom-select__trigger:hover { border-color: var(--glow-border-color); }
.custom-select.open .custom-select__trigger {
    border-color: var(--border-focus);
    box-shadow: 0 0 10px var(--glow-color);
}
.custom-options {
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: var(--bg-card);
    border: 1px solid var(--glow-border-color);
    border-radius: 8px;
    margin-top: 5px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: var(--transition-base);
}
.custom-select.open .custom-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.custom-option {
    display: block;
    padding: 12px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    color: var(--text-secondary);
}
.custom-option:hover { background-color: var(--glow-color); color: var(--primary-color); }
.arrow {
    width: 10px; height: 10px;
    border-left: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: rotate(-45deg);
    transition: transform 0.3s ease;
}
.custom-select.open .arrow { transform: rotate(135deg); }

/* Scrollbar neón */
.custom-options::-webkit-scrollbar { width: 8px; }
.custom-options::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); border-radius: 10px; }
.custom-options::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
    border-radius: 10px;
    border: 2px solid var(--bg-card);
    box-shadow: 0 0 10px var(--glow-color);
}
.custom-options::-webkit-scrollbar-thumb:hover {
    background-color: #ffffff;
    box-shadow: 0 0 15px var(--glow-border-color);
}

/* --- RESULTADOS Y FOOTER --- */
.results-container { animation: fadeIn 0.5s ease; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--glow-color);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition-base);
}
.btn-back:hover {
    background: var(--primary-color);
    color: var(--bg-primary);
    box-shadow: var(--shadow-glow-strong);
}
.alert-modern {
    padding: var(--spacing-md);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.alert-success-modern {
    background: rgba(50, 255, 181, 0.1);
    border: 1px solid rgba(50, 255, 181, 0.3);
    color: #adffde;
}
.alert-danger-modern {
    background: rgba(255, 77, 77, 0.1);
    border: 1px solid rgba(255, 77, 77, 0.3);
    color: #ff9a9a;
}
.alert-warning-modern {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border: 2px solid #f39c12;
    color: #856404;
    border-radius: 15px;
    padding: 1.2rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 8px 25px rgba(243, 156, 18, 0.15);
    position: relative;
    overflow: hidden;
}
.alert-warning-modern::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, #f39c12, #e67e22);
}
.alert-warning-modern i { font-size: 1.25rem; margin-right: 0.75rem; color: #f39c12; }
.alert-info-modern {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    border: 2px solid #17a2b8;
    color: #0c5460;
    border-radius: 15px;
    padding: 1.2rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 8px 25px rgba(23, 162, 184, 0.15);
    position: relative;
    overflow: hidden;
}
.alert-info-modern::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, #17a2b8, #138496);
}
.alert-info-modern i { font-size: 1.25rem; margin-right: 0.75rem; color: #17a2b8; }

.result-content-wrapper {
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    padding: var(--spacing-lg);
    margin-top: var(--spacing-md);
    border: 1px solid var(--border-color-subtle);
}
.footer-modern {
    padding: var(--spacing-lg);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.footer-modern a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

/* =============================================
   NUEVO NAVBAR CON SIDEBAR
   ============================================= */
.navbar-nuevo {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 60px;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: rgba(26, 18, 53, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(50, 255, 181, 0.15);
    box-shadow: 0 2px 20px rgba(0,0,0,0.4);
}
.navbar-nuevo-left {
    display: flex;
    align-items: center;
    gap: 14px;
}
.navbar-nuevo-brand {
    font-size: 1.3rem;
    font-weight: 600;
    color: #ffffff;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.01em;
}
.navbar-nuevo-brand i { color: var(--primary-color); }

.navbar-nuevo-center {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    color: rgba(255,255,255,0.5);
}
.navbar-status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #32FFB5;
    box-shadow: 0 0 8px #32FFB5;
    animation: dot-pulse 2.5s ease-in-out infinite;
    flex-shrink: 0;
}
@keyframes dot-pulse {
    0%, 100% { box-shadow: 0 0 4px #32FFB5; }
    50%       { box-shadow: 0 0 14px #32FFB5; }
}
.navbar-nuevo-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.navbar-username-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1.1rem;
    color: rgba(255,255,255,0.6);
}
.navbar-username-pill i { font-size: 1.1rem; }
.navbar-salir-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1.1rem;
    padding: 7px 18px;
    border: 1px solid rgba(255, 100, 100, 0.4);
    border-radius: 10px;
    color: #ff8080;
    text-decoration: none;
    transition: all 0.2s ease;
}
.navbar-salir-btn:hover {
    background: rgba(255, 100, 100, 0.12);
    border-color: rgba(255, 100, 100, 0.6);
    color: #ff6464;
}

/* --- BOTÓN HAMBURGER --- */
.hamburger-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px 8px;
    border-radius: 8px;
    transition: background 0.2s;
}
.hamburger-btn:hover { background: rgba(50, 255, 181, 0.1); }
.hb-line {
    display: block;
    width: 22px;
    height: 2px;
    background: rgba(255,255,255,0.75);
    border-radius: 2px;
    transition: all 0.3s ease;
}
.hamburger-btn:hover .hb-line { background: #32FFB5; }

/* --- OVERLAY SIDEBAR --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1040;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; animation: fadeInOv 0.2s ease; }
@keyframes fadeInOv { from { opacity: 0; } to { opacity: 1; } }

/* --- SIDEBAR PANEL --- */
.sidebar-panel {
    position: fixed;
    top: 0; left: 0;
    width: 270px;
    height: 100vh;
    z-index: 1050;
    background: #16132e;
    border-right: 1px solid rgba(50, 255, 181, 0.15);
    box-shadow: 4px 0 30px rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}
.sidebar-panel.open { transform: translateX(0); }

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}
.sidebar-brand i { color: #32FFB5; }
.sidebar-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.4);
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}
.sidebar-close:hover { color: #fff; background: rgba(255,255,255,0.08); }

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    background: rgba(50, 255, 181, 0.05);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(50, 255, 181, 0.12);
    border: 1px solid rgba(50, 255, 181, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: #32FFB5;
    flex-shrink: 0;
}
.sidebar-username { font-size: 13px; font-weight: 600; color: #fff; }
.sidebar-role { font-size: 11px; color: rgba(255,255,255,0.4); margin-top: 2px; }

.sidebar-divider { height: 1px; background: rgba(255,255,255,0.07); margin: 6px 0; }
.sidebar-section-label {
    font-size: 10px;
    color: rgba(255,255,255,0.3);
    letter-spacing: 0.12em;
    padding: 8px 18px 4px;
}
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 13px;
    transition: all 0.15s ease;
    border-left: 2px solid transparent;
    position: relative;
}
.sidebar-item:hover {
    color: #32FFB5;
    background: rgba(50, 255, 181, 0.07);
    border-left-color: #32FFB5;
}
.sidebar-item i:first-child { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-item span { flex: 1; }
.sidebar-ext-icon { font-size: 11px !important; opacity: 0.4; }
.sidebar-badge {
    font-size: 10px;
    padding: 1px 7px;
    border-radius: 20px;
    background: rgba(50, 255, 181, 0.15);
    color: #32FFB5;
    border: 1px solid rgba(50, 255, 181, 0.3);
    min-width: 24px;
    text-align: center;
}

/* Ajuste contenido principal */
.main-container { padding-top: 84px !important; }

/* =============================================
   RESPONSIVE MÓVIL
   ============================================= */
@media (max-width: 768px) {
    .navbar-nuevo { padding: 0 1rem; }
    .navbar-nuevo-center { display: none; }
    .navbar-username-pill { display: none; }
    .navbar-salir-btn { padding: 6px 12px; font-size: 0.9rem; }
    .navbar-salir-btn span { display: none; }
    .sidebar-panel { width: 100%; max-width: 300px; }

    .main-container { padding: 74px 0.75rem 1rem !important; }
    .main-card {
        max-width: 100% !important;
        border-radius: 14px !important;
        padding: 1.25rem !important;
    }
    .result-content-wrapper { padding: 0.75rem; }
    .result-content-wrapper * { max-width: 100% !important; box-sizing: border-box; }
    .result-content-wrapper img { max-width: 100% !important; height: auto !important; }
    .result-content-wrapper table { width: 100% !important; table-layout: fixed !important; }
}

@media (max-width: 480px) {
    .main-card { padding: 1rem !important; border-radius: 10px !important; }
    .main-title { font-size: 1.4rem; }
    .result-content-wrapper { padding: 0.5rem; font-size: 0.9rem; }
    body { overflow-x: hidden; }
}