/* ============================================================
   ESPACIO BALAGUER - ESTILOS GLOBALES
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #667eea;
    --secondary: #764ba2;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #1f2937;
    --light: #f9fafb;
    --gray: #6b7280;
    --border: #e5e7eb;
    --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* ============================================================
   BODY BASE (fondo por defecto para admin y success)
   ============================================================ */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gradient);
    min-height: 100vh;
    color: var(--dark);
    line-height: 1.6;
}

/* ============================================================
   FONDO PERSONALIZADO PARA LA LANDING PÚBLICA
   Solo se aplica cuando el body tiene la clase "landing-page"
   La imagen ya tiene su propio tratamiento (negro con opacidad)
   ============================================================ */
body.landing-page {
    background-image: url('../img/fondo.jpg');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    position: relative;
}

/* Sin overlay - la imagen ya viene tratada */
body.landing-page::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    z-index: 0;
    pointer-events: none;
}

/* Asegurar que el contenido esté por encima */
body.landing-page .container {
    position: relative;
    z-index: 1;
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 30px 20px;
}

/* ============================================================
   HERO / HEADER LANDING
   ============================================================ */
.hero {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

/* Logo en el hero (logo blanco sobre fondo oscuro) */
.hero-logo {
    max-width: 280px;
    width: 100%;
    height: auto;
    margin: 0 auto 16px;
    display: block;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
}

.hero h1 {
    font-size: 38px;
    font-weight: 800;
    letter-spacing: -1px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}
.hero .tagline {
    font-size: 16px;
    opacity: 0.95;
    margin-top: 6px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* ============================================================
   TARJETAS GENERALES (Landing)
   ============================================================ */
.card {
    background: white;
    border-radius: 20px;
    padding: 36px;
    margin-bottom: 24px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.card h2 {
    color: var(--secondary);
    margin-bottom: 10px;
    font-size: 24px;
}
.card .desc {
    color: var(--gray);
    margin-bottom: 24px;
}

/* ============================================================
   CAMPOS DE FORMULARIO
   ============================================================ */
.field { margin-bottom: 18px; }
.field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--dark);
    font-size: 14px;
}
.field input, .field select, .field textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    transition: all 0.2s;
    font-family: inherit;
}
.field input:focus, .field select:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(118, 75, 162, 0.1);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
@media (max-width: 600px) {
    .grid-2 { grid-template-columns: 1fr; }
}

/* ============================================================
   SELECCIÓN DE BENEFICIOS (Tarjetas clickeables)
   ============================================================ */
.benefits {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-top: 10px;
}

.benefit-option {
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 20px 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
    position: relative;
    user-select: none;
}

.benefit-option:hover {
    border-color: var(--secondary);
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(118, 75, 162, 0.15);
}

.benefit-option input { 
    display: none; 
}

/* ESTADO ACTIVO - CUANDO ESTÁ SELECCIONADO */
.benefit-option.active {
    border-color: var(--secondary);
    background: linear-gradient(135deg, rgba(102,126,234,0.12), rgba(118,75,162,0.12));
    box-shadow: 0 6px 20px rgba(118, 75, 162, 0.25);
    transform: translateY(-2px);
}

/* INDICADOR VISUAL DE SELECCIÓN (checkmark) */
.benefit-option.active::before {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--secondary);
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.benefit-icon { 
    font-size: 36px; 
    margin-bottom: 8px;
    display: block;
}

.benefit-name { 
    font-weight: 700; 
    color: var(--dark); 
    font-size: 14px; 
    margin-bottom: 4px;
    display: block;
}

.benefit-desc { 
    font-size: 12px; 
    color: var(--gray);
    display: block;
    line-height: 1.4;
}

.benefit-option:focus-within {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ============================================================
   BOTONES GENERALES
   ============================================================ */
.btn {
    display: inline-block;
    padding: 13px 24px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s;
    font-family: inherit;
}
.btn-primary {
    background: var(--gradient);
    color: white;
    width: 100%;
    padding: 16px;
    font-size: 16px;
    letter-spacing: 0.5px;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(118,75,162,0.35); }
.btn-secondary {
    background: white;
    color: var(--secondary);
    border: 2px solid var(--secondary);
}
.btn-secondary:hover { background: var(--secondary); color: white; }
.btn-instagram {
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    color: white;
    width: 100%;
    padding: 16px;
    margin-top: 20px;
}
.btn-instagram:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(220,39,67,0.35); }

