/* Mobile-first: los estilos base son para pantallas pequeñas;
   las media queries (min-width) más abajo añaden mejoras para pantallas grandes. */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: #f4f5f7;
    margin: 0;
    color: #1f2430;
    overflow-x: hidden;
}
.container {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 12px;
}
@media (min-width: 480px) {
    .container { padding: 16px; }
}
.empty-state {
    text-align: center;
    padding: 80px 16px;
}
.raffle-header {
    text-align: center;
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.raffle-image {
    max-width: 100%;
    max-height: 320px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 12px;
}
.raffle-header h1 { margin: 8px 0; font-size: 1.25rem; }
.raffle-header p { margin: 6px 0; font-size: 0.95rem; }
.description { white-space: pre-line; color: #444; }
@media (min-width: 480px) {
    .raffle-header h1 { font-size: 1.5rem; }
    .raffle-header p { font-size: 1rem; }
}

.legend {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    font-size: 0.85rem;
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.swatch {
    width: 14px; height: 14px; border-radius: 4px; display: inline-block;
}
.swatch.available { background: #3fb950; }
.swatch.reserved { background: #d29922; }
.swatch.confirmed { background: #8b949e; }

.numbers-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 4px;
}
.number-btn {
    aspect-ratio: 1 / 1;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.75rem;
    cursor: pointer;
    background: #3fb950;
    color: #fff;
    padding: 0;
    touch-action: manipulation;
}
.number-btn.reserved { background: #d29922; cursor: not-allowed; }
.number-btn.confirmed { background: #8b949e; cursor: not-allowed; }
.number-btn:disabled { opacity: 0.85; }
@media (min-width: 480px) {
    .numbers-grid { gap: 6px; }
    .number-btn { font-size: 0.95rem; border-radius: 8px; }
}

.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
    z-index: 10;
}
.modal-overlay.hidden { display: none; }
.modal {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    width: 100%;
    max-width: 360px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal h2 { margin-top: 0; font-size: 1.1rem; }
.modal label {
    display: block;
    margin-bottom: 12px;
    font-size: 0.9rem;
}
.modal input {
    width: 100%;
    padding: 10px;
    margin-top: 4px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 16px; /* evita el zoom automático de iOS al enfocar */
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.modal-actions button {
    padding: 10px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    touch-action: manipulation;
    min-height: 44px;
}
.modal-actions button[type="submit"] { background: #2563eb; color: #fff; }
.modal-actions button#modal-cancel { background: #e5e7eb; }
.error-text { color: #d32f2f; font-size: 0.85rem; }
.hidden { display: none; }

/* Admin */
.admin-wrap {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px 12px 60px;
}
.admin-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.admin-nav h1 { font-size: 1.25rem; margin: 0; }
.card {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.card h2 { margin-top: 0; font-size: 1.1rem; }
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { font-size: 0.9rem; display: block; }
.form-grid input, .form-grid textarea, .form-grid select {
    width: 100%;
    padding: 10px;
    margin-top: 4px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 16px; /* evita el zoom automático de iOS al enfocar */
    font-family: inherit;
}
.btn {
    padding: 10px 18px;
    border-radius: 6px;
    border: none;
    background: #2563eb;
    color: #fff;
    cursor: pointer;
    font-size: 0.95rem;
    touch-action: manipulation;
    min-height: 44px;
}
.btn.secondary { background: #e5e7eb; color: #1f2430; }
.public-link {
    background: #eef2ff;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    word-break: break-all;
}
.admin-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 4px;
}
.admin-num {
    aspect-ratio: 1/1;
    border-radius: 6px;
    border: none;
    color: #fff;
    font-size: 0.7rem;
    cursor: pointer;
    font-weight: 600;
    padding: 0;
    touch-action: manipulation;
}
.admin-num.available { background: #3fb950; }
.admin-num.reserved { background: #d29922; }
.admin-num.confirmed { background: #8b949e; }
.login-wrap {
    max-width: 340px;
    margin: 60px auto;
    padding: 0 16px;
}
@media (min-width: 560px) {
    .form-grid { grid-template-columns: 1fr 1fr; }
    .admin-num { font-size: 0.8rem; }
}
@media (min-width: 480px) {
    .admin-wrap { padding: 20px 16px 60px; }
    .admin-nav h1 { font-size: 1.5rem; }
    .card { padding: 20px; }
}

.admin-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid #e0e0e0;
    overflow-x: auto;
}
.admin-tab {
    padding: 10px 14px;
    font-size: 0.9rem;
    color: #555;
    text-decoration: none;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
}
.admin-tab.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
    font-weight: 600;
}

.filter-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.filter-chip {
    padding: 6px 12px;
    border-radius: 999px;
    background: #eef0f3;
    color: #333;
    font-size: 0.85rem;
    text-decoration: none;
    white-space: nowrap;
}
.filter-chip.active {
    background: #2563eb;
    color: #fff;
}

.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.search-bar input {
    flex: 1;
    min-width: 180px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 16px;
}

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #fff;
}
.status-badge.available { background: #3fb950; }
.status-badge.reserved { background: #d29922; }
.status-badge.confirmed { background: #8b949e; }

.table-wrap { overflow-x: auto; }
.numbers-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.numbers-table th, .numbers-table td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid #eee;
}
.numbers-table thead th {
    color: #666;
    font-size: 0.8rem;
    text-transform: uppercase;
}

/* Debajo de 640px la tabla se convierte en tarjetas apiladas para evitar scroll horizontal */
@media (max-width: 640px) {
    .numbers-table thead { display: none; }
    .numbers-table, .numbers-table tbody, .numbers-table tr, .numbers-table td {
        display: block;
        width: 100%;
    }
    .numbers-table tr {
        margin-bottom: 10px;
        border: 1px solid #eee;
        border-radius: 8px;
        padding: 4px 10px;
    }
    .numbers-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        border-bottom: 1px solid #f2f2f2;
        padding: 8px 0;
    }
    .numbers-table td:last-child { border-bottom: none; }
    .numbers-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #888;
        font-size: 0.78rem;
        text-transform: uppercase;
    }
}
