/* Variables CSS para consistencia de colores */
:root {
    --color-primario: #0056b3;
    --color-secundario: #007bff;
}

/* Mobile First - Estilos base para móviles */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f7f9;
    color: #333;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

.container {
    background-color: #fff;
    padding: 1em;
    width: 100%;
    min-height: 100vh;
    box-sizing: border-box;
}

/* Desktop y tablets grandes */
@media (min-width: 768px) {
    body {
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    .container {
        padding: 2em;
        border-radius: 8px;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
        max-width: 800px;
        min-height: auto;
    }
}

/* Branding y logo */
.logo-container {
    text-align: center;
    margin-bottom: 1em;
}

.brand-logo {
    max-height: 60px;
    max-width: 200px;
    height: auto;
    width: auto;
}

/* Desktop */
@media (min-width: 768px) {
    .logo-container {
        margin-bottom: 1.5em;
    }
    
    .brand-logo {
        max-height: 80px;
        max-width: 250px;
    }
}

h1 {
    text-align: center;
    color: var(--color-primario);
    font-size: 1.5em;
    margin: 0.5em 0 1em 0;
}

/* Desktop */
@media (min-width: 768px) {
    h1 {
        font-size: 2em;
        margin: 1em 0;
    }
}

.form-grid {
    display: flex;
    flex-direction: column;
    gap: 1em;
    margin-bottom: 1em;
}

/* Tablet y Desktop */
@media (min-width: 600px) {
    .form-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5em;
        margin-bottom: 1.5em;
    }
}

.form-group label {
    display: block;
    margin-bottom: 0.4em;
    font-weight: 600;
    font-size: 0.95em;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.9em;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 16px; /* Evita zoom en iOS */
}

/* Desktop */
@media (min-width: 768px) {
    .form-group label {
        margin-bottom: 0.5em;
        font-size: 1em;
    }
    
    .form-group input,
    .form-group select {
        padding: 0.8em;
    }
}

button {
    display: block;
    width: 100%;
    padding: 1.1em;
    border: none;
    background-color: var(--color-secundario);
    color: white;
    font-size: 1.1em;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s;
    font-weight: 600;
    touch-action: manipulation; /* Mejor respuesta táctil */
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

button:active {
    background-color: var(--color-primario);
    transform: scale(0.98);
}

button:hover {
    background-color: var(--color-primario);
}

button:disabled {
    background-color: #aaa;
    cursor: not-allowed;
}

/* Desktop */
@media (min-width: 768px) {
    button {
        padding: 1em;
        border-radius: 4px;
    }
}

.hidden {
    display: none;
}

#resultado {
    margin-top: 1em;
    padding-top: 0;
}

/* Desktop */
@media (min-width: 768px) {
    #resultado {
        margin-top: 2em;
        padding-top: 1.5em;
        border-top: 1px solid #eee;
    }
}

#visorPdf iframe {
    width: 100% !important;
    height: 70vh !important; /* Altura adaptativa en móviles */
    min-height: 400px !important;
    border: 1px solid #ddd !important;
    border-radius: 4px;
    display: block;
}

/* Desktop */
@media (min-width: 768px) {
    #visorPdf iframe {
        height: 600px !important;
    }
}

.pdf-viewer-container {
    margin: 0.5em 0;
}

/* Indicador de carga del PDF */
.pdf-loading {
    text-align: center;
    padding: 3em 2em;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    color: #6c757d;
    font-size: 1em;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Desktop */
@media (min-width: 768px) {
    .pdf-viewer-container {
        margin: 1em 0;
    }
    
    .pdf-loading {
        padding: 4em 2em;
        font-size: 1.1em;
    }
}

#enlacesDescarga {
    margin-top: 1em;
    display: flex;
    flex-direction: column;
    gap: 0.8em;
    padding: 0 0.5em;
}

/* Tablet y Desktop */
@media (min-width: 600px) {
    #enlacesDescarga {
        flex-direction: row;
        gap: 1em;
        justify-content: center;
        padding: 0;
    }
}

