/* Colectate Rifas — panel admin. Paleta alineada a colectate.com.uy
   (verde azulado primario + amarillo de acento, según la marca real). */

@import url('https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,800;1,800&display=swap');

:root {
    --color-primary: #1b7a72;
    --color-primary-dark: #125650;
    --color-accent: #ffc93c;
    --color-secondary: #0f3d3a;
    --color-secondary-light: #1b5c57;
    --color-bg: #f5f6f8;
    --color-surface: #ffffff;
    --color-border: #e4e6eb;
    --color-text: #1f2430;
    --color-text-muted: #6b7280;
    --color-success-bg: #e6f7ee;
    --color-success-text: #0a7d3f;
    --color-error-bg: #fdecea;
    --color-error-text: #b3261e;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(20, 20, 30, 0.06);
}

* {
    box-sizing: border-box;
}

[hidden] { display: none !important; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 15px;
    line-height: 1.5;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1 {
    font-size: 1.4rem;
    margin: 0 0 1.25rem;
}

h2 {
    font-size: 1.1rem;
    margin: 0 0 1rem;
}

/* ---------- Shell: sidebar + contenido ---------- */

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: var(--color-secondary);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 0;
}

.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
}

.sidebar-brand {
    font-family: 'Raleway', sans-serif;
    font-weight: 800;
    font-style: italic;
    font-size: 1.15rem;
    padding-bottom: 1.5rem;
    color: #fff;
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.sidebar-brand .marca-producto {
    color: var(--color-accent);
    font-style: normal;
}

/* Botón hamburguesa: oculto en desktop, el menú siempre se ve entero ahí. */
.sidebar-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    padding: 0;
}
.sidebar-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    margin: 0 auto;
    background: #fff;
    border-radius: 999px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.sidebar-nav-wrap {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.sidebar-nav-wrap nav {
    display: flex;
    flex-direction: column;
}

.sidebar nav a {
    color: #cfd6e0;
    padding: 0.65rem 1.5rem;
    font-size: 0.9rem;
    border-left: 3px solid transparent;
}

.sidebar nav a:hover {
    color: #fff;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.05);
}

.sidebar nav a.active {
    color: #fff;
    background: var(--color-secondary-light);
    border-left-color: var(--color-primary);
    font-weight: 600;
}

.sidebar-footer {
    padding: 1rem 1.5rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: auto;
    padding-top: 1rem;
    font-size: 0.8rem;
}

.sidebar-footer .admin-name {
    color: #fff;
    font-weight: 600;
}

.sidebar-footer .admin-role {
    color: #9aa5b3;
    margin-bottom: 0.6rem;
    text-transform: capitalize;
}

.sidebar-footer a {
    display: block;
    color: #cfd6e0;
    font-size: 0.85rem;
    margin-top: 0.35rem;
}

.content {
    flex: 1;
    padding: 2rem 2.5rem;
    min-width: 0; /* ocupa todo el ancho disponible (los formularios mantienen su ancho propio: form.stacked) */
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

/* ---------- Componentes ---------- */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.alert {
    padding: 0.65rem 0.9rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
}

.alert-success {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.alert-error {
    background: var(--color-error-bg);
    color: var(--color-error-text);
}

.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.btn:hover {
    background: var(--color-primary-dark);
    text-decoration: none;
}

/* Formulario ya enviado (anti-doble-envio.js): se ve ocupado y no recibe más toques. */
.btn.enviando {
    opacity: 0.6;
    cursor: wait;
    pointer-events: none;
}

.btn-secondary {
    background: transparent;
    color: var(--color-secondary);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: #fafafa;
}

.btn-link-danger {
    background: none;
    border: none;
    color: var(--color-error-text);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0;
}

.btn-link-danger:hover {
    text-decoration: underline;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

/* Fila de datos + fila de acciones a ancho completo (colspan) por cada
   registro, en vez de apretar todos los chips en la última columna angosta
   de la tabla — ahí quedaban cortados en 2-3 líneas desparejas. */
tr.row-top td {
    border-bottom: none;
    padding-bottom: 0.4rem;
}

tr.row-actions td {
    padding-top: 0.55rem;
    padding-bottom: 0.75rem;
    border-top: 1px solid var(--color-border);
    background: #fafbfc;
}

.btn-chip {
    display: inline-block;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    background: #fff;
    color: var(--color-text);
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    line-height: 1.4;
}
.btn-chip:hover { background: #f5f6f8; text-decoration: none; }

.btn-chip-primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}
.btn-chip-primary:hover { background: var(--color-primary-dark); }

.btn-chip-danger {
    background: none;
    border-color: var(--color-error-text);
    color: var(--color-error-text);
}
.btn-chip-danger:hover { background: var(--color-error-bg); }

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    text-align: left;
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.88rem;
}

th {
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

tr:last-child td {
    border-bottom: none;
}

code {
    background: #f1f2f6;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.badge-borrador { background: #eef0f3; color: #555b66; }
.badge-activa { background: var(--color-success-bg); color: var(--color-success-text); }
.badge-finalizada { background: #e7edf5; color: var(--color-secondary); }
.badge-cancelada { background: var(--color-error-bg); color: var(--color-error-text); }

/* Badges clickeables (filtro de compras por estado en Ventas) */
a.badge-link { text-decoration: none; cursor: pointer; }
a.badge-link:hover { filter: brightness(0.95); text-decoration: none; }
.badge-sel { box-shadow: 0 0 0 2px var(--color-secondary); }

/* ---------- Tarjetas de resumen (ventas) ---------- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-tile {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.stat-tile .valor { font-size: 1.5rem; font-weight: 700; color: var(--color-secondary); }
.stat-tile .etiqueta { font-size: 0.8rem; color: var(--color-text-muted); }

.chip-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ---------- Formularios ---------- */

form.stacked {
    max-width: none; /* los formularios también ocupan todo el ancho del panel */
}

label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: #444;
    margin: 1rem 0 0.35rem;
}

label:first-child {
    margin-top: 0;
}

input, select, textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    background: #fff;
    color: var(--color-text);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(27, 122, 114, 0.15);
}

input[readonly] {
    background: #f7f7f8;
    color: var(--color-text-muted);
}

textarea {
    resize: vertical;
    min-height: 90px;
}

.hint {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    margin-top: 0.3rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row > div {
    flex: 1;
}

.detalle-lista {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.5rem 1.25rem;
    margin: 0;
}

.detalle-lista dt {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.detalle-lista dd {
    margin: 0;
    font-weight: 600;
}

.org-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 6px;
}

.org-color-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 0.4rem;
}

input[type="color"] {
    max-width: 80px;
    padding: 0.2rem;
}

img.preview {
    max-width: 100%;
    border-radius: var(--radius);
    margin-top: 0.5rem;
    display: block;
}

/* ---------- Login (sin sidebar) ---------- */

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-secondary);
}

.auth-card {
    background: var(--color-surface);
    padding: 2.5rem;
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 360px;
}

.auth-card h1 {
    font-size: 1.15rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-card .btn {
    width: 100%;
    padding: 0.7rem;
    margin-top: 0.5rem;
}

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        padding: 0;
    }

    .sidebar-top {
        padding: 0.75rem 1rem;
    }

    .sidebar-brand {
        padding-bottom: 0;
    }

    /* El menú (links + datos del admin + cerrar sesión) queda oculto y se
       despliega debajo de la barra al tocar el botón hamburguesa. */
    .sidebar-toggle {
        display: flex;
    }

    .sidebar-nav-wrap {
        display: none;
        flex: none;
        width: 100%;
        border-top: 1px solid rgba(255, 255, 255, 0.15);
        padding: 0.5rem 0.75rem 0.75rem;
    }
    .sidebar-nav-wrap.is-open {
        display: flex;
    }

    /* Links como pills apiladas: más fáciles de tocar y el activo se nota
       por el fondo, no por un borde fino. */
    .sidebar-nav-wrap nav {
        gap: 0.15rem;
    }
    .sidebar nav a {
        border-left: none;
        border-radius: 999px;
        padding: 0.75rem 1.1rem;
    }
    .sidebar nav a.active {
        border-left-color: transparent;
    }

    .sidebar-footer {
        border-top: 1px solid rgba(255, 255, 255, 0.15);
        margin-top: 0.5rem;
        padding: 0.85rem 1.1rem 0.25rem;
    }

    .content {
        padding: 1.25rem;
        max-width: 100%;
    }

    .content-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    .content-header .btn, .content-header .btn-secondary {
        text-align: center;
    }

    .card {
        padding: 1rem;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    table {
        font-size: 0.82rem;
    }
    th, td {
        padding: 0.55rem 0.5rem;
        white-space: nowrap;
    }

    code {
        word-break: break-all;
        white-space: normal;
    }

    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Botones de acción de las tablas (Ventas/Vendedores/Editar/Cancelar):
       pills más grandes y con más aire, más fáciles de tocar con el pulgar. */
    .table-actions {
        gap: 0.5rem;
    }
    .btn-chip {
        padding: 0.45rem 0.9rem;
        font-size: 0.8rem;
    }

    .auth-card {
        padding: 1.75rem 1.25rem;
    }
}


/* ---------- Reportes (gráficos) ---------- */

.chart-scroll { overflow-x: auto; }
.chart-svg { width: 100%; min-width: 560px; height: auto; display: block; }
.chart-grid { stroke: var(--color-border); stroke-width: 1; }
.chart-baseline { stroke: var(--color-text-muted); stroke-width: 1; }
.chart-axis { fill: var(--color-text-muted); font-size: 11px; }
.chart-bar { fill: var(--color-primary); }
.chart-bar:hover { fill: var(--color-accent); }

.medios-barras { display: flex; flex-direction: column; gap: 0.75rem; }
.medio-fila { display: grid; grid-template-columns: 160px 1fr 190px; gap: 0.75rem; align-items: center; }
.medio-nombre { font-weight: 600; }
.medio-proveedor { display: block; font-weight: 400; color: var(--color-text-muted); font-size: 0.8rem; }
.medio-barra { background: var(--color-bg); border-radius: 999px; height: 14px; overflow: hidden; }
.medio-barra span { display: block; height: 100%; background: var(--color-primary); border-radius: 999px; }
.medio-valor { text-align: right; white-space: nowrap; }
.medio-valor small { display: block; color: var(--color-text-muted); }

@media (max-width: 720px) {
    .medio-fila { grid-template-columns: 1fr; gap: 0.25rem; }
    .medio-valor { text-align: left; }
    .medio-valor small { display: inline; margin-left: 0.5rem; }
}

/* Reportes: separación entre secciones y encabezados uniformes */
.reportes .stat-grid { margin-bottom: 2rem; }
.reportes .reporte { margin-bottom: 2rem; }
.reporte-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    padding-bottom: 1rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--color-border);
}
.reporte-head h2 { margin: 0 0 0.25rem; }
.reporte-head .hint { margin: 0; max-width: 560px; }
.reporte-detalle { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--color-border); }
.reporte-detalle summary { cursor: pointer; font-weight: 600; color: var(--color-primary); margin-bottom: 0.5rem; }
.reportes .medios-barras { gap: 0; }
.reportes .medio-fila { padding: 0.9rem 0; border-bottom: 1px solid var(--color-border); }
.reportes .medio-fila:first-child { padding-top: 0; }
.reportes .medio-fila:last-child { border-bottom: 0; padding-bottom: 0; }

