@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&family=Syne:wght@700;800&display=swap');

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
    --azul:         #0F1F3D;
    --azul-mid:     #1B2F55;
    --naranja:      #E8743A;
    --naranja-soft: #FFF0E8;
    --verde:        #0DAB76;
    --verde-soft:   #E6FAF4;
    --rojo:         #E53935;
    --rojo-soft:    #FEECEC;
    --amarillo:     #F5A623;
    --amarillo-soft:#FFF8EC;
    --gris-50:      #F9F9F7;
    --gris-100:     #F2F2EF;
    --gris-200:     #E8E8E4;
    --gris-300:     #D0D0CA;
    --gris-500:     #9B9B93;
    --gris-700:     #5A5A52;
    --gris-900:     #1A1A16;
    --texto:        #1A1A16;
    --texto-suave:  #6B6B62;
    --sidebar-w:    256px;
    --bottomnav-h:  64px;
    --radius-sm:    8px;
    --radius-md:    12px;
    --radius-lg:    16px;
    --radius-xl:    24px;
    --shadow-sm:    0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:    0 4px 16px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg:    0 12px 40px rgba(0,0,0,0.12);
    --transition:   0.2s cubic-bezier(0.4,0,0.2,1);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: var(--gris-50);
    color: var(--texto);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar (desktop) ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--azul);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition);
    overflow-y: auto;
}

.sidebar-logo {
    padding: 1.5rem 1.25rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.07);
}
.sidebar-logo .logo-txt {
    font-family: 'Syne', sans-serif;
    font-size: 26px;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.02em;
    line-height: 1;
}
.sidebar-logo .logo-txt span { color: var(--naranja); }
.sidebar-logo .logo-sub {
    font-size: 10px;
    color: rgba(255,255,255,0.35);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin-top: 4px;
}