#enlacesDescarga a {
    text-decoration: none;
    padding: 1em 1.5em;
    border-radius: 8px;
    color: #fff;
    font-weight: bold;
    text-align: center;
    font-size: 1em;
    transition: transform 0.2s, box-shadow 0.2s;
    touch-action: manipulation;
}

#enlacesDescarga a:active {
    transform: scale(0.95);
}

/* Desktop */
@media (min-width: 768px) {
    #enlacesDescarga a {
        padding: 0.8em 1.5em;
        border-radius: 4px;
    }
}

.btn-pdf { 
    background-color: #dc3545;
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
}
.btn-xml { 
    background-color: #28a745;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
}
.btn-cdr { 
    background-color: #ffc107;
    color: #333;
    box-shadow: 0 2px 4px rgba(255, 193, 7, 0.3);
}

/* Estilos para reCAPTCHA v3 */
.recaptcha-info {
    margin: 1em 0;
    padding: 0.8em;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    text-align: center;
}

.recaptcha-info p {
    margin: 0;
    font-size: 0.8em;
    color: #6c757d;
    line-height: 1.4;
}

.recaptcha-info a {
    color: var(--color-secundario);
    text-decoration: none;
}

.recaptcha-info a:hover {
    text-decoration: underline;
}

/* Desktop */
@media (min-width: 768px) {
    .recaptcha-info {
        padding: 1em;
    }
    
    .recaptcha-info p {
        font-size: 0.9em;
    }
}

/* Indicador de verificación reCAPTCHA */
.recaptcha-status {
    display: none;
    margin: 0.5em 0;
    padding: 0.5em;
    border-radius: 4px;
    text-align: center;
    font-size: 0.9em;
}

.recaptcha-status.verifying {
    display: block;
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.recaptcha-status.verified {
    display: block;
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.recaptcha-status.failed {
    display: block;
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Ocultar el badge de reCAPTCHA si es necesario */
.grecaptcha-badge {
    visibility: visible !important;
}

/* Aviso de comprobante en cola */
.en-cola-aviso {
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    padding: 1em;
    margin-bottom: 1em;
    text-align: center;
}

.en-cola-aviso p {
    margin: 0;
    color: #856404;
    font-size: 0.95em;
    font-weight: 500;
    line-height: 1.5;
}

/* Aviso de ticket temporal */
.ticket-aviso {
    background-color: #e7f3ff;
    border: 1px solid #0066cc;
    border-radius: 6px;
    padding: 1em;
    margin-bottom: 1em;
    text-align: center;
}

.ticket-aviso p {
    margin: 0;
    color: #004499;
    font-size: 0.95em;
    font-weight: 500;
    line-height: 1.5;
}

/* Desktop */
@media (min-width: 768px) {
    .en-cola-aviso,
    .ticket-aviso {
        padding: 1.2em;
    }
    
    .en-cola-aviso p,
    .ticket-aviso p {
        font-size: 1em;
    }
}

/* Mensaje promocional */
.mensaje-promocional {
    text-align: center;
    margin: 1.5em 0 0 0;
    padding: 1em;
    background-color: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.mensaje-promocional p {
    margin: 0;
    font-size: 0.9em;
    color: #495057;
    line-height: 1.4;
}

.mensaje-promocional a {
    color: var(--color-secundario);
    text-decoration: none;
    font-weight: 600;
}

.mensaje-promocional a:hover {
    color: var(--color-primario);
    text-decoration: underline;
}

/* Desktop */
@media (min-width: 768px) {
    .mensaje-promocional {
        margin: 2em 0 0 0;
        padding: 1.2em;
    }
    
    .mensaje-promocional p {
        font-size: 1em;
    }
}

@media (max-width: 600px) {
    .recaptcha-info {
        padding: 0.8em;
    }
    
    .recaptcha-info p {
        font-size: 0.8em;
    }
}