/* Ventas: separación entre las tarjetas (el .card base no tiene margen) */
.ventas-pagina .card { margin-bottom: 2rem; }
.ventas-pagina .card .stat-grid:last-child { margin-bottom: 0; }

/* Tarjeta de resumen clickeable (Ventas > Reservados ahora) */
a.stat-tile-link { text-decoration: none; color: inherit; cursor: pointer; }
a.stat-tile-link:hover { border-color: var(--color-primary); text-decoration: none; }
a.stat-tile-link .etiqueta { color: var(--color-primary); }
.stat-tile-sel { border-color: var(--color-primary); box-shadow: 0 0 0 2px var(--color-primary); }

/* Casilla con texto en línea (formulario de rifa: Próximamente) */
label.check-inline { display: flex; align-items: center; gap: 0.5rem; margin-top: 1rem; font-weight: 600; }
label.check-inline input { width: auto; }
.badge-proximamente { background: #fff3cd; color: #7a5b00; }
.badge-pausada { background: #ffe0b2; color: #8a4b00; }
.aviso-inicio-vencido { display: block; margin-top: 0.3rem; font-size: 0.75rem; color: var(--color-error-text); font-weight: 600; }

.aviso-interesados { display: block; margin-top: 0.3rem; font-size: 0.75rem; color: var(--color-text-muted); font-weight: 600; }

/* ---------- Pulido visual: encabezados con acciones, botones compactos y aire entre elementos ---------- */

/* Título + grupo de acciones: nunca quedan pegados y, si no entran, bajan de línea. */
.content-header { flex-wrap: wrap; gap: 0.75rem 1rem; }
.content-header h1 { margin: 0; }
.header-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.header-actions .btn { padding: 0.5rem 1rem; font-size: 0.85rem; white-space: nowrap; }

/* Las tarjetas apiladas respiran entre sí (el .card base no tiene margen). */
.card + .card { margin-top: 1.5rem; }

/* El botón que cierra un formulario no queda pegado al último campo. */
form.stacked > button[type="submit"],
form.stacked > .btn { margin-top: 1.5rem; }

/* Formularios en línea (acciones dentro de una celda): separados entre sí. */
form.inline { display: inline-block; margin: 0 0.35rem 0.35rem 0; }
.table-actions form.inline { margin: 0; }

/* Enlace "← Rifas" de arriba de cada pantalla. */
.content > p:first-child { margin: 0 0 1rem; }

@media (max-width: 720px) {
    .header-actions { width: 100%; }
    .header-actions .btn { flex: 1 1 calc(50% - 0.5rem); text-align: center; }
}

/* Los badges de estado no se parten en varias líneas. */
.badge { white-space: nowrap; }

/* Botones del encabezado con la misma altura (el primario no tiene borde) y "Cerrar" compacto. */
.header-actions .btn:not(.btn-secondary) { border: 1px solid transparent; }
.reporte-head .btn { padding: 0.45rem 1rem; font-size: 0.85rem; }

/* ---------- Botones que quedaban pegados a otros elementos ---------- */

/* Buscador (campo + botón) en una fila con separación; en celular, uno debajo del otro. */
.form-busqueda { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-top: 0.85rem; }
.form-busqueda input { flex: 1 1 240px; max-width: 380px; min-width: 0; width: auto; }
.form-busqueda .btn { flex: 0 0 auto; }
@media (max-width: 480px) {
    .form-busqueda input { flex-basis: 100%; max-width: none; }
    .form-busqueda .btn { flex: 1 1 100%; text-align: center; }
}

/* Botón "Texto de ejemplo" de la rifa: aire contra la nota de arriba y la de abajo. */
#btn-terminos-ejemplo { margin: 0.9rem 0 0.4rem; }
#btn-terminos-ejemplo + .hint { margin-top: 0.5rem; }

/* Fecha + botón dentro de una misma celda (lista de contactados). */
form.inline small { margin-right: 0.6rem; }

/* Pantallas de acceso (login / recuperar contraseña): el botón no pegado al último campo. */
.auth-card .btn { margin-top: 1.1rem; }

/* ---------- Panel: resumen de rifas (activas / próximas a iniciar) ---------- */

.rol-linea { margin: 0 0 1.5rem; }
.panel-seccion { margin-top: 2.25rem; }
.panel-seccion-head { margin-bottom: 1rem; }
.panel-seccion-head h2 { margin: 0 0 0.25rem; }
.panel-seccion-head .hint { margin: 0; }

.rifa-resumen-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
}

.rifa-resumen {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.1rem 1.15rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}
.rifa-resumen-proxima { border-style: dashed; }

.rifa-resumen-link {
    display: flex;
    gap: 0.9rem;
    align-items: center;
    color: inherit;
    text-decoration: none;
}
a.rifa-resumen-link:hover h3 { color: var(--color-primary); }

/* Miniatura: el banner/logo de la rifa, recortado a un rectángulo chico. */
.rifa-mini {
    flex: 0 0 92px;
    width: 92px;
    height: 62px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
}
.rifa-mini-vacia {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-primary);
    background: #eaf6f4;
}

