/* Estilo inspirado en shadcn: neutros, bordes finos, tipografía clara */

:root {
  --background: #fafafa;
  --foreground: #09090b;
  --card: #ffffff;
  --card-foreground: #09090b;
  --muted: #71717a;
  --muted-bg: #f4f4f5;
  --border: #e4e4e7;
  --ring: #18181b;
  --primary: #18181b;
  --primary-foreground: #fafafa;
  --destructive: #dc2626;
  --radius: 0.5rem;
  --shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md:
    0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.07);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* El atributo hidden debe ocultar de verdad; si no, #id { display: flex } lo anula. */
[hidden] {
  display: none !important;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    "Inter",
    system-ui,
    -apple-system,
    sans-serif;
  background: var(--background);
  color: var(--foreground);
  line-height: 1.5;
}

.screen {
  min-height: 100vh;
}

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

#app-screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

.login-card {
  width: 100%;
  max-width: 22rem;
}

.title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 0.25rem;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 1rem;
}

.muted {
  color: var(--muted);
  font-size: 0.875rem;
  margin: 0 0 1rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.input {
  width: 100%;
  height: 2.5rem;
  padding: 0 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--foreground);
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.input::placeholder {
  color: var(--muted);
}

.input:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 2px rgb(24 24 27 / 0.12);
}

.input:invalid:not(:placeholder-shown) {
  border-color: var(--destructive);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2.5rem;
  padding: 0 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}

.btn-primary:hover {
  background: #27272a;
}

.btn-secondary {
  background: var(--card);
  color: var(--foreground);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--muted-bg);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  height: 2.25rem;
}

.btn-ghost:hover {
  color: var(--foreground);
  background: var(--muted-bg);
}

.btn-danger {
  background: var(--destructive);
  color: #fff;
  border-color: var(--destructive);
}

.btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}

.btn-delete-inline {
  height: 2rem;
  padding: 0 0.625rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--destructive);
  background: transparent;
  border: 1px solid transparent;
}

.btn-delete-inline:hover {
  background: rgb(254 242 242);
  border-color: rgb(252 165 165);
  color: var(--destructive);
}

.btn-edit-inline {
  height: 2rem;
  padding: 0 0.625rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--foreground);
  background: transparent;
  border: 1px solid transparent;
}

.btn-edit-inline:hover {
  background: var(--muted-bg);
  border-color: var(--border);
}

.error {
  color: var(--destructive);
  font-size: 0.8125rem;
  margin: 0.5rem 0 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.brand {
  font-weight: 600;
  font-size: 0.9375rem;
}

.main {
  flex: 1;
  max-width: 48rem;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.app-banner {
  margin: 0;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: rgb(254 242 242);
  border: 1px solid rgb(252 165 165);
}

.form-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 480px) {
  .form-grid {
    grid-template-columns: 1fr 1fr;
    align-items: end;
  }

  .form-actions {
    grid-column: 1 / -1;
  }
}

.field {
  min-width: 0;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.file-btn {
  cursor: pointer;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table th,
.table td {
  text-align: left;
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--border);
}

.table th {
  font-weight: 500;
  background: var(--muted-bg);
  color: var(--foreground);
}

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

.table tbody tr:hover td {
  background: rgb(244 244 245 / 0.6);
}

.empty-row td {
  text-align: center;
  padding: 1.25rem;
}

.table .th-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

.table .td-actions {
  text-align: right;
  vertical-align: middle;
}

.td-actions-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: flex-end;
  align-items: center;
}

.modal-dialog {
  padding: 0;
  border: none;
  background: transparent;
  max-width: calc(100vw - 2rem);
}

.modal-dialog::backdrop {
  background: rgb(9 9 11 / 0.45);
}

.modal-dialog-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 1.25rem 1.5rem;
  min-width: min(22rem, 100%);
}

.modal-dialog-card--wide {
  min-width: min(28rem, 100%);
}

.modal-dialog-textarea {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 0.25rem;
  padding: 0.625rem 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--foreground);
  background: var(--muted-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
  min-height: 12rem;
}

.modal-dialog-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  letter-spacing: -0.01em;
}

.modal-dialog-text {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--foreground);
}

.modal-dialog-hint {
  margin: 0 0 1rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--muted);
}

.modal-dialog-hint strong {
  color: var(--foreground);
  font-weight: 600;
}

.modal-dialog-error {
  margin: 0.5rem 0 0;
}

.modal-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

#numero::-webkit-outer-spin-button,
#numero::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#numero[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

/* Cartelas: ocultas hasta abrir <details> */
.rifa-details {
  padding: 0;
  overflow: hidden;
}

