/* ========================================================================
   PayTickets — visual theme inspirado en PayViolations
   Paleta: primary #005087 (azul), secondary #E26329 (naranja)
   Tipografía: BasicSans-LightItalic / Basic Sans / Poppins
   ======================================================================== */

@font-face {
    font-family: 'Basic Sans';
    font-style: italic;
    font-weight: 300;
    src: local('Basic Sans Light Italic'),
         local('BasicSans-LightItalic'),
         url('../fonts/BasicSans-LightItalic.ttf') format('truetype'),
         url('../fonts/BasicSans-LightItalic.otf') format('opentype');
    font-display: swap;
}

@font-face {
    font-family: 'BasicSans-LightIt';
    src: url('https://db.onlinewebfonts.com/t/1d8fbe95b298417a043edc59f44d3a09.eot');
    src: url('https://db.onlinewebfonts.com/t/1d8fbe95b298417a043edc59f44d3a09.eot?#iefix') format('embedded-opentype'),
         url('https://db.onlinewebfonts.com/t/1d8fbe95b298417a043edc59f44d3a09.woff2') format('woff2'),
         url('https://db.onlinewebfonts.com/t/1d8fbe95b298417a043edc59f44d3a09.woff') format('woff'),
         url('https://db.onlinewebfonts.com/t/1d8fbe95b298417a043edc59f44d3a09.ttf') format('truetype'),
         url('https://db.onlinewebfonts.com/t/1d8fbe95b298417a043edc59f44d3a09.svg#BasicSans-LightIt') format('svg');
    font-display: swap;
}

:root {
    --color-primary: #005087;
    --color-primary-hover: #003d68;
    --color-secondary: #E26329;
    --color-secondary-hover: #c4541e;
    --color-text: #005087;
    --color-text-muted: #4a6885;
    --color-card-bg: rgba(220, 220, 220, 0.8);
    --color-white: #ffffff;
    --color-error: #d32f2f;
    --color-success: #2e7d32;
    --color-warning: #ed6c02;
    --font-family: 'BasicSans-LightIt', 'Basic Sans', 'Poppins', Arial, sans-serif;
    --shadow-card: 0 0 2px var(--color-primary), 0 0 2px var(--color-primary), 0 0 2px var(--color-primary);
    --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    font-family: var(--font-family);
    color: var(--color-text);
    line-height: 1.4;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-image: url('../assets/img/background.png');
    background-size: cover;
    background-position: center bottom;
    background-repeat: no-repeat;
    /* En móvil mejor "scroll" — fixed degrada FPS en iOS y al desplazar */
    background-attachment: scroll;
    -webkit-text-size-adjust: 100%;
}
@media (min-width: 900px) {
    body { background-attachment: fixed; }
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-hover); text-decoration: underline; }

/* ===== Header ===== */
.site-header {
    flex-grow: 0;
    padding: 6px 10px;
}
@media (min-width: 600px) { .site-header { padding: 10px 24px; } }
@media (min-width: 900px) { .site-header { padding: 10px 36px; } }

