/* ================= */
/* Reset Básico      */
/* ================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #f9c011;
    font-family: 'Segoe UI', sans-serif;
    color: #333;
}

/* ================= */
/* Header            */
/* ================= */
header {
    background: #0383de;
    padding: 20px;
    text-align: center;
}
.header-inner {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}
.logo {
    width: 50px;
}
header h1 {
    color: #f9c011;
    font-size: 1.8em;
    text-transform: uppercase;
}

/* ================= */
/* Botón Seleccionar Tipo */
/* ================= */
.top-actions {
    text-align: center;
    margin: 20px 0;
}
.btn-primary {
    background: #0383de;
    color: #f9c011;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 1em;
    cursor: pointer;
    transition: background .2s;
}
.btn-primary:hover {
    background: #036bb3;
}
.btn-secondary {
    background: #fff;
    color: #0383de;
    border: 2px solid #0383de;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .2s;
}
.btn-secondary:hover {
    background: #e0f0ff;
}

/* ================= */
/* Resumen de Tarjetas */
/* ================= */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    max-width: 800px;
    margin: 0 auto 20px;
}
.card {
    background: #fff;
    padding: 16px;
    border-left: 6px solid #0383de;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.card h3 {
    font-size: 1em;
    color: #555;
    margin-bottom: 8px;
}
.card p {
    font-size: 1.4em;
    color: #0383de;
    font-weight: 700;
}

/* ================= */
/* Modal Base        */
/* ================= */
.hidden {
    display: none !important;
}
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-content {
    background: #fff;
    padding: 24px;
    border-radius: 8px;
    width: 360px;
    position: relative;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    font-size: 1.4em;
    cursor: pointer;
    color: #555;
}

/* ================= */
/* Tipo de Apuesta   */
/* ================= */
.type-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}
.type-btn {
    padding: 10px;
    border: 1px solid #0383de;
    background: #fff;
    color: #0383de;
    border-radius: 6px;
    cursor: pointer;
    transition: background .2s;
}
.type-btn:hover {
    background: #e0f0ff;
}

/* ================= */
/* Formulario        */
/* ================= */
.form-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.form-header h2 {
    flex: 1;
    text-align: center;
}
.form-group {
    margin-bottom: 16px;
    text-align: left;
}
.form-group label {
    display: block;
    margin-bottom: 6px;
    color: #555;
    font-weight: 600;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1em;
    transition: border-color .2s, box-shadow .2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #0383de;
    box-shadow: 0 0 0 2px rgba(3,131,222,0.1);
    outline: none;
}

/* Campos dinámicos */
.dynamic.hidden {
    display: none;
}

/* Inline Payout / Net Gain */
.form-group.inline {
    display: flex;
    gap: 12px;
}
.form-group.inline div {
    flex: 1;
}

