/* =====================================================================
   TM SOLUCIONES — Panel de Suscripciones
   Sistema de diseno: tinta profunda + dorado, sobre papel calido.
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
    /* Superficies oscuras (sidebar, topbar de soporte) */
    --ink-950: #0E1120;
    --ink-900: #171B34;
    --ink-800: #232A54;
    --ink-700: #2E3568;
    --ink-line: rgba(255, 255, 255, 0.09);

    /* Superficies claras (contenido) */
    --paper: #F5F4EF;
    --surface: #FFFFFF;
    --surface-hover: #FAF9F5;
    --line: #E6E2D8;
    --line-strong: #D8D3C4;

    /* Texto */
    --texto: #1C1E2E;
    --texto-suave: #5B5E70;
    --texto-tenue: #90929E;
    --texto-sobre-ink: #ECEBF5;
    --texto-sobre-ink-suave: #A7ABCB;

    /* Marca */
    --dorado: #C6963C;
    --dorado-oscuro: #9C7429;
    --dorado-claro: #F0DFB8;

    /* Semanticos */
    --verde: #1F8A5F;
    --verde-bg: #E4F3EB;
    --ambar: #B9760E;
    --ambar-bg: #FBEFD9;
    --rojo: #C4433A;
    --rojo-bg: #FAE7E4;
    --azul: #3D6FA6;
    --azul-bg: #E4EDF6;
    --morado: #6B5B95;
    --morado-bg: #ECE8F3;
    --gris: #6B6E7D;
    --gris-bg: #EBEAE5;

    --radio-s: 6px;
    --radio-m: 10px;
    --radio-l: 16px;
    --sombra-flotante: 0 12px 28px rgba(14, 17, 32, 0.16);

    --fuente-marca: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
    --fuente-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--fuente-base);
    background: var(--paper);
    color: var(--texto);
    font-size: 15px;
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-family: var(--fuente-marca); font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
button { font-family: inherit; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------------------------------------------------------------------
   Estructura general
   --------------------------------------------------------------------- */
.app-shell {
    display: grid;
    grid-template-columns: 264px 1fr;
    grid-template-areas: "sidebar contenido";
    direction: ltr;
    min-height: 100vh;
}

.sidebar {
    grid-area: sidebar;
    order: 1;
    background: linear-gradient(175deg, var(--ink-900) 0%, var(--ink-950) 100%);
    color: var(--texto-sobre-ink);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    direction: ltr;
}

.marca {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 22px;
}

.marca-icono {
    width: 34px;
    height: 34px;
    border-radius: var(--radio-s);
    background: linear-gradient(155deg, var(--dorado) 0%, var(--dorado-oscuro) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-950);
    font-family: var(--fuente-marca);
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}

.marca-texto {
    font-family: var(--fuente-marca);
    font-weight: 600;
    font-size: 15.5px;
    color: #fff;
    line-height: 1.15;
}

.marca-texto small {
    display: block;
    font-family: var(--fuente-base);
    font-weight: 400;
    font-size: 11.5px;
    color: var(--texto-sobre-ink-suave);
    margin-top: 1px;
}

.nav-seccion-titulo {
    font-size: 11px;
    color: var(--texto-sobre-ink-suave);
    padding: 14px 12px 6px;
    font-weight: 500;
}

.nav-lista { display: flex; flex-direction: column; gap: 1px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: var(--radio-s);
    color: var(--texto-sobre-ink-suave);
    font-size: 14px;
    font-weight: 500;
    border-left: 2px solid transparent;
    transition: background-color 0.14s, color 0.14s;
}

.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.nav-link.activo {
    background: rgba(198, 150, 60, 0.14);
    color: #fff;
    border-left-color: var(--dorado);
}

.nav-spacer { flex: 1; }

.sidebar-usuario {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-top: 1px solid var(--ink-line);
    margin-top: 10px;
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--ink-700);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--fuente-marca);
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

.sidebar-usuario-info { flex: 1; min-width: 0; }
.sidebar-usuario-nombre { font-size: 13.5px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-usuario-rol { font-size: 11.5px; color: var(--texto-sobre-ink-suave); }

.boton-salir {
    color: var(--texto-sobre-ink-suave);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radio-s);
    flex-shrink: 0;
}
.boton-salir:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.boton-salir svg { width: 17px; height: 17px; }

/* ---------------------------------------------------------------------
   Contenido principal
   --------------------------------------------------------------------- */
.contenido { grid-area: contenido; order: 2; display: flex; flex-direction: column; min-height: 100vh; direction: ltr; }