.rifa-resumen-titulo { min-width: 0; }
.rifa-resumen-titulo h3 {
    margin: 0 0 0.3rem;
    font-size: 1rem;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.rifa-resumen-badges { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.rifa-resumen-badges:empty { display: none; }

.rifa-resumen-saldo { display: flex; align-items: baseline; gap: 0.5rem; }
.saldo-valor { font-size: 1.7rem; font-weight: 800; color: var(--color-secondary); letter-spacing: -0.01em; }
.saldo-etiqueta { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; color: var(--color-text-muted); }

.progreso-admin { height: 8px; border-radius: 999px; background: var(--color-bg); overflow: hidden; }
.progreso-admin-fill { height: 100%; background: var(--color-primary); border-radius: 999px; min-width: 2px; }

.rifa-resumen-dato { margin: 0; font-size: 0.82rem; color: var(--color-text-muted); }
.rifa-resumen-inicio { margin: 0; font-size: 0.95rem; }
.rifa-resumen .aviso-inicio-vencido,
.rifa-resumen .aviso-interesados { margin: 0; }

.rifa-resumen-pie {
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 0.75rem;
}
.rifa-resumen-acciones { display: flex; gap: 0.4rem; margin-left: auto; }

/* Cuánto falta (sorteo / inicio): neutro, a punto de llegar (<= 7 días) o vencido. */
.sorteo-fecha { font-size: 0.8rem; font-weight: 600; color: var(--color-text-muted); }
.sorteo-alerta { color: #8a4b00; }
.sorteo-peligro { color: var(--color-error-text); }

@media (max-width: 720px) {
    .rifa-resumen-grid { grid-template-columns: 1fr; }
    .rifa-resumen-acciones { width: 100%; }
    .rifa-resumen-acciones .btn-chip { flex: 1 1 auto; text-align: center; }
}

/* ---------- Panel: lista completa paginada y paginador ---------- */

.panel-lista { margin-top: 1.25rem; }
.panel-lista h3 { margin: 0 0 0.85rem; font-size: 1rem; }
.fila-rifa { display: flex; align-items: center; gap: 0.75rem; min-width: 220px; }
.fila-rifa .badge { margin-left: 0.35rem; }
.rifa-mini-sm { flex: 0 0 56px; width: 56px; height: 38px; border-radius: 7px; font-size: 1rem; }
.panel-lista td.acciones-fila { white-space: nowrap; text-align: right; }
.panel-lista td.acciones-fila .btn-chip + .btn-chip { margin-left: 0.3rem; }
.panel-lista small.sorteo-fecha { white-space: nowrap; }

.paginador {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}
.paginador-estado { font-size: 0.82rem; font-weight: 600; color: var(--color-text-muted); }
.paginador-off { opacity: 0.45; cursor: default; pointer-events: none; }

.panel-lista td.col-fecha { white-space: nowrap; }
.panel-lista td.col-fecha small { display: block; margin-top: 0.1rem; }

/* ---------- Vendedores: podio y ranking ---------- */

.ranking-seccion { margin-top: 2.25rem; }
.ranking-seccion > h2 { margin: 0 0 0.25rem; }
.ranking-seccion > .hint { margin: 0 0 1.25rem; }

.podio {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    align-items: end;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}
.podio-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1rem 1.1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
}
/* Disposición de podio: el 1º al centro y más alto, el 2º a su izquierda y el 3º a su derecha. */
.podio-card.puesto-1 { order: 2; padding-top: 1.75rem; padding-bottom: 1.6rem; border-color: #e5c04a; box-shadow: 0 6px 18px rgba(229, 192, 74, 0.28); }
.podio-card.puesto-2 { order: 1; }
.podio-card.puesto-3 { order: 3; }

.podio-medalla {
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    color: #fff;
}
.puesto-1 .podio-medalla { background: #d4a017; width: 2.9rem; height: 2.9rem; font-size: 1.15rem; }
.puesto-2 .podio-medalla { background: #8d97a5; }
.puesto-3 .podio-medalla { background: #b87333; }

.podio-card h3 { margin: 0.2rem 0 0; font-size: 1rem; line-height: 1.25; overflow-wrap: anywhere; }
.podio-valor { font-size: 1.9rem; font-weight: 800; color: var(--color-secondary); line-height: 1.1; letter-spacing: -0.01em; }
.puesto-1 .podio-valor { font-size: 2.3rem; }
.podio-etiqueta { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; color: var(--color-text-muted); }
.podio-detalle { margin: 0.35rem 0 0; font-size: 0.82rem; color: var(--color-text-muted); }

.ranking-resto { margin-top: 0; }
.ranking-resto h3 { margin: 0 0 0.85rem; font-size: 1rem; }
.ranking-resto td.puesto-num { width: 3rem; font-weight: 700; color: var(--color-text-muted); }
.ranking-nota { margin: 1rem 0 0; font-size: 0.85rem; color: var(--color-text-muted); }

@media (max-width: 720px) {
    .podio { grid-template-columns: 1fr; align-items: stretch; }
    .podio-card.puesto-1, .podio-card.puesto-2, .podio-card.puesto-3 { order: 0; }
    .podio-card.puesto-1 { padding-top: 1.25rem; padding-bottom: 1.1rem; }
}

/* ---------- Listado de rifas: acordeones ---------- */

.rifas-acordeon { display: flex; flex-direction: column; gap: 0.75rem; }
.rifa-item { background: #fff; border: 1px solid var(--color-border); border-radius: 12px; overflow: hidden; }
.rifa-item[open] { border-color: var(--color-primary); }
.rifa-item > summary {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    list-style: none;
}
.rifa-item > summary::-webkit-details-marker { display: none; }
.rifa-item > summary:hover { background: #f6faf9; }
.rifa-item-titulo { flex: 1 1 auto; min-width: 0; }
.rifa-item-titulo strong { display: block; font-size: 1.05rem; color: var(--color-secondary); }
.rifa-item-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin-top: 0.3rem; }
.rifa-item-resumen { flex: 0 0 auto; font-size: 0.85rem; color: var(--color-text-muted); white-space: nowrap; }
.rifa-item-flecha {
    flex: 0 0 auto;
    width: 0.6rem;
    height: 0.6rem;
    border-right: 2px solid var(--color-text-muted);
    border-bottom: 2px solid var(--color-text-muted);
    transform: rotate(45deg);
    transition: transform 0.15s;
    margin: 0 0.4rem 0.25rem 0;
}
.rifa-item[open] .rifa-item-flecha { transform: rotate(-135deg); margin-bottom: 0; }
.rifa-item-cuerpo { padding: 0.25rem 1rem 1rem; border-top: 1px solid var(--color-border); }
.rifa-datos { display: flex; flex-wrap: wrap; gap: 0.75rem 2rem; margin: 0.9rem 0; }
.rifa-datos dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--color-text-muted); }
.rifa-datos dd { margin: 0.1rem 0 0; font-weight: 600; }

@media (max-width: 720px) {
    .rifa-item > summary { flex-wrap: wrap; gap: 0.6rem 0.75rem; }
    .rifa-item-resumen { order: 3; flex-basis: 100%; white-space: normal; }
}

/* ---------- Marca de la barra lateral: el mismo logo que el encabezado público ---------- */

/* Pestaña blanca a sangre desde el borde izquierdo, con el costado derecho en arco suave y filo en
   degradé (colores del logo). Mismo recurso que .site-header-logo-panel de public.css. */
.sidebar-brand {
    align-items: center;
    flex-wrap: nowrap;
    gap: 1.9rem;
    margin-left: -1.5rem;
    padding-bottom: 0;
    margin-bottom: 1.5rem;
    text-decoration: none;
    font-style: normal;
}
.sidebar-brand-panel {
    position: relative;
    display: flex;
    align-items: center;
    padding: 0.7rem 1rem 0.7rem 1.5rem;
    background: #ffffff;
    flex: 0 0 auto;
}
.sidebar-brand-panel::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: calc(100% - 1px);
    width: 19px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 72' preserveAspectRatio='none'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%239ccfcd'/%3E%3Cstop offset='.28' stop-color='%231b9aa8'/%3E%3Cstop offset='.52' stop-color='%232fa77a'/%3E%3Cstop offset='.78' stop-color='%23e3893a'/%3E%3Cstop offset='1' stop-color='%23f0c419'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M0 0Q36 36 0 72Z' fill='url(%23g)'/%3E%3Cpath d='M0 0Q28 36 0 72Z' fill='%23ffffff'/%3E%3C/svg%3E") no-repeat 0 0 / 100% 100%;
}
.sidebar-brand-logo { display: block; height: 36px; width: auto; }
.sidebar-brand .marca-producto { font-size: 1.1rem; }

@media (max-width: 720px) {
    .sidebar-brand { margin-left: -1rem; margin-bottom: 0; }
}

/* ---------- Ventas: totales en dos bloques (Dinero / Números) ---------- */

.stat-grupos { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 1.5rem; margin-bottom: 1.5rem; align-items: start; }
.stat-grupo .stat-grid { margin-bottom: 0; }
.stat-grupo-titulo { margin: 0 0 0.6rem; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); }
@media (max-width: 960px) {
    .stat-grupos { grid-template-columns: 1fr; gap: 0.5rem; }
    .stat-grupo { margin-bottom: 1rem; }
}

/* ---------- Estados de compra: mismo color e ícono en todo el panel ---------- */

.badge-e-aprobado, .badge-e-pendiente, .badge-e-rechazado, .badge-e-expirado, .badge-e-revision { font-weight: 700; }
.badge-e-aprobado::before, .badge-e-pendiente::before, .badge-e-rechazado::before, .badge-e-expirado::before, .badge-e-revision::before { margin-right: 0.3rem; font-weight: 800; }
.badge-e-aprobado  { background: var(--color-success-bg); color: var(--color-success-text); }
.badge-e-aprobado::before  { content: '\2713'; }
.badge-e-pendiente { background: #fff3cd; color: #7a5b00; }
.badge-e-pendiente::before { content: '\2026'; }
.badge-e-rechazado { background: var(--color-error-bg); color: var(--color-error-text); }
.badge-e-rechazado::before { content: '\2715'; }
.badge-e-expirado  { background: #eef0f3; color: #555b66; }
.badge-e-expirado::before  { content: '\2013'; }
.badge-e-revision  { background: #ffe0b2; color: #8a4b00; }
.badge-e-revision::before  { content: '!'; }

/* ---------- Listados largos: filas compactas y cabecera fija al scrollear ---------- */

.tabla-scroll { max-height: 70vh; overflow: auto; }
.tabla-scroll th, .tabla-scroll td { padding: 0.45rem 0.65rem; font-size: 0.84rem; }
.tabla-scroll thead th { position: sticky; top: 0; z-index: 1; background: var(--color-surface); box-shadow: 0 1px 0 var(--color-border); }
.tabla-scroll tbody tr:hover td { background: #f6faf9; }

/* Botón "Ir al sitio" en la barra lateral */
.sidebar-footer a.sidebar-sitio {
    display: block;
    margin: 0 0 0.9rem;
    padding: 0.5rem 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 999px;
    color: #fff;
    text-align: center;
    font-weight: 600;
    text-decoration: none;
}
.sidebar-footer a.sidebar-sitio:hover { background: rgba(255, 255, 255, 0.15); }

/* Leyenda desplegable de los botones de las compras (Ventas) */
.leyenda-botones { margin-bottom: 1rem; }
.leyenda-botones > summary { cursor: pointer; }
.leyenda-botones dl { margin: 0.9rem 0 0; }
.leyenda-botones dt { margin-top: 0.7rem; font-weight: 700; color: var(--color-secondary); }
.leyenda-botones dd { margin: 0.15rem 0 0; font-size: 0.88rem; line-height: 1.5; color: #3b4452; }