.site-header-inner {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.site-logo {
    width: auto;
    height: 36px;
}
@media (min-width: 480px) { .site-logo { height: 42px; } }
@media (min-width: 600px) { .site-logo { height: 56px; padding-top: 8px; margin-top: 8px; } }
@media (min-width: 900px) { .site-logo { height: 68px; padding-top: 16px; margin-top: 16px; } }

.lang-switcher {
    display: flex;
    gap: 8px;
    padding-top: 6px;
}
@media (min-width: 600px) { .lang-switcher { gap: 12px; padding-top: 18px; } }
@media (min-width: 900px) { .lang-switcher { padding-top: 24px; } }
.lang-switcher a {
    color: var(--color-primary);
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 4px;
    /* Touch target mínimo */
    min-width: 36px;
    text-align: center;
}
.lang-switcher a.active {
    background: var(--color-primary);
    color: #fff;
}

/* ===== Main / Card ===== */
.site-main {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    padding: 8px;
}
@media (min-width: 600px) { .site-main { padding: 16px 24px 24px; } }
@media (min-width: 900px) { .site-main { padding: 24px 48px 48px; } }
@media (min-width: 1200px) { .site-main { padding: 32px 64px 64px; } }
@media (min-width: 1600px) { .site-main { padding: 32px 96px 96px; } }

.glass-card {
    background-color: var(--color-card-bg);
    box-shadow: var(--shadow-card);
    border-radius: var(--radius);
    width: 100%;
    /* Tope para que en monitores 4K no se estire al infinito */
    max-width: 1600px;
    display: flex;
    flex-direction: column;
    padding: 8px;
}
@media (min-width: 600px) { .glass-card { padding: 8px 16px; } }
@media (min-width: 900px) { .glass-card { padding: 12px 20px; } }
@media (min-width: 1200px) { .glass-card { padding: 16px 24px; } }

.card-header {
    border-bottom: 1px solid var(--color-primary);
    margin: 4px 8px 0;
    padding-bottom: 12px;
}
@media (min-width: 600px) { .card-header { margin: 8px 16px 0; } }
@media (min-width: 900px) { .card-header { margin: 12px 20px 0; border-bottom-width: 2px; } }
@media (min-width: 1200px) { .card-header { margin: 16px 24px 0; } }

.card-header h1 {
    margin: 0;
    color: var(--color-primary);
    text-align: center;
    font-size: 1.35rem;
    font-weight: bold;
    font-style: italic;
    word-break: break-word;
}
@media (min-width: 480px) { .card-header h1 { font-size: 1.5rem; } }
@media (min-width: 600px) { .card-header h1 { font-size: 1.6rem; } }
@media (min-width: 900px) { .card-header h1 { font-size: 1.875rem; } }

.card-body {
    padding: 14px 6px;
}
@media (min-width: 480px) { .card-body { padding: 16px 8px; } }
@media (min-width: 600px) { .card-body { padding: 24px 16px; } }

/* ===== Instructions ===== */
.instructions {
    margin: 0 0 20px;
    padding: 0;
    list-style: none;
    color: var(--color-primary);
}
@media (min-width: 600px) { .instructions { margin-bottom: 24px; } }
.instructions h2 {
    margin: 0 0 10px;
    color: var(--color-primary);
    font-weight: bold;
    font-style: italic;
    font-size: 1.2rem;
}
@media (min-width: 600px) { .instructions h2 { font-size: 1.35rem; } }
@media (min-width: 900px) { .instructions h2 { font-size: 1.5rem; } }
.instructions li {
    font-size: 0.95rem;
    margin-bottom: 4px;
    color: var(--color-primary);
}
@media (min-width: 600px) { .instructions li { font-size: 1rem; } }
@media (min-width: 900px) { .instructions li { font-size: 1.125rem; } }
.instructions li::before {
    content: '— ';
    color: var(--color-primary);
}

/* ===== Form ===== */
.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin-bottom: 20px;
}
@media (min-width: 600px) { .form-row { gap: 16px; margin-bottom: 24px; grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .form-row.cols-3 { grid-template-columns: repeat(3, 1fr); } }
/* Fila full width: la usa el cardNumber para tener todo el ancho. Mantiene 1fr en todos los breakpoints. */
.form-row--full,
.form-row--full[class] { grid-template-columns: 1fr !important; }

.field {
    display: flex;
    flex-direction: column;
    position: relative;
}
.field label {
    color: var(--color-primary);
    font-size: 0.85rem;
    margin-bottom: 2px;
    font-style: italic;
}
.field input,
.field select,
.field textarea {
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--color-primary);
    padding: 8px 0;
    color: var(--color-primary);
    font-family: inherit;
    /* 16px previene el zoom automático de iOS al enfocar */
    font-size: 16px;
    outline: none;
    transition: border-color .2s;
    /* Tap target táctil */
    min-height: 40px;
    width: 100%;
    max-width: 100%;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
    border-bottom-color: var(--color-secondary);
    border-bottom-width: 2px;
}
.field input::placeholder { color: var(--color-text-muted); opacity: 0.7; }

/* Mes / Año side-by-side */
.expiry-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-items: end;
}

