/* =====================================================================
   ESTILOS DE LOS COMPONENTES (tarjetas, formularios, tablas, campañas...)
   ===================================================================== */
/* Sistema de Pestañas */


.container {
    max-width: 900px;
    margin: 30px auto;
    padding: 20px;
    background: #1e1e1e;
    border-radius: 10px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.kpi-card {
    background: #2a2a2a;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    border-left: 4px solid #4CAF50;
}

.kpi-card h3 {
    margin: 0;
    color: #aaa;
    font-size: 14px;
}

.kpi-card p {
    margin: 10px 0 0 0;
    font-size: 28px;
    font-weight: bold;
    color: #fff;
}

input,
select {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: 1px solid #444;
    border-radius: 5px;
    box-sizing: border-box;
    background: #2a2a2a;
    color: white;
}

label.campo {
    color: #aaa;
    margin-top: 10px;
    display: block;
}

button.action-btn {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 5px;
    cursor: pointer;
    width: 100%;
    font-weight: bold;
    font-size: 15px;
}

button.action-btn:hover {
    background-color: #45a049;
}

button.action-btn:disabled {
    background-color: #555;
    cursor: not-allowed;
    color: #888;
}

button.danger-btn {
    background-color: #f44336;
}

button.danger-btn:hover {
    background-color: #d32f2f;
}

.log-box {
    background: #111;
    padding: 15px;
    border-radius: 5px;
    font-family: monospace;
    font-size: 13px;
    color: #4CAF50;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 15px;
    white-space: pre-wrap;
}

/* Conexión (la clave NO se guarda en el archivo) */


/* Vista previa de la animación */
.vista-previa {
    display: none;
    margin-top: 15px;
    padding: 15px;
    background: #111;
    border-radius: 8px;
    text-align: center;
}

.vista-previa canvas {
    max-width: 256px;
    max-height: 256px;
    background: repeating-conic-gradient(#333 0% 25%, #222 0% 50%) 50% / 20px 20px;
    border-radius: 6px;
}

.vista-previa .datos {
    font-family: monospace;
    color: #aaa;
    margin-top: 10px;
}

.fila {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

/* Inventario de la tienda */
.inv-filtros {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px;
    align-items: center;
}

.inv-filtros button {
    background: #333;
    color: #fff;
    border: none;
    padding: 12px 16px;
    border-radius: 5px;
    cursor: pointer;
}

.inv-lista {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 10px;
}

.inv-item {
    background: #2a2a2a;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    border-top: 3px solid #e91e63;
}

.inv-item canvas {
    width: 96px;
    height: 96px;
    object-fit: contain;
    background: repeating-conic-gradient(#333 0% 25%, #222 0% 50%) 50% / 16px 16px;
    border-radius: 6px;
}

.inv-item .nombre {
    font-weight: bold;
    margin: 6px 0 2px;
    word-break: break-word;
}

.inv-item .meta {
    font-size: 12px;
    color: #aaa;
}

.inv-acciones {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.inv-acciones button {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: #fff;
    font-weight: bold;
}

.btn-editar { background: #2196F3; }
.btn-borrar { background: #f44336; }

#panelEditar {
    display: none;
    background: #252525;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #2196F3;
    margin-top: 15px;
}

@media (max-width: 600px) {
    .inv-filtros, .fila { grid-template-columns: 1fr; }
}

/* Ranking y medallas */
.barra-herramientas {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
}

.barra-herramientas select,
.barra-herramientas input {
    width: auto;
    margin: 0;
    flex: 1 1 160px;
}

.btn-chico {
    background: #333;
    color: #fff;
    border: none;
    padding: 10px 14px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    white-space: nowrap;
}

.btn-chico:hover { background: #444; }
.btn-chico.dorado { background: #c9962c; color: #1b1205; }
.btn-chico.azul { background: #2196F3; }
.btn-chico.verde { background: #4CAF50; }
.btn-chico.rojo { background: #f44336; }
.btn-chico:disabled { opacity: 0.45; cursor: not-allowed; }

.tabla-scroll { overflow-x: auto; }

table.ranking {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table.ranking th {
    text-align: left;
    color: #c9962c;
    font-size: 12px;
    letter-spacing: 1px;
    padding: 8px 6px;
    border-bottom: 1px solid #333;
    white-space: nowrap;
}

table.ranking td {
    padding: 8px 6px;
    border-bottom: 1px solid #262626;
    vertical-align: middle;
}

table.ranking tr:hover td { background: #242424; }
table.ranking .puesto { font-weight: bold; font-size: 16px; width: 36px; }
table.ranking .oro { color: #e3b54d; }
table.ranking .plata { color: #cdd2db; }
table.ranking .bronce { color: #cc854d; }
table.ranking .email { color: #888; font-size: 12px; }
table.ranking .acciones { white-space: nowrap; }
table.ranking .acciones button { padding: 6px 8px; margin-right: 3px; }
table.ranking input[type=checkbox] { width: auto; margin: 0; }

.grilla-medallas {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px;
}

.medalla-item {
    background: #2a2a2a;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    border-top: 3px solid #888;
}

.medalla-item.inactiva { opacity: 0.5; }
.medalla-item img { width: 90px; height: 90px; object-fit: contain; }
.medalla-item .nombre { font-weight: bold; margin-top: 6px; }
.medalla-item .desc { color: #aaa; font-size: 12px; min-height: 30px; }
.medalla-item .meta { color: #c9962c; font-size: 12px; margin: 4px 0; }
.medalla-item .acciones { display: flex; gap: 4px; margin-top: 8px; }
.medalla-item .acciones button { flex: 1; padding: 6px 4px; font-size: 12px; }

.sin-imagen {
    width: 90px;
    height: 90px;
    margin: 0 auto;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    color: #1b1205;
    font-weight: bold;
}

#panelMedalla {
    display: none;
    background: #252525;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #c9962c;
    margin-bottom: 15px;
}

/* Ventana de acciones (mensaje, invitación, medalla) */
#modalAccion {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

#modalAccion .caja {
    background: #1e1e1e;
    border: 1px solid #c9962c;
    border-radius: 10px;
    padding: 20px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
}

#modalAccion textarea {
    width: 100%;
    min-height: 110px;
    padding: 12px;
    margin: 10px 0;
    border: 1px solid #444;
    border-radius: 5px;
    box-sizing: border-box;
    background: #2a2a2a;
    color: white;
    font-family: inherit;
}

.destinatarios {
    background: #111;
    border-radius: 5px;
    padding: 8px 10px;
    color: #ccc;
    font-size: 13px;
    max-height: 80px;
    overflow-y: auto;
}

/* Campañas */
#panelCampana {
    display: none;
    background: #252525;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #e91e63;
    margin-bottom: 15px;
}

.previa-carrusel {
    position: relative;
    width: 100%;
    aspect-ratio: 1100 / 156;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(227, 181, 77, 0.45);
    background: #2a1a0d center / cover no-repeat;
    container-type: inline-size;
}

.previa-carrusel .sombra {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(10, 8, 5, 0.9) 0%, rgba(10, 8, 5, 0.5) 45%, rgba(10, 8, 5, 0) 75%);
}

.previa-carrusel .textos { position: absolute; left: 2.6%; top: 9%; width: 64%; }
.previa-carrusel .chip { color: #e3b54d; font-weight: bold; letter-spacing: 0.3em; font-size: 1.6cqw; }
.previa-carrusel .titulo { color: #fff; font-weight: bold; font-size: 3.2cqw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.previa-carrusel .bajada { color: #f5ede0; font-size: 2cqw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.previa-carrusel .cuenta { color: #e3b54d; font-weight: bold; font-size: 1.8cqw; margin-top: 0.4cqw; }

.previa-carrusel .boton {
    position: absolute;
    right: 2.6%;
    top: 50%;
    transform: translateY(-50%);
    background: #e3b54d;
    color: #211407;
    font-weight: bold;
    letter-spacing: 0.1em;
    border-radius: 1cqw;
    padding: 1.4cqw 2.6cqw;
    font-size: 2cqw;
}

.previa-franja {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(10, 8, 5, 0.85);
    border-top: 2px solid rgba(227, 181, 77, 0.5);
    padding: 10px 14px;
    border-radius: 6px;
    color: #f5ede0;
    font-size: 15px;
}

.previa-franja img { width: 34px; height: 34px; object-fit: contain; }
/* Banner de abajo del menú: 1800 × 110 (la proporción del juego), imagen centrada sobre fondo oscuro */
.previa-banner {
    aspect-ratio: 2340 / 110; width: 100%; display: flex; align-items: center; justify-content: center;
    background: rgba(15, 11, 8, 0.92); border: 1px solid rgba(227, 181, 77, 0.35); border-radius: 10px;
    overflow: hidden; color: #f5ede0; font-size: clamp(11px, 1.5vw, 20px); padding: 0 2%;
}
.previa-banner img { width: 100%; height: 100%; object-fit: cover; }
.previa-banner { position: relative; }
.previa-banner .capa { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 0 2%; }
.previa-banner .hoja-animada { width: 100%; height: 100%; background-repeat: no-repeat; }
.previa-banner.acercar .capa img, .previa-banner.acercar .capa .hoja-animada { animation: acercarBanner var(--segundos, 8s) linear infinite; }
.previa-banner .brillo {
    position: absolute; top: -60%; left: -15%; width: 7%; height: 220%; pointer-events: none;
    background: linear-gradient(90deg, transparent, rgba(255, 248, 217, 0.38), transparent);
    transform: rotate(20deg); animation: brilloBanner 4.4s ease-in-out infinite;
}
.previa-banner .capa.entra-deslizar { animation: entraDeslizar 0.5s cubic-bezier(0.22, 0.61, 0.36, 1); }
.previa-banner .capa.entra-carta { animation: entraCarta 0.5s ease-out; }
.previa-banner .capa.entra-fundido { animation: entraFundido 0.5s ease-out; }
@keyframes acercarBanner { from { transform: scale(1); } to { transform: scale(1.05); } }
@keyframes brilloBanner { 0%, 75% { left: -15%; } 95%, 100% { left: 110%; } }
@keyframes entraDeslizar { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes entraCarta { 0%, 50% { transform: scaleY(0); } 85% { transform: scaleY(1.08); } 100% { transform: scaleY(1); } }
@keyframes entraFundido { from { opacity: 0; } to { opacity: 1; } }
.caja-movimiento { border: 1px solid rgba(227, 181, 77, 0.3); border-radius: 8px; padding: 10px 12px; margin-top: 12px; background: rgba(227, 181, 77, 0.04); }
.caja-movimiento .titulo-movimiento { color: #e3b54d; font-weight: bold; }
.caja-movimiento .ayuda-movimiento { color: var(--texto-2); font-size: 13px; margin: 6px 0 0; }
.previa-franja .etiqueta { color: #e3b54d; font-weight: bold; letter-spacing: 0.2em; font-size: 12px; }

.lista-campanas { display: grid; gap: 12px; }

.campana-item {
    display: grid;
    grid-template-columns: 220px 1fr auto;
    gap: 14px;
    align-items: center;
    background: #2a2a2a;
    border-radius: 8px;
    padding: 10px;
}

.campana-item .miniatura {
    width: 220px;
    aspect-ratio: 1100 / 156;
    border-radius: 6px;
    background: #2a1a0d center / cover no-repeat;
    border: 1px solid #444;
}

.campana-item .titulo { font-weight: bold; }
.campana-item .detalle { color: #aaa; font-size: 12px; margin-top: 3px; }
.campana-item .numeros { color: #e3b54d; font-size: 13px; margin-top: 5px; }
.campana-item .acciones { display: flex; flex-direction: column; gap: 4px; }
.campana-item .acciones button { padding: 6px 10px; font-size: 12px; }

.estado {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
    margin-left: 6px;
    vertical-align: middle;
}

.estado.activa { background: #2e7d32; }
.estado.programada { background: #1565c0; }
.estado.terminada { background: #555; }
.estado.pausada { background: #8d6e00; }

/* Anunciantes y reportes */
.grilla-anunciantes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 12px;
    margin-bottom: 15px;
}

.anunciante-item {
    background: #2a2a2a;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    border-left: 4px solid #e3b54d;
}

.anunciante-item:hover { background: #303030; }
.anunciante-item.elegido { outline: 2px solid #e3b54d; }
.anunciante-item.inactivo { opacity: 0.55; border-left-color: #666; }
.anunciante-item .nombre { font-weight: bold; font-size: 16px; }
.anunciante-item .detalle { color: #aaa; font-size: 12px; margin-top: 4px; }

.seccion {
    background: #252525;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.seccion h3 { margin-top: 0; color: #e3b54d; }

.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin: 12px 0;
}

.kpi {
    background: #1b1b1b;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.kpi .valor { font-size: 26px; font-weight: bold; color: #fff; }
.kpi .nombre { font-size: 11px; color: #aaa; letter-spacing: 1px; margin-top: 4px; }

.grafico { width: 100%; height: auto; background: #1b1b1b; border-radius: 8px; }

#reporteImprimible .cabecera-impresion { display: none; }

@media print {

    body * { visibility: hidden; }
    #reporteImprimible, #reporteImprimible * { visibility: visible; }
    #reporteImprimible { position: absolute; left: 0; top: 0; width: 100%; background: #fff; color: #000; padding: 0; }
    #reporteImprimible .no-imprimir { display: none !important; }
    #reporteImprimible .cabecera-impresion { display: block; margin-bottom: 16px; }
    #reporteImprimible .kpi { background: #f3efe6; border: 1px solid #ddd; }
    #reporteImprimible .kpi .valor { color: #000; }
    #reporteImprimible .kpi .nombre { color: #555; }
    #reporteImprimible table.ranking th { color: #7a5a12; }
    #reporteImprimible table.ranking td { border-bottom: 1px solid #ddd; color: #000; }
    #reporteImprimible .grafico { background: #fff; border: 1px solid #ddd; }
}

@media (max-width: 700px) {
    .campana-item { grid-template-columns: 1fr; }
    .campana-item .miniatura { width: 100%; }
    .campana-item .acciones { flex-direction: row; }
}

@media (max-width: 600px) {
    .container { padding: 12px; margin: 12px; }
}

/* =====================================================================
   DISEÑO DEL PANEL (va después de los estilos de cada componente)
   ===================================================================== */
:root {
    --acento: #e3b54d;
    --acento-oscuro: #c9962c;
    --texto-sobre-acento: #1b1205;
    --fondo: #0f0f10;
    --fondo-lateral: #151516;
    --tarjeta: #1c1c1e;
    --tarjeta-2: #242427;
    --borde: #2c2c30;
    --texto: #ececec;
    --texto-2: #a3a3a8;
    --ok: #4caf50;
    --error: #ef5350;
    --info: #42a5f5;
    --lateral: 248px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--fondo);
    color: var(--texto);
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
}

h2 { font-size: 22px; margin: 0 0 6px; }
h3 { font-size: 16px; }

/* --- Login --- */
#panelConexion {
    max-width: 420px;
    margin: 12vh auto;
    padding: 32px;
    background: var(--tarjeta);
    border: 1px solid var(--borde);
    border-top: 3px solid var(--acento);
    border-radius: 12px;
}

#panelConexion .marca { font-size: 22px; font-weight: 700; color: var(--acento); margin-bottom: 4px; }
#panelConexion .bajada { color: var(--texto-2); margin-bottom: 18px; }

/* --- Estructura: menú lateral + contenido --- */
#panelPrincipal { display: none; }
#panelPrincipal.visible { display: grid; grid-template-columns: var(--lateral) 1fr; min-height: 100vh; }

#lateral {
    background: var(--fondo-lateral);
    border-right: 1px solid var(--borde);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: 18px 12px;
}

#lateral .marca { font-weight: 800; font-size: 17px; color: var(--acento); padding: 4px 10px 18px; letter-spacing: 0.5px; }
#lateral .marca span { display: block; font-size: 11px; color: var(--texto-2); font-weight: 500; letter-spacing: 2px; }
#lateral .grupo { font-size: 11px; color: var(--texto-2); letter-spacing: 1.5px; text-transform: uppercase; padding: 16px 10px 6px; }

#lateral .item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: none;
    background: none;
    color: var(--texto);
    padding: 9px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    text-align: left;
    border-left: 3px solid transparent;
}

#lateral .item:hover { background: var(--tarjeta-2); }
#lateral .item.activo { background: rgba(227, 181, 77, 0.12); color: var(--acento); border-left-color: var(--acento); font-weight: 600; }
#lateral .item .icono { width: 20px; text-align: center; }

#principal { min-width: 0; }

#barraArriba {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 28px;
    background: rgba(15, 15, 16, 0.92);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--borde);
}

#barraArriba .titulo { font-size: 18px; font-weight: 700; flex: 1; }
#barraArriba .sesion { color: var(--texto-2); font-size: 13px; }
#barraArriba button { background: var(--tarjeta-2); color: var(--texto); border: 1px solid var(--borde); padding: 7px 12px; border-radius: 6px; cursor: pointer; }
#botonMenu { display: none; }

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 28px 60px;
    background: none;
    box-shadow: none;
    border-radius: 0;
}

/* Las secciones: el título de la barra ya dice dónde estás */
.tab-content > h2:first-child { display: none; }

/* --- Componentes con el color del juego --- */
button.action-btn { background-color: var(--acento); color: var(--texto-sobre-acento); border-radius: 8px; }
button.action-btn:hover { background-color: var(--acento-oscuro); }
input, select, textarea { background: var(--tarjeta-2) !important; border-color: var(--borde) !important; color: var(--texto) !important; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(227, 181, 77, 0.5); }
.seccion, #panelEditar, #panelMedalla, #panelCampana, .kpi, .anunciante-item, .campana-item, .medalla-item, .inv-item {
    background: var(--tarjeta) !important;
    border: 1px solid var(--borde);
}
.kpi { text-align: left; padding: 14px 16px; }
.kpi .valor { font-size: 24px; }
.kpi .nombre { letter-spacing: 1px; }
.kpi .detalle { color: var(--texto-2); font-size: 12px; margin-top: 4px; }
.kpi.acento { border-top: 3px solid var(--acento); }
.kpi.verde { border-top: 3px solid var(--ok); }
.kpi.azul { border-top: 3px solid var(--info); }
.kpi.violeta { border-top: 3px solid #b77cf2; }

.grupo-kpis { margin-bottom: 22px; }
.grupo-kpis > .titulo-grupo { font-size: 12px; color: var(--texto-2); letter-spacing: 1.5px; text-transform: uppercase; margin-bottom: 8px; }

.dos-columnas { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Tablas ordenables */
table.ranking th.ordenable { cursor: pointer; user-select: none; }
table.ranking th.ordenable:hover { color: #fff; }
table.ranking td.numero, table.ranking th.numero { text-align: right; }
.barra-interes { height: 8px; border-radius: 4px; background: var(--tarjeta-2); overflow: hidden; min-width: 80px; }
.barra-interes > div { height: 100%; background: linear-gradient(90deg, var(--acento-oscuro), var(--acento)); }

.leyenda { display: flex; gap: 16px; flex-wrap: wrap; color: var(--texto-2); font-size: 12px; margin: 6px 0; }
.leyenda i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }

/* Avisos flotantes */
#avisos { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.aviso { background: var(--tarjeta-2); border: 1px solid var(--borde); border-left: 4px solid var(--ok); padding: 10px 14px; border-radius: 8px; min-width: 240px; max-width: 380px; }
.aviso.error { border-left-color: var(--error); }

/* --- Celular / ventana chica --- */
@media (max-width: 900px) {
    #panelPrincipal.visible { grid-template-columns: 1fr; }
    #lateral { position: fixed; left: 0; top: 0; z-index: 50; width: var(--lateral); transform: translateX(-100%); transition: transform 0.2s; }
    #lateral.abierto { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, 0.6); }
    #botonMenu { display: inline-block; }
    .container { padding: 16px; }
    .dos-columnas { grid-template-columns: 1fr; }
}