/* ================= */
/* Loader            */
/* ================= */
.loader {
    display: inline-block;
    vertical-align: middle;
    width: 18px;
    height: 18px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0383de;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ================= */
/* Historial de Apuestas */
/* ================= */
.history-section {
    background: #fff;
    max-width: 100%;
    margin: 0 auto 40px;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.history-section > h2 {
    margin-bottom: 16px;
    color: #0383de;
    font-size: 1.3em;
}

/* Tabla */
.history-section table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}
.history-section th,
.history-section td {
    padding: 12px 16px;
    font-size: 0.95em;
    text-align: center;
    border-bottom: 1px solid #eee;
    white-space: normal;
    word-break: break-word;
}
.history-section th {
    background: #f0f0f0;
    color: #333;
    font-weight: 600;
}
.history-section tr:nth-child(even) {
    background: #fafafa;
}
.history-section tr:hover {
    background: #f0f4f8;
}

/* Alineación icono + texto en deporte */
td.deporte-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Acciones */
.actions i {
    margin: 0 8px;
    cursor: pointer;
    color: #777;
    transition: color .2s;
}
.actions i:hover {
    color: #333;
}

/* Paginación */
.pagination {
    text-align: center;
    margin-top: 16px;
}
.pagination button {
    margin: 0 6px;
    padding: 8px 12px;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    transition: background .2s;
}
.pagination button.current {
    background: #0383de;
    color: #f9c011;
    border-color: #0383de;
}
.pagination button:hover:not(.current) {
    background: #f0f4f8;
}

/* Footer */
footer {
    background: #222;
    text-align: center;
    padding: 12px 0;
}
footer p {
    color: #fff;
    font-size: 0.9em;
}

/* Ajuste visual de la versión pública */
body {
    min-height: 100vh;
    background: radial-gradient(circle at 80% 0%, rgba(249,192,17,.18), transparent 30%), #f4f7fb;
    color: #172033;
}
header { padding: 22px; background: linear-gradient(120deg, #032a4d, #0383de); border-bottom: 4px solid #f9c011; }
main { width: min(1440px, calc(100% - 40px)); margin: 0 auto; }
.top-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 24px 0 16px; text-align: left; }
.btn-primary { min-height: 44px; padding: 11px 18px; color: #09233b; background: #f9c011; font-weight: 800; box-shadow: 0 8px 22px rgba(249,192,17,.23); }
.btn-primary:hover { background: #eeb200; }
.temporary-note { color: #64748b; font-size: .9rem; }
.summary-cards { max-width: none; margin-bottom: 18px; }
.card { padding: 20px; border: 1px solid #e2e8f0; border-left: 0; border-radius: 14px; text-align: left; box-shadow: 0 12px 32px rgba(15,23,42,.06); }
.card h3 { color: #64748b; font-size: .82rem; text-transform: uppercase; letter-spacing: .07em; }
.card p { color: #0369a1; font-size: 1.7rem; }
.history-section { padding: 22px; border: 1px solid #e2e8f0; border-radius: 16px; box-shadow: 0 16px 40px rgba(15,23,42,.07); }
.history-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.history-heading span { color: #0383de; font-size: .72rem; font-weight: 900; letter-spacing: .14em; }
.history-heading h2 { margin: 4px 0 0; color: #172033; }
.history-heading strong { padding: 7px 10px; border-radius: 999px; color: #075985; background: #e0f2fe; font-size: .78rem; }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid #e2e8f0; border-radius: 11px; }
.history-section table { min-width: 1380px; }
.history-section th { background: #f8fafc; color: #475569; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.history-section th, .history-section td { padding: 12px 11px; border-bottom-color: #e2e8f0; white-space: nowrap; }
.history-section tr:nth-child(even) { background: #fbfdff; }
.positive { color: #15803d; font-weight: 800; }
.negative { color: #b91c1c; font-weight: 800; }
.modal-content { max-height: 92vh; overflow-y: auto; border-radius: 15px; box-shadow: 0 24px 70px rgba(15,23,42,.24); }

@media screen and (max-width: 600px) {
    body { padding: 0; }
    main { width: min(100% - 24px, 1440px); }
    header { margin: 0; }
    .top-actions { align-items: stretch; flex-direction: column; }
    .top-actions .btn-primary { width: 100%; max-width: none; }
    .temporary-note { text-align: center; }
    .summary-cards { display: grid; grid-template-columns: 1fr 1fr; }
    .history-section { padding: 14px; }
    .history-heading { align-items: flex-start; flex-direction: column; }
    .history-section table { min-width: 760px; display: table; }
    .history-section thead { display: table-header-group; }
    .history-section tbody { display: table-row-group; }
}

/* =========================== */
/* Media Queries / MOBILE      */
/* =========================== */
/* ≤600px */
@media screen and (max-width: 600px) {
    body {
        padding: 0 12px;
        font-size: 16px;
    }

    .header-inner {
        flex-direction: column;
        gap: 6px;
    }
    header h1 {
        font-size: 1.3em;
    }

    .top-actions .btn-primary {
        width: 90%;
        padding: 14px 0;
        font-size: 1.05em;
    }

    .summary-cards {
        display: flex;
        flex-direction: column;
        gap: 12px;
        margin-bottom: 20px;
    }

    .history-section table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-spacing: 0 8px;
        table-layout: auto;
    }
    .history-section th {
        white-space: nowrap;
        word-break: normal;
        padding: 6px 8px;
        font-size: 0.85em;
    }
    .history-section td {
        padding: 6px 8px;
        font-size: 0.8em;
    }
    /* ocultar cols secundarias */
    .history-section th:nth-child(2),
    .history-section th:nth-child(7),
    .history-section th:nth-child(8),
    .history-section th:nth-child(9),
    .history-section th:nth-child(13),
    .history-section td:nth-child(2),
    .history-section td:nth-child(7),
    .history-section td:nth-child(8),
    .history-section td:nth-child(9),
    .history-section td:nth-child(13) {
        display: none;
    }

    .pagination button {
        padding: 4px 6px;
        font-size: 0.8em;
    }

    .modal-content {
        width: 95%;
        margin: 10px auto;
        padding: 8px;
    }

    /* Formulario móvil compacto */
    .modal-content,
    #formContainer {
        width: 100% !important;
        padding: 0;
        margin: 0;
    }
    #formContainer form#betForm {
        padding: 0 8px 8px;
    }
    #formContainer .form-group {
        margin-bottom: 8px !important;
    }
    #formContainer .form-group.inline {
        display: block;
        gap: 6px;
    }
    #formContainer .form-group.inline > div {
        margin-bottom: 8px !important;
    }
    #formContainer label {
        font-size: 0.85em;
        margin-bottom: 4px;
    }
    #formContainer input,
    #formContainer select,
    #formContainer textarea {
        font-size: 0.9em;
        padding: 6px 8px;
    }
    #submitBtn,
    #backBtn,
    .type-buttons .type-btn {
        width: 100%;
        padding: 10px 0;
        font-size: 1em;
        margin-bottom: 8px;
    }
    #formContainer .form-header {
        padding: 8px 8px 4px;
        margin-bottom: 8px;
    }
    #formContainer .form-header h2 {
        font-size: 1.1em;
    }
}

/* ≤400px */
@media screen and (max-width: 400px) {
    body {
        padding: 0 8px;
        font-size: 15px;
    }

    .summary-cards {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        margin: 10px auto;
    }
    .summary-cards .card {
        padding: 8px;
    }
    .summary-cards .card h3 {
        font-size: 0.85em;
    }
    .summary-cards .card p {
        font-size: 1.1em;
    }

    .pagination button {
        font-size: 0.75em;
        padding: 4px 6px;
        margin: 0 2px;
    }
    #submitBtn,
    #backBtn {
        font-size: 0.9em;
        padding: 10px;
    }
}