.banner-soporte {
    background: linear-gradient(90deg, #7A5A16 0%, var(--dorado-oscuro) 100%);
    color: #fff;
    padding: 10px 28px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13.5px;
    font-weight: 500;
}
.banner-soporte svg { width: 16px; height: 16px; flex-shrink: 0; }
.banner-soporte strong { font-weight: 700; }
.banner-soporte .spacer { flex: 1; }
.banner-soporte a {
    background: rgba(255, 255, 255, 0.18);
    padding: 5px 12px;
    border-radius: var(--radio-s);
    font-weight: 600;
    white-space: nowrap;
}
.banner-soporte a:hover { background: rgba(255, 255, 255, 0.28); }

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 18px 28px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.boton-menu-movil {
    display: none;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radio-s);
    border: 1px solid var(--line);
    color: var(--texto-suave);
    flex-shrink: 0;
}
.boton-menu-movil svg { width: 18px; height: 18px; }

.topbar-titulo h1 { font-size: 19px; color: var(--texto); }
.topbar-titulo p { font-size: 13px; color: var(--texto-suave); margin-top: 2px; }

.main { flex: 1; padding: 26px 28px 48px; }

/* ---------------------------------------------------------------------
   Mensajes flash
   --------------------------------------------------------------------- */
.flash {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radio-m);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 20px;
}
.flash svg { width: 17px; height: 17px; flex-shrink: 0; }
.flash-exito { background: var(--verde-bg); color: #1D6B49; }
.flash-error { background: var(--rojo-bg); color: #A6362E; }
.flash-info { background: var(--azul-bg); color: #2E5680; }

/* ---------------------------------------------------------------------
   Botones
   --------------------------------------------------------------------- */
.boton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: var(--radio-s);
    font-size: 13.5px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.14s, border-color 0.14s, color 0.14s;
}
.boton svg { width: 16px; height: 16px; }

.boton-primario { background: var(--ink-950); color: #fff; }
.boton-primario:hover { background: var(--ink-800); }

.boton-dorado { background: var(--dorado); color: #2B2008; }
.boton-dorado:hover { background: var(--dorado-oscuro); color: #fff; }

.boton-secundario { background: var(--surface); color: var(--texto); border-color: var(--line-strong); }
.boton-secundario:hover { background: var(--surface-hover); border-color: var(--texto-tenue); }

.boton-peligro { background: var(--surface); color: var(--rojo); border-color: var(--rojo-bg); }
.boton-peligro:hover { background: var(--rojo-bg); }

.boton-texto { background: none; color: var(--texto-suave); padding: 6px 8px; }
.boton-texto:hover { color: var(--texto); }

.boton-s { padding: 6px 11px; font-size: 12.5px; }
.boton-icono { padding: 7px; }
.boton:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------------------------------------------------------------------
   Paneles / tarjetas
   --------------------------------------------------------------------- */
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radio-l);
    padding: 22px;
}

.panel-cabecera {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}
.panel-cabecera h2 { font-size: 15.5px; }
.panel-cabecera p { font-size: 12.5px; color: var(--texto-suave); margin-top: 3px; }

.rejilla-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radio-l);
    padding: 18px;
}
.stat-card-cabecera { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.stat-icono {
    width: 36px; height: 36px; border-radius: var(--radio-s);
    display: flex; align-items: center; justify-content: center;
}
.stat-icono svg { width: 18px; height: 18px; }
.stat-icono-azul   { background: var(--azul-bg); color: var(--azul); }
.stat-icono-verde  { background: var(--verde-bg); color: var(--verde); }
.stat-icono-ambar  { background: var(--ambar-bg); color: var(--ambar); }
.stat-icono-rojo   { background: var(--rojo-bg); color: var(--rojo); }
.stat-icono-morado { background: var(--morado-bg); color: var(--morado); }
.stat-icono-dorado { background: var(--dorado-claro); color: var(--dorado-oscuro); }

.stat-delta { font-size: 11.5px; font-weight: 600; padding: 3px 7px; border-radius: 20px; }
.stat-delta-positivo { background: var(--verde-bg); color: #1D6B49; }
.stat-delta-negativo { background: var(--rojo-bg); color: #A6362E; }
.stat-delta-neutro { background: var(--gris-bg); color: var(--texto-suave); }

.stat-valor { font-family: var(--fuente-marca); font-size: 27px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12.5px; color: var(--texto-suave); margin-top: 7px; }

/* ---------------------------------------------------------------------
   Badges
   --------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.badge-verde  { background: var(--verde-bg); color: #1D6B49; }
.badge-ambar  { background: var(--ambar-bg); color: #8C5B0A; }
.badge-rojo   { background: var(--rojo-bg); color: #A6362E; }
.badge-azul   { background: var(--azul-bg); color: #2E5680; }
.badge-morado { background: var(--morado-bg); color: #52456F; }
.badge-gris   { background: var(--gris-bg); color: var(--texto-suave); }
.badge-dorado { background: var(--dorado-claro); color: var(--dorado-oscuro); }

/* Colores de categoria: rotacion fija de 8 tonos propios (no imitan
   marcas reales) para diferenciar Streaming/Video/Musica/etc a golpe
   de vista en el catalogo. */
.tag-cat { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.tag-cat svg { width: 13px; height: 13px; }
.tag-cat-1 { background: var(--rojo-bg); color: #A6362E; }
.tag-cat-2 { background: var(--azul-bg); color: #2E5680; }
.tag-cat-3 { background: var(--morado-bg); color: #52456F; }
.tag-cat-4 { background: var(--verde-bg); color: #1D6B49; }
.tag-cat-5 { background: var(--dorado-claro); color: var(--dorado-oscuro); }
.tag-cat-6 { background: var(--ambar-bg); color: #8C5B0A; }
.tag-cat-7 { background: #DCEAE8; color: #276E64; }
.tag-cat-8 { background: var(--gris-bg); color: var(--texto-suave); }

/* ---------------------------------------------------------------------
   Formularios
   --------------------------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.campo { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.campo-ancho { grid-column: 1 / -1; }
.campo label { font-size: 13px; font-weight: 600; color: var(--texto); }
.campo .ayuda { font-size: 12px; color: var(--texto-tenue); }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=tel], input[type=search], select, textarea {
    font-family: inherit;
    font-size: 14px;
    padding: 9px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radio-s);
    background: var(--surface);
    color: var(--texto);
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--dorado-oscuro);
    box-shadow: 0 0 0 3px rgba(198, 150, 60, 0.18);
}
textarea { resize: vertical; min-height: 70px; }

.check-linea { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--texto); }
.check-linea input { width: auto; }

fieldset { border: 1px solid var(--line); border-radius: var(--radio-m); padding: 14px 16px; margin: 0 0 16px; }
legend { font-size: 12.5px; font-weight: 600; color: var(--texto-suave); padding: 0 6px; }

.form-acciones { display: flex; gap: 10px; margin-top: 6px; }

/* ---------------------------------------------------------------------
   Tablas
   --------------------------------------------------------------------- */
.tabla-envoltorio { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radio-l); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
    text-align: left;
    padding: 11px 16px;
    background: var(--surface-hover);
    color: var(--texto-suave);
    font-weight: 600;
    font-size: 12px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-hover); }
.celda-num { text-align: right; font-variant-numeric: tabular-nums; }
.celda-acciones { display: flex; gap: 6px; justify-content: flex-end; }
.texto-suave { color: var(--texto-suave); }
.texto-tenue { color: var(--texto-tenue); font-size: 12.5px; }

.fila-vacia { text-align: center; padding: 48px 20px; color: var(--texto-tenue); }
.fila-vacia svg { width: 34px; height: 34px; margin-bottom: 10px; opacity: 0.5; }

/* ---------------------------------------------------------------------
   Filtros / barra de herramientas
   --------------------------------------------------------------------- */
.barra-herramientas {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.campo-buscar { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
.campo-buscar svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--texto-tenue); }
.campo-buscar input { padding-left: 34px; }
.barra-herramientas select { width: auto; min-width: 130px; }
.barra-herramientas .spacer { flex: 1; }

/* ---------------------------------------------------------------------
   Pestanas
   --------------------------------------------------------------------- */
.pestanas { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.pestana {
    padding: 10px 4px;
    margin-right: 22px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--texto-suave);
    border-bottom: 2px solid transparent;
    display: flex; align-items: center; gap: 7px;
}
.pestana.activa { color: var(--texto); border-bottom-color: var(--dorado-oscuro); }
.pestana .contador { background: var(--gris-bg); color: var(--texto-suave); font-size: 11px; padding: 1px 7px; border-radius: 20px; }
.pestana.activa .contador { background: var(--dorado-claro); color: var(--dorado-oscuro); }

/* ---------------------------------------------------------------------
   Tarjetas de catalogo (planes/combos para vender)
   --------------------------------------------------------------------- */
.rejilla-catalogo { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.tarjeta-catalogo { border: 1px solid var(--line); border-radius: var(--radio-l); padding: 18px; background: var(--surface); display: flex; flex-direction: column; gap: 10px; }
.tarjeta-catalogo-titulo { font-family: var(--fuente-marca); font-size: 16px; font-weight: 600; }
.tarjeta-catalogo-precio { font-family: var(--fuente-marca); font-size: 22px; font-weight: 700; }
.tarjeta-catalogo-precio span { font-family: var(--fuente-base); font-size: 12.5px; font-weight: 500; color: var(--texto-suave); }
.tarjeta-catalogo-meta { font-size: 12.5px; color: var(--texto-suave); display: flex; flex-direction: column; gap: 3px; }
.tarjeta-combo { border-color: var(--dorado-claro); background: linear-gradient(180deg, #FFFDF8 0%, var(--surface) 60%); }

/* ---------------------------------------------------------------------
   Clave oculta (cuentas.php)
   --------------------------------------------------------------------- */
.clave-oculta { display: inline-flex; align-items: center; gap: 6px; font-family: ui-monospace, monospace; font-size: 12.5px; cursor: pointer; color: var(--texto-suave); }
.clave-oculta svg { width: 14px; height: 14px; flex-shrink: 0; }
.clave-oculta:hover { color: var(--texto); }
.valor-clave { color: var(--dorado-oscuro); font-weight: 600; }

/* ---------------------------------------------------------------------
   Login
   --------------------------------------------------------------------- */
.pagina-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--ink-950) 0%, var(--ink-900) 55%, #1A2050 100%);
    padding: 20px;
}
.tarjeta-login {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border-radius: var(--radio-l);
    padding: 34px 30px;
    box-shadow: var(--sombra-flotante);
}
.tarjeta-login .marca { padding: 0 0 26px; justify-content: center; }
.tarjeta-login .marca-texto { color: var(--texto); }
.tarjeta-login .marca-texto small { color: var(--texto-suave); }
.tarjeta-login h1 { font-size: 17px; text-align: center; margin-bottom: 4px; }
.tarjeta-login .subtitulo { font-size: 13px; color: var(--texto-suave); text-align: center; margin-bottom: 24px; }
.pista-demo { background: var(--surface-hover); border: 1px solid var(--line); border-radius: var(--radio-m); padding: 12px 14px; font-size: 12px; color: var(--texto-suave); margin-top: 18px; line-height: 1.6; }
.pista-demo code { background: var(--gris-bg); padding: 1px 5px; border-radius: 4px; }

/* ---------------------------------------------------------------------
   Errores (403 / 404)
   --------------------------------------------------------------------- */
.pagina-error { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--paper); padding: 20px; }
.tarjeta-error { max-width: 420px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radio-l); padding: 40px 32px; }
.icono-error { width: 52px; height: 52px; border-radius: 50%; background: var(--ambar-bg); color: var(--ambar); display: flex; align-items: center; justify-content: center; margin: 0 auto 18px; }
.icono-error svg { width: 24px; height: 24px; }
.tarjeta-error h1 { font-size: 19px; margin-bottom: 10px; }
.tarjeta-error p { color: var(--texto-suave); font-size: 14px; margin-bottom: 22px; line-height: 1.6; }

/* ---------------------------------------------------------------------
   Paginacion
   --------------------------------------------------------------------- */
.paginacion { display: flex; gap: 6px; justify-content: center; margin-top: 20px; }
.paginacion a, .paginacion span {
    min-width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    border-radius: var(--radio-s); font-size: 13px; font-weight: 600; color: var(--texto-suave);
    border: 1px solid var(--line);
}
.paginacion a:hover { background: var(--surface-hover); }
.paginacion .actual { background: var(--ink-950); color: #fff; border-color: var(--ink-950); }

/* ---------------------------------------------------------------------
   Utilidades
   --------------------------------------------------------------------- */
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.items-center { align-items: center; }
.w-100 { width: 100%; }

/* ---------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------- */
@media (max-width: 1180px) {
    .form-grid, .form-grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        z-index: 40;
        left: 0; top: 0; bottom: 0;
        width: 264px;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: var(--sombra-flotante);
    }
    .sidebar.abierto { transform: translateX(0); }
    .overlay-movil { display: none; position: fixed; inset: 0; background: rgba(14,17,32,0.45); z-index: 35; }
    .overlay-movil.visible { display: block; }
    .boton-menu-movil { display: flex; }
    .topbar { padding: 14px 16px; }
    .main { padding: 18px 16px 40px; }
    .rejilla-stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
}

@media (max-width: 620px) {
    .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
    .panel { padding: 16px; }
    .stat-valor { font-size: 22px; }
    .topbar-titulo h1 { font-size: 17px; }
    .banner-soporte { flex-wrap: wrap; padding: 10px 16px; }
}