.field.error input,
.field.error select { border-bottom-color: var(--color-error); }
.field .error-msg {
    color: var(--color-error);
    font-size: 0.75rem;
    margin-top: 4px;
    min-height: 1em;
}

/* ===== Buttons ===== */
.btn-row {
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
}
@media (min-width: 480px) {
    .btn-row {
        flex-direction: row;
        justify-content: flex-end;
        gap: 12px;
        flex-wrap: wrap;
    }
}

.btn {
    font-family: inherit;
    font-size: 1rem;
    padding: 12px 20px;
    border-radius: 4px;
    border: 1px solid var(--color-primary);
    background: transparent;
    color: var(--color-primary);
    cursor: pointer;
    text-transform: none;
    transition: background .2s, color .2s;
    /* Touch target táctil mínimo */
    min-height: 44px;
    width: 100%;
}
@media (min-width: 480px) {
    .btn { width: auto; min-width: 110px; padding: 10px 24px; }
}
.btn:hover { background: rgba(0, 80, 135, 0.08); }
.btn-primary {
    background: var(--color-primary);
    color: var(--color-white);
}
.btn-primary:hover {
    background: var(--color-primary-hover);
    color: #fff;
}
.btn-secondary {
    background: var(--color-secondary);
    color: #fff;
    border-color: var(--color-secondary);
}
.btn-secondary:hover {
    background: var(--color-secondary-hover);
    border-color: var(--color-secondary-hover);
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Inline button spinner shown via JS adding .btn--loading */
.btn { position: relative; }
.btn--loading {
    color: transparent !important;
    pointer-events: none;
}
.btn--loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
/* Botones outline (sin fondo) → spinner azul */
.btn.btn--loading:not(.btn-primary):not(.btn-secondary)::after {
    border-color: rgba(0, 80, 135, 0.25);
    border-top-color: var(--color-primary);
}

/* ===== Alerts ===== */
.alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 12px;
    font-size: 0.95rem;
}
.alert-success { background: #e8f5e9; color: var(--color-success); border-left: 4px solid var(--color-success); }
.alert-danger { background: #ffebee; color: var(--color-error); border-left: 4px solid var(--color-error); }
.alert-warning { background: #fff3e0; color: var(--color-warning); border-left: 4px solid var(--color-warning); }

/* ===== Loading overlay ===== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(220, 220, 220, 0.75);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}
.loading-overlay.show { display: flex; }
.loading-spinner {
    border: 4px solid rgba(0, 80, 135, 0.2);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Dialog / Modal ===== */
.dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 900;
    padding: 8px;
}
@media (min-width: 480px) { .dialog-backdrop { padding: 16px; } }
.dialog-backdrop.show { display: flex; }
.dialog {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    max-width: 560px;
    width: 100%;
    /* En móvil dejamos margen para safe-area / barras del navegador */
    max-height: calc(100vh - 16px);
    overflow: auto;
    padding: 14px;
    -webkit-overflow-scrolling: touch;
}
@media (min-width: 480px) { .dialog { padding: 18px; max-height: 92vh; } }
@media (min-width: 600px) { .dialog { padding: 20px; max-height: 90vh; } }

.dialog-header {
    border-bottom: 1px solid var(--color-primary);
    padding-bottom: 10px;
    margin-bottom: 14px;
}
@media (min-width: 600px) { .dialog-header { padding-bottom: 12px; margin-bottom: 16px; } }
.dialog-header h2 {
    margin: 0;
    color: var(--color-primary);
    font-style: italic;
    font-weight: bold;
    font-size: 1.2rem;
    word-break: break-word;
}
@media (min-width: 600px) { .dialog-header h2 { font-size: 1.4rem; } }
.dialog-body { color: var(--color-primary); }
.dialog-footer {
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    margin-top: 18px;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 80, 135, 0.2);
}
@media (min-width: 480px) {
    .dialog-footer {
        flex-direction: row;
        justify-content: flex-end;
        gap: 12px;
        flex-wrap: wrap;
        margin-top: 20px;
    }
}

/* ===== Ticket details list ===== */
.ticket-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.ticket-list li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px dashed rgba(0, 80, 135, 0.3);
    flex-wrap: wrap;
}
.ticket-list li:last-child { border-bottom: 0; }
.ticket-list .ticket-label {
    color: var(--color-text-muted);
    flex-shrink: 0;
}
.ticket-list .ticket-value {
    color: var(--color-primary);
    text-align: right;
    word-break: break-word;
    min-width: 0;
    flex: 1 1 auto;
}
.ticket-list li.total-row {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 2px solid var(--color-primary);
    border-bottom: 0;
    font-size: 1.15rem;
}
.ticket-list li.total-row .ticket-label,
.ticket-list li.total-row .ticket-value {
    color: var(--color-primary);
    font-weight: bold;
}

