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

/* ============================================================
   Yolber Center — Agente de Pagos
   "Clean Light Luxury" — mismos tokens que ventas.greycell.es
   (ver docs/spec.md §9). Marfil + negro + dorado sutil.
   ============================================================ */

:root {
    --bg:          #faf9f6;
    --surface:     #ffffff;
    --card:        #ffffff;
    --card-border: #f0efea;
    --hairline:    #eceae3;
    --input-bg:    #ffffff;
    --input-border:#e6e3da;
    --hover:       #f7f5f0;

    --text:   #1a1a1a;
    --text-2: #6b7280;
    --muted:  #9ca3af;

    --gold:      #b8860b;
    --gold-2:    #c9a23a;
    --gold-soft: rgba(201, 162, 58, 0.12);
    --gold-line: rgba(184, 134, 11, 0.35);

    --ink:    #111111;
    --ink-2:  #262626;

    --ok:      #16a34a;
    --ok-soft: rgba(22, 163, 74, 0.10);
    --danger:      #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.09);
    --warn:      #d97706;
    --warn-soft: rgba(217, 119, 6, 0.10);
    --info:      #2563eb;
    --info-soft: rgba(37, 99, 235, 0.10);

    --radius:    20px;
    --radius-lg: 24px;
    --radius-sm: 14px;
    --radius-xs: 10px;

    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.06);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-pop: 0 18px 50px rgba(0, 0, 0, 0.12);

    --sidebar-w: 240px;
    --topbar-h: 60px;

    --font: 'Space Grotesk', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    background: var(--bg); color: var(--text);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
    font-size: 16px; line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0 0 .35em; font-weight: 600; letter-spacing: -0.02em; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; margin-top: 1em; }
p { margin: 0 0 .6em; }
.muted { color: var(--muted); }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 20px; } .mt-1 { margin-top: 8px; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-screen {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 20px; background: var(--bg);
}
.login-card {
    width: 100%; max-width: 380px; background: var(--surface);
    border: 1px solid var(--card-border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-pop); padding: 36px 28px;
}
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo .dot {
    width: 14px; height: 14px; border-radius: 50%; margin: 0 auto 12px;
    background: linear-gradient(135deg, var(--gold-2), var(--gold));
    box-shadow: 0 0 0 6px var(--gold-soft);
}
.login-logo h1 { font-size: 1.3rem; margin-bottom: 2px; }
.login-logo p { color: var(--text-2); font-size: .85rem; }

/* ============================================================
   SHELL
   ============================================================ */
.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed; top: 0; left: 0; z-index: 60;
    display: flex; flex-direction: column; justify-content: space-between;
    width: min(84vw, 280px); height: 100vh;
    background: var(--surface); border-right: 1px solid var(--card-border);
    box-shadow: var(--shadow-pop);
    transform: translateX(-100%); transition: transform .38s var(--ease);
}
.app-shell.is-open .sidebar { transform: translateX(0); }
.backdrop {
    display: none; position: fixed; inset: 0; z-index: 50;
    background: rgba(0,0,0,.25);
}
.app-shell.is-open .backdrop { display: block; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 18px; min-height: var(--topbar-h); }
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-dot {
    width: 12px; height: 12px; border-radius: 50%;
    background: linear-gradient(135deg, var(--gold-2), var(--gold));
    box-shadow: 0 0 0 4px var(--gold-soft);
}
.brand-name { font-weight: 700; font-size: 1rem; }
.nav { padding: 6px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 11px 12px;
    border-radius: var(--radius-xs); color: var(--text-2); font-weight: 500; font-size: .92rem;
    transition: background .2s var(--ease), color .2s var(--ease);
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--gold-soft); color: var(--ink); font-weight: 600; }
.nav-ic { width: 20px; text-align: center; }
.sidebar-foot { padding: 16px 18px; border-top: 1px solid var(--card-border); }
.user-chip { display: flex; flex-direction: column; margin-bottom: 10px; }
.user-name { font-weight: 600; font-size: .9rem; }
.user-rol { color: var(--text-2); font-size: .78rem; }
.btn-logout { display: block; text-align: center; padding: 8px; border-radius: var(--radius-xs); background: var(--hover); font-size: .85rem; font-weight: 600; }

.main { min-height: 100vh; }
.topbar {
    display: flex; align-items: center; gap: 12px; min-height: var(--topbar-h);
    padding: 0 18px; background: var(--surface); border-bottom: 1px solid var(--card-border);
    position: sticky; top: 0; z-index: 40;
}
.topbar-title { font-size: 1.1rem; margin: 0; }
.content { padding: 18px; max-width: 980px; margin: 0 auto; }
.icon-btn { border: 0; background: transparent; font-size: 1.2rem; cursor: pointer; padding: 6px; }
.only-mobile { display: inline-flex; }

@media (min-width: 900px) {
    .sidebar { transform: translateX(0); position: sticky; height: 100vh; }
    .backdrop { display: none !important; }
    .app-shell { display: flex; }
    .main { flex: 1; }
    .only-mobile { display: none; }
    .content { padding: 28px 32px; }
}

/* ============================================================
   CARDS / GRID / STATS
   ============================================================ */