/* ============================================================
   ALERTAS
   ============================================================ */
.alert {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 18px;
    font-size: 14px;
}
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* ============================================================
   PANTALLA DE ÉXITO
   ============================================================ */
.success-page { background: var(--gradient); }
.success-card {
    background: white;
    border-radius: 20px;
    padding: 40px 30px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}
.success-icon { font-size: 72px; margin-bottom: 10px; }
.success-card h1 { color: var(--secondary); font-size: 26px; margin-bottom: 24px; }

.beneficio-box, .codigo-box {
    background: #f6f8ff;
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 18px;
}
.beneficio-box .label, .codigo-box .label {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--gray);
    font-weight: 600;
    letter-spacing: 1px;
    margin-bottom: 6px;
}
.beneficio-box .value { font-size: 20px; font-weight: 700; color: var(--dark); }
.codigo-box .codigo {
    font-size: 36px;
    font-weight: 900;
    color: var(--secondary);
    letter-spacing: 2px;
    font-family: 'Courier New', monospace;
    margin: 8px 0;
}
.btn-copy {
    background: var(--secondary);
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    margin-top: 6px;
}

.instrucciones {
    background: #fefce8;
    border-left: 4px solid var(--warning);
    padding: 14px;
    border-radius: 10px;
    margin: 20px 0;
    text-align: left;
}

.link-home {
    display: inline-block;
    margin-top: 20px;
    color: white;
    text-decoration: none;
    opacity: 0.9;
}
.link-home:hover { opacity: 1; }

/* ============================================================
   FOOTER
   ============================================================ */
