/* ============================================================
   Invitaciones QR — sistema de diseño (dark-first, mobile-first)
   Sin dependencias, sin build. Un solo archivo.
   ============================================================ */

:root {
    /* Superficies y texto */
    --bg:            #0f1117;
    --surface:       #1a1d29;
    --surface-2:     #212433;
    --border:        #2a2e3d;
    --text:          #e6e8ef;
    --muted:         #9aa0b0;

    /* Acento y estados */
    --accent:        #6366f1;
    --accent-hover:  #7c7ff5;
    --accent-soft:   rgba(99, 102, 241, 0.15);
    --success:       #22c55e;
    --danger:        #ef4444;
    --warning:       #f59e0b;

    /* Forma y ritmo */
    --radius:        10px;
    --radius-sm:     7px;
    --gap:           0.75rem;
    --touch:         44px;                 /* alto táctil mínimo */
    --content-w:     34rem;                /* ~544px */
    --shadow:        0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    --ring:          0 0 0 3px var(--accent-soft);

    color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

/* ---------- Layout ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--gap);
    padding: 0.75rem 1rem;
    background: rgba(15, 17, 23, 0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}
.topbar__brand {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.01em;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.topbar__brand span { color: var(--accent); }
.topbar__end { display: inline-flex; align-items: center; gap: 0.75rem; }
.topbar__user { color: var(--muted); font-size: 0.9rem; }
.topbar__organization { margin: 0; }
.topbar__organization select {
    width: auto;
    max-width: 13rem;
    min-height: 36px;
    margin: 0;
    padding: 0.4rem 2rem 0.4rem 0.7rem;
    font-size: 0.9rem;
}
@media (max-width: 400px) { .topbar__user { display: none; } }
@media (max-width: 480px) {
    .topbar { gap: 0.5rem; padding-inline: 0.65rem; }
    .topbar__end { gap: 0.4rem; }
    .topbar__organization select { max-width: 8.5rem; }
}

.container {
    width: 100%;
    max-width: var(--content-w);
    margin-inline: auto;
    padding: 1.25rem 1rem 3rem;
}

/* ---------- Tipografía ---------- */

h1 { font-size: 1.6rem; line-height: 1.2; letter-spacing: -0.02em; margin: 0.2rem 0 1rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 0.75rem; }
p  { margin: 0 0 0.9rem; }
a  { color: var(--accent-hover); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.text-center { text-align: center; }

/* ---------- Botones ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: var(--touch);
    padding: 0.65rem 1.1rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    line-height: 1;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .05s;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }

.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover   { background: var(--accent-hover); }

.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }

.btn-ghost     { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface); }

.btn-danger    { background: transparent; color: var(--danger); border-color: rgba(239,68,68,.4); }
.btn-danger:hover { background: rgba(239,68,68,.12); }

.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0.4rem 0.7rem; font-size: 0.9rem; }

/* Grupo de acciones: apilado en móvil, en fila en pantallas anchas */
.btn-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin: 0 0 1.25rem;
}
.btn-group .btn { width: 100%; }

/* ---------- Card ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin: 0 0 1.25rem;
}

/* ---------- Formularios ---------- */

label { display: block; font-size: 0.85rem; color: var(--muted); margin: 0 0 0.35rem; }

input, select, textarea {
    width: 100%;
    min-height: var(--touch);
    padding: 0.65rem 0.8rem;
    margin: 0 0 0.9rem;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring);
}
input[type="file"] { padding: 0.5rem; }
input[type="checkbox"] {
    width: auto;
    min-height: auto;
    margin: 0;
    accent-color: var(--accent);
}

/* Los <button> dentro de formularios adoptan el estilo primario por defecto */
form button:not(.btn) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: var(--touch);
    padding: 0.65rem 1.1rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .15s;
}
form button:not(.btn):hover { background: var(--accent-hover); }

.error {
    color: #fecaca;
    background: rgba(239,68,68,.12);
    border: 1px solid rgba(239,68,68,.4);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.8rem;
    margin: 0 0 1rem;
    font-size: 0.9rem;
}

.success {
    color: #bbf7d0;
    background: rgba(34,197,94,.12);
    border: 1px solid rgba(34,197,94,.4);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.8rem;
    margin: 0 0 1rem;
    font-size: 0.9rem;
}

.arte-preview {
    max-width: 300px;
    width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
}

/* ---------- Badges ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 999px;
    white-space: nowrap;
}
.badge-success { color: var(--success); background: rgba(34,197,94,.14); }
.badge-warning { color: var(--warning); background: rgba(245,158,11,.14); }
.badge-muted   { color: var(--muted);   background: var(--surface-2); }

/* ---------- Tablas ---------- */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    margin: 0 0 1.25rem;
}
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.7rem 0.8rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td .btn { margin-right: 0.4rem; }
.row-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}
.row-actions .btn { margin-right: 0; }
.row-actions form { margin: 0; }
.row-actions form button:not(.btn) { width: auto; }

.search-card { padding-bottom: 0.7rem; }
.search-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.6rem;
}
.search-row input { margin-bottom: 0; }
.bulk-actions,
.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.7rem;
    margin: 0 0 1rem;
}
.pagination { justify-content: space-between; }
.is-disabled {
    opacity: 0.45;
    pointer-events: none;
}

/* ---------- Estado vacío ---------- */

.empty {
    text-align: center;
    color: var(--muted);
    padding: 2.5rem 1rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    margin: 0 0 1.25rem;
}

/* ---------- Responsive (≥640px) ---------- */

@media (min-width: 640px) {
    h1 { font-size: 1.9rem; }
    .container { padding-top: 1.75rem; }

    /* Los botones se ajustan a su contenido y las acciones van en fila */
    .btn-group { flex-direction: row; flex-wrap: wrap; }
    .btn-group .btn { width: auto; }

    .btn-auto { width: auto; }
    .search-row { grid-template-columns: minmax(0, 1fr) auto auto; }
}