.card {
    background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); padding: 20px;
}
.card-narrow { max-width: 460px; }
.card-title { margin-bottom: 14px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
@media (min-width: 640px) {
    .grid-2 { grid-template-columns: 1fr 1fr; }
    .grid-3 { grid-template-columns: 1fr 1fr 1fr; }
}
.stat {
    background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); padding: 18px;
}
.stat-label { color: var(--text-2); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.6rem; font-weight: 700; margin-top: 4px; color: var(--gold); }
.stat-value.plain { color: var(--text); }
.stat-sub { color: var(--muted); font-size: .78rem; margin-top: 2px; }

/* ============================================================
   FORMS
   ============================================================ */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; color: var(--text-2); }
input, select, textarea {
    width: 100%; padding: 11px 13px; border: 1px solid var(--input-border); border-radius: var(--radius-xs);
    background: var(--input-bg); font-family: var(--font); font-size: .95rem; color: var(--text);
    transition: border-color .2s var(--ease);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold-line); }
textarea { resize: vertical; min-height: 70px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px 18px; border-radius: var(--radius-xs); border: 0; cursor: pointer;
    font-family: var(--font); font-weight: 600; font-size: .92rem; transition: transform .15s var(--ease), box-shadow .15s var(--ease);
}
.btn:active { transform: scale(.98); }
.btn-gold { background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #fff; box-shadow: 0 2px 10px rgba(184,134,11,.3); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--input-border); }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 20px; font-size: 1rem; }

.ops-row { display: flex; gap: 10px; flex-wrap: wrap; }
.ops-row .btn { flex: 1; min-width: 160px; }

/* ============================================================
   TABLE
   ============================================================ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--hairline); font-size: .88rem; }
th { color: var(--text-2); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
td.num { text-align: right; }
td.money { font-variant-numeric: tabular-nums; }
td.money.neg { color: var(--danger); }
tr:hover td { background: var(--hover); }
.acciones { white-space: nowrap; }

/* ============================================================
   FLASH / BADGES
   ============================================================ */
.flash { padding: 12px 14px; border-radius: var(--radius-xs); font-size: .88rem; margin-bottom: 16px; font-weight: 500; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.flash-info { background: var(--info-soft); color: var(--info); }

.badge-anulado, .badge-abierto {
    display: inline-block; font-size: .68rem; font-weight: 700; padding: 2px 7px; border-radius: 20px;
    text-transform: uppercase; letter-spacing: .03em;
}
.badge-anulado { background: var(--danger-soft); color: var(--danger); }
.badge-abierto { background: var(--ok-soft); color: var(--ok); }
.row-anulado td { opacity: .5; text-decoration: line-through; }
.row-anulado td.acciones, .row-anulado td:last-child { text-decoration: none; }

.link-sm { font-size: .8rem; font-weight: 600; color: var(--gold); background: none; border: 0; cursor: pointer; padding: 0; margin-right: 8px; }
.link-danger { color: var(--danger); }

.turno-chip {
    display: inline-block; background: var(--gold-soft); color: var(--ink);
    padding: 8px 14px; border-radius: var(--radius-xs); font-size: .85rem; margin: 0 8px 8px 0;
}

.filtro-fecha { display: flex; align-items: center; gap: 10px; }
.filtro-fecha label { font-weight: 600; font-size: .85rem; color: var(--text-2); }
.filtro-fecha input { width: auto; }

/* Punto pulsante "en vivo" */
.live-dot {
    display: inline-block; width: 9px; height: 9px; border-radius: 50%;
    background: var(--ok); margin-left: 8px; vertical-align: middle;
    animation: pulse 1.6s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* Fila nueva insertada por el polling: highlight breve */
@keyframes filaNueva {
    0% { background: var(--gold-soft); }
    100% { background: transparent; }
}
.row-nueva { animation: filaNueva 2.5s var(--ease); }

/* ============================================================
   GRID DE ICONOS — Nueva operación (vista trabajador)
   ============================================================ */
.tipo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-top: 4px; }
.tipo-btn {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 14px 8px; border: 1.5px solid var(--input-border); border-radius: var(--radius-sm);
    background: var(--surface); cursor: pointer; transition: border-color .15s var(--ease), background .15s var(--ease), transform .1s var(--ease);
    font-family: var(--font);
}
.tipo-btn:active { transform: scale(.97); }
.tipo-btn-icono { font-size: 1.8rem; line-height: 1; }
.tipo-btn-nombre { font-size: .78rem; font-weight: 600; text-align: center; color: var(--text); }
.tipo-btn.active { border-color: var(--gold); background: var(--gold-soft); box-shadow: 0 0 0 1px var(--gold-line); }

.detalles-opcionales { margin: 14px 0; }
.detalles-opcionales summary { cursor: pointer; font-size: .85rem; font-weight: 600; color: var(--text-2); padding: 6px 0; }
.detalles-opcionales .field:first-of-type { margin-top: 10px; }

/* ============================================================
   DIALOG (inactividad, WhatsApp) — estilo consistente con .card
   ============================================================ */
dialog {
    border: 1px solid var(--card-border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-pop); padding: 24px; max-width: 360px; width: calc(100vw - 40px);
    font-family: var(--font); color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog h2 { font-size: 1.05rem; margin-bottom: 8px; }
dialog p { font-size: .88rem; color: var(--text-2); }