/* Cabecera del resumen en el PaymentDialog: identifica el ticket y no
   se confunde con las filas del sumatorio. */
.summary-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 6px 0 10px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(0, 80, 135, 0.25);
    flex-wrap: wrap;
}
.summary-head .head-label {
    color: var(--color-text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-style: normal;
}
.summary-head .head-value {
    color: var(--color-primary);
    font-weight: 600;
    font-size: 1rem;
    font-style: normal;
}

/* ===== Payment success view (dentro del paymentDialog) ===== */
.payment-success {
    text-align: center;
    padding: 4px 8px 16px;
    border-bottom: 1px solid rgba(0, 80, 135, 0.2);
    margin-bottom: 14px;
}
@media (min-width: 600px) { .payment-success { padding: 8px 16px 20px; margin-bottom: 16px; } }
.payment-success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: rgba(46, 125, 50, 0.15);
    color: var(--color-success);
    font-size: 28px;
    font-weight: bold;
    line-height: 1;
}
@media (min-width: 600px) {
    .payment-success-icon { width: 64px; height: 64px; font-size: 36px; margin-bottom: 16px; }
}
.payment-success-icon::before { content: "\2713"; }
.payment-success h3 {
    color: var(--color-primary);
    margin: 0 0 6px;
    font-style: italic;
    font-weight: bold;
    font-size: 1.2rem;
}
@media (min-width: 600px) { .payment-success h3 { font-size: 1.35rem; } }
.payment-success p {
    color: var(--color-primary);
    margin: 0;
    font-size: 0.95rem;
}
@media (min-width: 600px) { .payment-success p { font-size: 1rem; } }

/* ===== Payment error view (dentro del paymentDialog) ===== */
.payment-error {
    text-align: center;
    padding: 4px 8px 16px;
    border-bottom: 1px solid rgba(0, 80, 135, 0.2);
    margin-bottom: 14px;
}
@media (min-width: 600px) { .payment-error { padding: 8px 16px 20px; margin-bottom: 16px; } }
.payment-error-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: rgba(211, 47, 47, 0.12);
    color: var(--color-error);
    font-size: 28px;
    font-weight: bold;
    line-height: 1;
}
@media (min-width: 600px) {
    .payment-error-icon { width: 64px; height: 64px; font-size: 36px; margin-bottom: 16px; }
}
.payment-error-icon::before { content: "\2715"; }
.payment-error h3 {
    color: var(--color-error);
    margin: 0 0 6px;
    font-style: italic;
    font-weight: bold;
    font-size: 1.2rem;
}
@media (min-width: 600px) { .payment-error h3 { font-size: 1.35rem; } }
.payment-error p {
    color: var(--color-primary);
    margin: 0;
    font-size: 0.95rem;
    word-break: break-word;
}
@media (min-width: 600px) { .payment-error p { font-size: 1rem; } }

/* ===== Image preview dialog ===== */
.dialog--image { max-width: 900px; }
#imagePreviewImg {
    max-width: 100%;
    max-height: 55vh;
    height: auto;
    display: block;
    margin: 0 auto;
}
@media (min-width: 600px) { #imagePreviewImg { max-height: 65vh; } }
@media (orientation: landscape) and (max-height: 500px) {
    #imagePreviewImg { max-height: 50vh; }
}

/* ===== Utilities ===== */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