.rifa-details-summary {
  list-style: none;
  cursor: pointer;
  padding: 1rem 1.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--foreground);
  background: var(--muted-bg);
  border-bottom: 1px solid transparent;
  user-select: none;
}

.rifa-details-summary::-webkit-details-marker {
  display: none;
}

.rifa-details-summary::after {
  content: "▸";
  float: right;
  color: var(--muted);
  font-weight: 400;
  transition: transform 0.2s;
}

.rifa-details[open] .rifa-details-summary::after {
  transform: rotate(90deg);
}

.rifa-details[open] .rifa-details-summary {
  border-bottom-color: var(--border);
}

.rifa-details-body {
  padding: 0;
}

.rifa-details-hint {
  margin: .75rem .75rem .5rem;
  font-size: 0.8125rem;
}

/* Number board: ten columns, matching the printed pink ticket. */
.rifa-legend { display: flex; flex-wrap: wrap; gap: 1rem; margin: 0 .75rem .5rem; font-size: .75rem; color: var(--muted); }
.rifa-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.rifa-legend i { width: 13px; height: 13px; border-radius: 4px; border: 1px solid #df85af; background: #fff4f8; }
.rifa-legend .rifa-legend-taken { background: #a92e67; border-color: #922253; }
.rifa-ticket {
  overflow: hidden;
  border: 1px solid #efaccb;
  border-radius: 14px;
  background: #fff6fa;
  text-align: center;
}
.rifa-ticket-header { padding: .875rem .5rem .75rem; }
.rifa-ticket-header h3 {
  margin: 0 0 .35rem;
  color: #b81260;
  font-size: clamp(20px, 5vw, 32px);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: .025em;
}
.rifa-ticket-price {
  width: 72%;
  max-width: 425px;
  margin: 0 auto;
  padding: .3rem .5rem;
  border-radius: 999px;
  background: #e92386;
  color: #fff;
  font-size: clamp(14px, 3.5vw, 21px);
  font-weight: 800;
  line-height: 1.2;
}
.rifa-ticket-footer {
  padding: .75rem .25rem;
  color: #b81260;
  font-size: clamp(13px, 3.5vw, 21px);
  font-weight: 800;
  line-height: 1.2;
}
.rifa-ticket .rifa-grid { border-left: 0; border-right: 0; }
.rifa-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  width: 100%;
  min-width: 0;
  gap: 1px;
  padding: 0;
  border: 1px solid #e591b8;
  border-radius: 0;
  background: #e591b8;
  box-shadow: none;
}
.rifa-cell {
  min-width: 0;
  min-height: 0;
  height: clamp(22px, 3.5vw, 27px);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0;
  background: linear-gradient(135deg, #fffafd, #fbeaf2);
  color: #242024;
  font-family: "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  font-size: clamp(11px, 2.8vw, 17px);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -.04em;
  box-shadow: none;
}
.rifa-cell--ocupado {
  color: white;
  background: #a92e67;
  border-color: #922253;
  box-shadow: none;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

/* Compact dashboard and registration dialog. */
.dashboard-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.eyebrow { margin: 0 0 .35rem; color: var(--muted); font-size: .6875rem; font-weight: 600; letter-spacing: .1em; }
.dashboard-title { margin: 0; font-size: 1.5rem; letter-spacing: -.04em; }
.dashboard-summary { margin: .85rem 0 0; color: var(--muted); font-size: .875rem; }
#register-btn { flex-shrink: 0; }
#participants-count { display: inline-block; margin-left: .3rem; padding: .1rem .5rem; border-radius: 2rem; background: var(--muted-bg); font-size: .75rem; }
.btn { min-height: 44px; }
.btn:disabled { opacity: .55; cursor: wait; }
.btn:focus-visible, .file-btn:focus-within { outline: 2px solid var(--ring); outline-offset: 3px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input[hidden] { display: block !important; position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
body:has(dialog[open]) { overflow: hidden; }
.register-dialog { width: 560px; max-height: calc(100dvh - 3rem); background: var(--card); border: 1px solid var(--border); border-radius: 1rem; padding: 1rem; box-shadow: 0 20px 70px rgb(0 0 0 / .18); }
.register-header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .75rem; }
.register-header h2 { font-size: 1.0625rem; letter-spacing: -.03em; margin: 0; }
.close-button { font-size: 1.75rem; width: 44px; padding: 0; flex-shrink: 0; }
.register-intro { font-size: .875rem; color: var(--muted); margin: .75rem 0 1.5rem; }
.register-actions { justify-content: flex-end; border-top: 1px solid var(--border); padding-top: 1rem; margin-top: .5rem; }
#register-error { grid-column: 1 / -1; }

@media (max-width: 600px) {
  .topbar { padding: .6rem 1rem; padding-top: max(.6rem, env(safe-area-inset-top)); }
  .main { padding: 1rem; gap: 1rem; }
  .card { padding: 1rem; border-radius: .875rem; }
  .dashboard-title { font-size: 1.3rem; }
  .toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
  .toolbar .btn { padding: .5rem; font-size: .8125rem; height: auto; }
  #list-participants-btn { grid-column: 1 / -1; grid-row: 1; }
  .input { font-size: 16px; height: 50px; border-radius: .625rem; }
  .label { margin-bottom: .5rem; }
  .rifa-details.card { padding: 0; }
  .rifa-details-summary { padding: 1rem; font-size: .875rem; }
  .rifa-details-body { padding: 0; }
  .participants-card { background: transparent; padding: 0; border: 0; box-shadow: none; }
  .participants-card .section-title { margin: .25rem 0 .75rem; }
  .table-wrap { border: 0; overflow: visible; }
  .table, .table tbody { display: block; }
  .table thead { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
  .table tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; margin-bottom: .75rem; padding: 1rem; background: var(--card); border: 1px solid var(--border); border-radius: .875rem; box-shadow: var(--shadow); gap: .5rem .75rem; }
  .table td { border: 0; padding: 0; overflow-wrap: anywhere; min-width: 0; }
  .table td:first-child { font-weight: 600; font-size: 1rem; align-self: center; }
  .table td:nth-child(2) { grid-column: 2; grid-row: 1; background: var(--primary); color: white; border-radius: .5rem; padding: .25rem .65rem; font-weight: 600; }
  .table td:nth-child(n+3):not(.td-actions) { grid-column: 1 / -1; display: grid; grid-template-columns: 85px minmax(0, 1fr); font-size: .8125rem; gap: .75rem; }
  .table td:nth-child(n+3):not(.td-actions)::before { content: attr(data-label); color: var(--muted); }
  .table .td-actions { grid-column: 1 / -1; border-top: 1px solid var(--border); margin-top: .25rem; padding-top: .5rem; }
  .td-actions-inner { flex-wrap: nowrap; gap: .5rem; }
  .td-actions-inner .btn { flex: 1; background: var(--muted-bg); }
  .td-actions-inner .btn-delete-inline { background: #fff1f2; }
  .table tbody tr:hover td { background: transparent; }
  .table tbody tr:hover td:nth-child(2) { background: var(--primary); }
  .empty-row td { grid-column: 1 / -1; padding: 1rem !important; font-weight: 400 !important; }
  .modal-dialog-card { padding: 1.25rem; }
  .modal-dialog-card .input { margin-bottom: .75rem; }
  .register-dialog { width: 100%; max-width: none; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; padding: 0; }
  .register-dialog[open] { display: flex; flex-direction: column; }
  .register-header { padding: max(.25rem, env(safe-area-inset-top)) 1rem .25rem; margin-bottom: 0; border-bottom: 1px solid var(--border); flex-shrink: 0; }
  .register-header h2 { font-size: 1.0625rem; }
  .register-intro { margin: 0; padding: 1rem 1.25rem 0; }
  .register-dialog .form-grid { display: flex; flex-direction: column; gap: .75rem; padding: 1rem; flex: 1; }
  .register-actions { position: sticky; bottom: 0; background: var(--card); margin: auto -1rem -1rem; padding: .75rem 1rem max(.75rem, env(safe-area-inset-bottom)); flex-shrink: 0; }
  .register-actions .btn-primary { flex: 1; }
}

/* Labels stay inside the field, including when values are autofilled. */
.register-dialog .form-grid { gap: .75rem; }
.floating-field { position: relative; }
.floating-field .input {
  height: 54px;
  padding: 1.3rem .75rem .3rem;
  font-size: 16px;
}
.floating-field .label {
  position: absolute;
  top: 50%;
  left: .75rem;
  right: .75rem;
  margin: 0;
  transform: translateY(-50%);
  transform-origin: left top;
  color: var(--muted);
  font-size: .9375rem;
  line-height: 1.2;
  cursor: text;
  transition: top .15s, transform .15s, font-size .15s;
}
.floating-field .input:focus + .label,
.floating-field .input:not(:placeholder-shown) + .label,
.floating-field .input:autofill + .label {
  top: 7px;
  transform: none;
  font-size: .6875rem;
}
.floating-field .input:focus + .label { color: var(--foreground); }
@media (prefers-reduced-motion: reduce) {
  .floating-field .label { transition: none; }
}