footer {
    text-align: center;
    color: white;
    opacity: 0.9;
    margin-top: 30px;
    font-size: 13px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
footer a { color: white; }

/* ============================================================
   ADMIN LOGIN
   ============================================================ */
.admin-login { background: var(--gradient); display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-card h1 { color: var(--secondary); text-align: center; margin-bottom: 6px; }
.login-card .subtitle { text-align: center; color: var(--gray); margin-bottom: 24px; }

/* ============================================================
   DASHBOARD ADMIN - LAYOUT COMPLETO
   ============================================================ */

.admin-dashboard {
    background: #f3f4f6;
    min-height: 100vh;
}

.dashboard-wrap {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px;
}

/* Header admin */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 14px 28px;
    border-radius: 14px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    flex-wrap: wrap;
    gap: 12px;
}

/* Logo en el header admin (conversión automática a negro) */
.admin-logo {
    max-height: 45px;
    width: auto;
    display: block;
    /* Filtro CSS para convertir logo blanco a negro automáticamente */
    filter: brightness(0) invert(0);
}

.header-left {
    display: flex;
    align-items: center;
}
.header-left h1 {
    font-size: 22px;
    color: var(--secondary);
    margin: 0;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 14px;
}
.user-info {
    font-size: 14px;
    color: var(--dark);
    font-weight: 500;
}
.btn-logout {
    background: var(--danger);
    color: white;
    padding: 8px 18px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: opacity 0.2s;
}
.btn-logout:hover { opacity: 0.85; }

/* Sección de estadísticas */
.stats-section {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    padding: 28px 20px;
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    text-align: center;
    border-top: 4px solid var(--primary);
}
.stat-card.stat-used { border-top-color: var(--success); }
.stat-card.stat-pending { border-top-color: var(--warning); }
.stat-card.stat-benefit { border-top-color: var(--secondary); }
.stat-number {
    font-size: 36px;
    font-weight: 800;
    color: var(--dark);
    line-height: 1;
    margin-bottom: 8px;
}
.stat-label {
    font-size: 13px;
    color: var(--gray);
    font-weight: 500;
}

/* Sección QR */
.qr-section { margin-bottom: 24px; }

.qr-card {
    background: white;
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 32px;
    align-items: center;
}

.qr-left h2 {
    color: var(--secondary);
    font-size: 22px;
    margin-bottom: 12px;
}
.qr-description {
    color: var(--gray);
    margin-bottom: 18px;
    line-height: 1.6;
    font-size: 14px;
}
.qr-url-box {
    background: #f6f8ff;
    padding: 14px 16px;
    border-radius: 10px;
    margin-bottom: 18px;
    border-left: 4px solid var(--secondary);
    font-size: 14px;
}
.qr-url-box strong {
    display: block;
    margin-bottom: 4px;
    color: var(--dark);
}
.qr-url-box code {
    word-break: break-all;
    color: var(--secondary);
    font-size: 13px;
}
.qr-tips {
    list-style: none;
    padding: 0;
    margin: 0;
}
.qr-tips li {
    padding: 5px 0;
    color: var(--dark);
    font-size: 14px;
    line-height: 1.5;
}

.qr-right {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.qr-image-box {
    background: white;
    padding: 20px;
    border: 3px dashed var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 280px;
}
.qr-image-box img {
    width: 100%;
    height: auto;
    display: block;
}

.btn-download {
    background: var(--gradient);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    max-width: 280px;
    transition: all 0.2s;
}
.btn-download:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(118,75,162,0.3);
}

.btn-print {
    background: white;
    color: var(--secondary);
    border: 2px solid var(--secondary);
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    max-width: 280px;
    transition: all 0.2s;
}
.btn-print:hover {
    background: var(--secondary);
    color: white;
}

/* Toolbar */
.toolbar-section { margin-bottom: 24px; }
.toolbar {
    background: white;
    padding: 18px;
    border-radius: 14px;
    display: flex;
    gap: 12px;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    flex-wrap: wrap;
}
.toolbar-search { flex: 1; min-width: 220px; }
.toolbar-search input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}
.toolbar-search input:focus {
    outline: none;
    border-color: var(--secondary);
}
.toolbar-filters { display: flex; gap: 10px; }
.toolbar-filters select {
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: white;
    cursor: pointer;
}
.toolbar-filters select:focus {
    outline: none;
    border-color: var(--secondary);
}
.btn-export {
    background: white;
    color: var(--secondary);
    border: 2px solid var(--secondary);
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn-export:hover {
    background: var(--secondary);
    color: white;
}

/* Tabla */
.table-section { margin-bottom: 24px; }
.table-container {
    background: white;
    border-radius: 14px;
    overflow-x: auto;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
thead { background: var(--light); }
th {
    padding: 14px 12px;
    text-align: left;
    font-weight: 700;
    color: var(--dark);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tr:hover { background: var(--light); }

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    white-space: nowrap;
}
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-used { background: #d1fae5; color: #065f46; }

.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-action {
    padding: 6px 10px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
}
.btn-mark { background: var(--success); }
.btn-edit { background: var(--primary); }
.btn-delete { background: var(--danger); }
.btn-action:hover { opacity: 0.85; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
    background: white;
    border-radius: 16px;
    padding: 30px;
    max-width: 460px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}
.modal h2 { color: var(--secondary); margin-bottom: 20px; font-size: 20px; }
.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}
.btn-cancel {
    background: white;
    color: var(--gray);
    border: 2px solid var(--border);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.btn-cancel:hover { border-color: var(--gray); }
.btn-save {
    background: var(--gradient);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}
.btn-save:hover { opacity: 0.9; }

/* Impresión (solo el QR) */
@media print {
    body * { visibility: hidden; }
    .qr-section, .qr-section * { visibility: visible; }
    .qr-section {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 40px;
    }
    .qr-card {
        display: flex;
        justify-content: center;
        align-items: center;
        box-shadow: none;
    }
    .qr-left { display: none !important; }
    .qr-right {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    .qr-image-box {
        border: 2px solid #000;
        max-width: 400px;
    }
    .btn-download, .btn-print { display: none !important; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    .stats-section { grid-template-columns: repeat(2, 1fr); }
    .qr-card { grid-template-columns: 1fr; }
    .qr-right { order: -1; }
}

@media (max-width: 640px) {
    .hero h1 { font-size: 28px; }
    .hero-logo { max-width: 200px; }
    .card { padding: 24px; }
    
    .admin-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .stats-section { grid-template-columns: 1fr 1fr; }
    
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .toolbar-search, .toolbar-filters { width: 100%; }
    .toolbar-filters { flex-direction: column; }
    .toolbar-filters select { width: 100%; }
    .btn-export { width: 100%; }
}