.sidebar-nav { flex: 1; padding: .75rem 0; }
.nav-seccion {
    font-size: 9px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.25);
    padding: 1rem 1.25rem .4rem;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 1.25rem;
    font-size: 13.5px;
    font-weight: 500;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    transition: all var(--transition);
    border-left: 3px solid transparent;
    border-radius: 0;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active {
    background: rgba(232,116,58,0.15);
    color: var(--naranja);
    border-left-color: var(--naranja);
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.07);
}
.sidebar-user { font-size: 12px; color: rgba(255,255,255,0.45); margin-bottom: 8px; }
.sidebar-user strong { color: rgba(255,255,255,0.85); display: block; font-size: 13px; }
.btn-logout {
    display: block; text-align: center;
    background: rgba(255,255,255,0.07);
    color: rgba(255,255,255,0.55);
    text-decoration: none;
    padding: 7px; border-radius: var(--radius-sm);
    font-size: 12px; transition: background var(--transition);
}
.btn-logout:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* ── Main area ── */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ── Topbar ── */
.topbar {
    background: #fff;
    border-bottom: 1px solid var(--gris-200);
    padding: 0 1.5rem;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky; top: 0; z-index: 50;
    gap: 1rem;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-titulo { font-size: 15px; font-weight: 600; color: var(--texto); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-acciones { display: flex; gap: 6px; flex-shrink: 0; }

.contenido { padding: 1.5rem; flex: 1; }

/* ============================================================
   HAMBURGER & OVERLAY (mobile)
   ============================================================ */
.hamburger {
    display: none;
    flex-direction: column;
    gap: 4.5px;
    cursor: pointer;
    padding: 10px;
    margin: -4px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
    -webkit-touch-callout: none;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}
.hamburger span {
    display: block;
    width: 20px; height: 2px;
    background: var(--texto);
    border-radius: 2px;
    transition: all var(--transition);
}
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 90;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.visible { display: block; }

/* ============================================================
   BOTTOM NAV (mobile only)
   ============================================================ */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bottomnav-h);
    background: #fff;
    border-top: 1px solid var(--gris-200);
    z-index: 80;
    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-inner {
    display: flex;
    height: 100%;
    align-items: stretch;
}
.bnav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--gris-500);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.02em;
    border-radius: var(--radius-sm);
    transition: color var(--transition);
    padding: 6px 4px;
    position: relative;
}
.bnav-item svg { width: 22px; height: 22px; }
.bnav-item.active { color: var(--naranja); }
.bnav-item.active svg { stroke: var(--naranja); }
.bnav-dot {
    position: absolute;
    top: 6px; right: calc(50% - 14px);
    width: 7px; height: 7px;
    background: var(--rojo);
    border-radius: 50%;
    border: 1.5px solid #fff;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: #fff;
    border-radius: var(--radius-lg);
    border: 1px solid var(--gris-200);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card-header {
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--gris-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.card-titulo { font-size: 14px; font-weight: 600; color: var(--texto); }
.card-body { padding: 1.25rem; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px,1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.stat-card {
    background: #fff;
    border: 1px solid var(--gris-200);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.25rem;
    box-shadow: var(--shadow-sm);
}
.stat-label {
    font-size: 10px; font-weight: 600;
    color: var(--gris-500);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 6px;
}
.stat-valor {
    font-family: 'Syne', sans-serif;
    font-size: 34px;
    font-weight: 700;
    color: var(--azul);
    line-height: 1;
}
.stat-valor.naranja { color: var(--naranja); }
.stat-valor.verde   { color: var(--verde); }
.stat-nota { font-size: 11px; color: var(--gris-500); margin-top: 4px; }

/* ============================================================
   INSCRITO CARDS (mobile view)
   ============================================================ */
.inscrito-lista { display: flex; flex-direction: column; gap: .75rem; }

.inscrito-card {
    background: #fff;
    border: 1px solid var(--gris-200);
    border-radius: var(--radius-lg);
    padding: 1rem;
    display: flex;
    align-items: flex-start;
    gap: .875rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
    text-decoration: none;
    color: inherit;
}
.inscrito-card:active { box-shadow: var(--shadow-md); }

.avatar {
    width: 44px; height: 44px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Syne', sans-serif;
    font-size: 16px; font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    background: var(--azul-mid);
}

.inscrito-info { flex: 1; min-width: 0; }
.inscrito-nombre { font-size: 14px; font-weight: 600; color: var(--texto); margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inscrito-sub { font-size: 11px; color: var(--texto-suave); }

.inscrito-acciones {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.badge-pagado    { background: var(--verde-soft);   color: #065F46; }
.badge-pendiente { background: var(--amarillo-soft); color: #92400E; }
.badge-parcial   { background: #FFF0E8;              color: #9A3412; }
.badge-cancelado { background: var(--rojo-soft);    color: #991B1B; }
.badge-superadmin{ background: #EFF6FF;              color: #1D4ED8; }
.badge-colaborador{ background: #F5F3FF;             color: #6D28D9; }

/* ============================================================
   TABLAS
   ============================================================ */
.tabla-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
    padding: 9px 12px;
    text-align: left;
    font-size: 10px; font-weight: 600;
    color: var(--gris-500);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-bottom: 1px solid var(--gris-200);
    background: var(--gris-50);
    white-space: nowrap;
}
tbody td { padding: 11px 12px; border-bottom: 1px solid var(--gris-100); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--gris-50); }

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-size: 13px; font-weight: 600;
    font-family: 'Plus Jakarta Sans', sans-serif;
    cursor: pointer; text-decoration: none;
    border: none; transition: all var(--transition);
    white-space: nowrap;
    min-height: 36px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.btn-primary   { background: var(--naranja); color: #fff; }
.btn-primary:hover { background: #D4632A; }
.btn-secondary { background: var(--gris-100); color: var(--texto); border: 1px solid var(--gris-200); }
.btn-secondary:hover { background: var(--gris-200); }
.btn-azul      { background: var(--azul); color: #fff; }
.btn-azul:hover{ background: var(--azul-mid); }
.btn-verde     { background: var(--verde-soft); color: #065F46; border: 1px solid #A7F3D0; }
.btn-verde:hover{ background: #D1FAE5; }
.btn-danger    { background: var(--rojo-soft); color: var(--rojo); border: 1px solid #FECACA; }
.btn-danger:hover{ background: #FEE2E2; }
.btn-sm { padding: 5px 9px; font-size: 11px; border-radius: var(--radius-sm); min-height: 28px; }
.btn-lg { padding: 13px 20px; font-size: 15px; border-radius: var(--radius-lg); min-height: 48px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Botón de acción circular (móvil) */
.btn-icon {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 16px;
    border: none; cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    flex-shrink: 0;
}
.btn-icon:hover { transform: scale(1.08); }

/* ============================================================
   FORMULARIOS
   ============================================================ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.campo { display: flex; flex-direction: column; gap: 5px; }
.campo.span2 { grid-column: span 2; }
label.campo-label {
    font-size: 11px; font-weight: 600;
    color: var(--gris-700);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
input[type=text], input[type=email], input[type=password],
input[type=date], input[type=time], input[type=number],
input[type=tel], input[type=url], select, textarea {
    border: 1.5px solid var(--gris-200);
    border-radius: var(--radius-md);
    padding: 10px 13px;
    font-size: 14px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    color: var(--texto);
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
    width: 100%;
    min-height: 42px;
    appearance: none; -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--naranja);
    box-shadow: 0 0 0 3px rgba(232,116,58,0.12);
}
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239B9B93' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}
textarea { resize: vertical; min-height: 80px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 1.25rem; }
.seccion {
    font-size: 10px; font-weight: 600;
    letter-spacing: 0.15em; text-transform: uppercase;
    color: var(--gris-500);
    margin: 1.5rem 0 .75rem;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--gris-200);
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert { padding: 11px 14px; border-radius: var(--radius-md); font-size: 13px; margin-bottom: 1rem; }
.alert-success { background: var(--verde-soft); color: #065F46; border: 1px solid #A7F3D0; }
.alert-error   { background: var(--rojo-soft); color: #991B1B; border: 1px solid #FECACA; }

/* ============================================================
   PAGINACION
   ============================================================ */
.paginacion { display: flex; gap: 4px; flex-wrap: wrap; }
.paginacion a {
    padding: 6px 11px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 500;
    text-decoration: none; color: var(--gris-700);
    border: 1px solid var(--gris-200);
    transition: all var(--transition);
}
.paginacion a.active,
.paginacion a:hover { background: var(--azul); color: #fff; border-color: var(--azul); }

/* ============================================================
   VACIO
   ============================================================ */
.vacio {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--gris-500);
    font-size: 14px;
}
.vacio svg { width: 44px; height: 44px; margin-bottom: 1rem; opacity: 0.25; display: block; margin-left: auto; margin-right: auto; }

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress-bar { background: var(--gris-100); border-radius: 20px; height: 6px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 20px; transition: width .4s; }

/* ============================================================
   BOTTOM SHEET (mobile action drawer)
   ============================================================ */
.sheet-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 150;
    backdrop-filter: blur(2px);
}
.sheet-overlay.open { display: block; }
.sheet {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    z-index: 151;
    padding: 0 0 env(safe-area-inset-bottom);
    transform: translateY(100%);
    transition: transform var(--transition);
    max-height: 90vh;
    overflow-y: auto;
}
.sheet.open { transform: translateY(0); }
.sheet-handle {
    width: 36px; height: 4px;
    background: var(--gris-200);
    border-radius: 2px;
    margin: 12px auto 16px;
}
.sheet-titulo {
    font-size: 15px; font-weight: 700;
    padding: 0 1.25rem 1rem;
    border-bottom: 1px solid var(--gris-100);
}
.sheet-body { padding: 1.25rem; }
.sheet-accion {
    display: flex; align-items: center; gap: 14px;
    padding: 13px 1.25rem;
    border: none; background: none;
    width: 100%; text-align: left;
    cursor: pointer; font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 15px; font-weight: 500; color: var(--texto);
    border-bottom: 1px solid var(--gris-100);
    text-decoration: none;
    transition: background var(--transition);
}
.sheet-accion:last-child { border-bottom: none; }
.sheet-accion:active { background: var(--gris-50); }
.sheet-accion-icon {
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; flex-shrink: 0;
}

/* ============================================================
   FAB (Floating Action Button)
   ============================================================ */
.fab {
    display: none;
    position: fixed;
    bottom: calc(var(--bottomnav-h) + 16px);
    right: 1rem;
    width: 52px; height: 52px;
    border-radius: 50%;
    background: var(--naranja);
    color: #fff;
    border: none; cursor: pointer;
    box-shadow: 0 4px 16px rgba(232,116,58,0.45);
    font-size: 24px;
    align-items: center; justify-content: center;
    z-index: 70;
    transition: transform var(--transition), box-shadow var(--transition);
}
.fab:active { transform: scale(0.94); box-shadow: 0 2px 8px rgba(232,116,58,0.3); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    /* Sidebar → oculto, deslizable */
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: translateX(0); }

    /* Main ocupa todo */
    .main { margin-left: 0; padding-bottom: var(--bottomnav-h); }

    /* Topbar */
    .topbar { padding: 0 1rem; height: 54px; }
    .topbar-titulo { font-size: 14px; }
    .hamburger { display: flex; }

    /* Bottom nav */
    .bottom-nav { display: block; }

    /* FAB */
    .fab { display: flex; }

    /* Contenido */
    .contenido { padding: 1rem; }

    /* Stats — 2 columnas */
    .stats-grid {
        grid-template-columns: repeat(2,1fr) !important;
        gap: .75rem;
    }
    .stat-valor { font-size: 28px !important; }
    .stat-card { padding: .875rem 1rem; }

    /* Cards */
    .card-header { padding: .875rem 1rem; flex-wrap: wrap; }
    .card-body   { padding: 1rem; }

    /* Tablas — scroll */
    table { min-width: 540px; font-size: 12px; }
    thead th { padding: 7px 10px; }
    tbody td  { padding: 9px 10px; }

    /* Formularios — una columna */
    .form-grid { grid-template-columns: 1fr !important; }
    .campo.span2 { grid-column: 1 !important; }
    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; justify-content: center; }

    /* Grids dobles → una columna */
    div[style*="grid-template-columns:1fr 1fr"],
    div[style*="grid-template-columns:1fr 340px"],
    div[style*="grid-template-columns:1fr 360px"],
    div[style*="grid-template-columns:repeat(4"],
    div[style*="grid-template-columns:repeat(5"],
    div[style*="grid-template-columns:repeat(6"] {
        grid-template-columns: 1fr !important;
    }

    /* Acciones topbar más pequeñas */
    .topbar-acciones .btn { font-size: 11px; padding: 5px 8px; min-height: 30px; }

    /* Botones SM más touchable */
    .btn-sm { min-height: 32px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr !important; gap: .5rem; }
    .stat-valor { font-size: 24px !important; }
    .contenido { padding: .75rem; }
    .card-header { padding: .75rem; }
    .card-body   { padding: .75rem; }
}

/* PWA safe areas */
@supports (padding: env(safe-area-inset-bottom)) {
    .bottom-nav { padding-bottom: env(safe-area-inset-bottom); height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); }
    .main { padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); }
    .fab { bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + 16px); }
}
