/* Variables CSS personalizadas (adaptadas para el nuevo diseño) */
:root {
    --primary-color: #3498db;
    /* Azul para botones y bordes */
    --primary-dark-color: #2c3e50;
    /* Azul oscuro para texto y gradientes */
    --secondary-color: #e74c3c;
    /* Rojo para destaque de boleto */
    --success-color: #27ae60;
    /* Verde para botón de imprimir */
    --danger-color: #e74c3c;
    /* Rojo para botón de PDF */
    --text-color: #333;
    --light-text-color: #7f8c8d;
    --white-color: white;
    --background-dark-overlay: rgba(0, 0, 0, 0.5);
    --border-radius-default: 8px;
    /* Arredondamento padrão */
    --spacing-large: 40px;
    --spacing-medium: 20px;
    --spacing-small: 15px;
    --button-padding-desktop: 14px 20px;
    --button-font-size-desktop: 16px;
    --button-padding-mobile: 12px 18px;
    --button-font-size-mobile: 15px;
}

/* Estilos globales */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    /* Usando a fonte Inter conforme padrão */
}

body {
    background: linear-gradient(135deg, #fdbb2d, #2140eb, #ffffff);
    /* Gradiente de fundo */
    color: var(--text-color);
    min-height: 100vh;
    padding: var(--spacing-medium);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    box-sizing: border-box;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

header {
    text-align: center;
    margin-bottom: 30px;
    color: var(--white-color);
    padding: var(--spacing-medium);
    background: var(--background-dark-overlay);
    border-radius: var(--border-radius-default);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(5px);
}

header h1 {
    font-size: 2.8rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

header p {
    font-size: 1.2rem;
    max-width: 800px;
    margin: 0 auto;
}

.app-container {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
}

.form-section {
    flex: 1;
    min-width: 300px;
    background: var(--white-color);
    border-radius: var(--border-radius-default);
    padding: 25px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.preview-section {
    flex: 2;
    min-width: 400px;
    background: var(--white-color);
    border-radius: var(--border-radius-default);
    padding: 25px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.section-title {
    font-size: 1.8rem;
    margin-bottom: 20px;
    color: var(--primary-dark-color);
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--primary-dark-color);
}

select,
input[type="number"],
input[type="text"],
input[type="date"],
input[type="file"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: var(--border-radius-default);
    font-size: 16px;
    transition: all 0.3s;
}

select:focus,
input[type="number"]:focus,
input[type="text"]:focus,
input[type="date"]:focus,
input[type="file"]:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
}

.btn {
    background: var(--primary-color);
    color: var(--white-color);
    border: none;
    padding: var(--button-padding-desktop);
    border-radius: var(--border-radius-default);
    font-size: var(--button-font-size-desktop);
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
    width: 100%;
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.btn-print {
    background: var(--success-color);
}

.btn-print:hover {
    background: #219653;
}

.btn-pdf {
    background: var(--danger-color);
}

.btn-pdf:hover {
    background: #c0392b;
}

.btn-generate {
    background: #9b59b6;
    /* Color morado para generar */
}

.btn-generate:hover {
    background: #8e44ad;
}

.btn-container {
    display: flex;
    flex-wrap: wrap;
    /* Permite que los botones rompan la línea */
    gap: 15px;
    margin-top: 20px;
}

.btn-container .btn {
    width: auto;
    flex: 1;
    min-width: 150px;
    /* Garante un tamaño mínimo para los botones */
}

.boleto-preview {
    flex: 1;
    background: #f8f9fa;
    border: 1px dashed #ccc;
    border-radius: var(--border-radius-default);
    padding: var(--spacing-medium);
    min-height: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    /* Alinea los boletos al tope */
    overflow-y: auto;
    gap: var(--spacing-medium);
    /* Espaciado entre boletos */
}

.boleto {
    width: 300px;
    /* Ancho fijo para simular bobina */
    background: var(--white-color);
    border: 2px solid var(--secondary-color);
    border-radius: var(--border-radius-default);
    padding: var(--spacing-small);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
    break-inside: avoid;
    /* Evita que el boleto se rompa en la impresión */
}

.boleto-header {
    text-align: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px dashed var(--secondary-color);
}

.boleto-number-top {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-dark-color);
    margin-bottom: 5px;
}

.campanha-name {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--secondary-color);
    margin-bottom: 5px;
}

.campanha-type {
    font-size: 1rem;
    color: var(--light-text-color);
    margin-bottom: 10px;
}

.logo {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark-color));
    border-radius: 50%;
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white-color);
    font-weight: bold;
    font-size: 1.5rem;
    overflow: hidden;
    /* Garantiza que el logo no se desborde */
}

.logo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    /* Garantiza que la imagen se ajuste */
}

.premios {
    margin-bottom: 15px;
}

.premios h3 {
    text-align: center;
    margin-bottom: 10px;
    color: var(--primary-dark-color);
    font-size: 1.2rem;
}

.premio-item {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px dashed #ecf0f1;
    font-size: 0.95rem;
}

.numeros {
    margin: 15px 0;
    text-align: center;
}

.numeros h3 {
    margin-bottom: 10px;
    color: var(--primary-dark-color);
    font-size: 1.2rem;
}

.numeros-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.numero {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark-color));
    color: var(--white-color);
    padding: 8px;
    border-radius: 5px;
    font-weight: bold;
    text-align: center;
    font-size: 0.9rem;
}

.boleto-footer {
    display: flex;
    flex-direction: column;
    /* Altera para coluna para empilhar os elementos */
    justify-content: space-between;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 2px dashed var(--secondary-color);
    font-size: 0.85rem;
    gap: 10px;
    /* Espaçamento entre os blocos do footer */
}

.footer-info-block {
    display: flex;
    justify-content: space-between;
    width: 100%;
}

.left-info {
    flex: 1;
    padding-right: 10px;
}

.right-info {
    text-align: right;
    flex: 1;
}

.info-item {
    margin-bottom: 5px;
}

.info-label {
    font-weight: bold;
    color: var(--light-text-color);
}

.bottom-numbers-section {
    text-align: center;
    font-size: 0.75rem;
    /* Menor tamanho de fonte */
    color: var(--light-text-color);
    border-top: 1px dashed #ddd;
    /* Linha divisória */
    padding-top: 8px;
    margin-top: 5px;
}

.bottom-numbers-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 3px;
    /* Espaçamento menor para os números de baixo */
    margin-top: 5px;
}

.bottom-number-item {
    background-color: #f0f0f0;
    color: #555;
    padding: 2px 5px;
    border-radius: 3px;
    font-weight: 500;
    font-size: 0.7rem;
    /* Ainda menor */
}


.empty-preview {
    text-align: center;
    color: var(--light-text-color);
    padding: var(--spacing-medium);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    /* Permite que ocupe o espacio disponible */
}

.empty-preview i {
    font-size: 3rem;
    margin-bottom: 20px;
    color: #bdc3c7;
}

.instructions {
    background: #fff9c4;
    border-left: 4px solid #ffd600;
    padding: var(--spacing-small);
    margin-top: 20px;
    border-radius: 4px;
    font-size: 0.9rem;
}

.thermal-warning {
    background: #ffebee;
    border-left: 4px solid #f44336;
    padding: 10px;
    margin-top: 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    display: none;
}


/* Estilos para impresión */
@media print {
    body * {
        visibility: hidden;
        /* Esconde todo por defecto */
    }

    .boleto-preview,
    .boleto-preview * {
        visibility: visible;
        /* Hace visible la sección de boletos y su contenido */
    }

    .boleto-preview {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 0;
        border: none;
        background: var(--white-color);
        box-shadow: none;
        display: block;
        /* Garantiza que el área de boletos se muestre */
    }

    .boleto {
        border: none;
        box-shadow: none;
        margin: 0 auto 10mm auto;
        /* Margen entre boletos en la impresión */
        padding: 5mm;
        width: 70mm;
        /* Ancho típico de bobina de impresora térmica */
        page-break-inside: avoid;
        /* Evita que el boleto se rompa entre páginas */
        font-size: 9px;
        /* Ajusta la fuente para la bobina */
    }

    .boleto-header,
    .boleto-footer {
        border-color: #000 !important;
        /* Bordes negros para impresión */
    }

    .boleto-number-top {
        font-size: 0.8rem;
        /* Ajusta el tamaño de la fuente para impresión */
    }

    .logo {
        width: 60px;
        height: 60px;
        font-size: 1.2rem;
    }

    .campanha-name {
        font-size: 1.1rem;
    }

    .campanha-type,
    .premios,
    .numeros,
    .boleto-footer {
        font-size: 0.8rem;
    }

    .numero {
        padding: 6px;
        font-size: 0.8rem;
    }

    .bottom-numbers-section {
        font-size: 0.65rem;
        /* Menor para impressão */
    }

    .bottom-number-item {
        font-size: 0.6rem;
        /* Ainda menor para impressão */
        padding: 1px 3px;
    }
}

/* Responsividad para pantallas más pequeñas */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .btn-container {
        flex-direction: column;
    }

    .btn-container .btn {
        width: 100%;
    }

    .boleto {
        width: 100%;
        max-width: 300px;
    }

    header h1 {
        font-size: 2rem;
    }

    header p {
        font-size: 1rem;
    }

    .section-title {
        font-size: 1.5rem;
    }
}


/* Novo campo para valor total no boleto */
.total-value-container {
    text-align: center;
    padding: 8px;
    background-color: #f8f9fa;
    border-radius: 6px;
    margin: 10px 0;
    font-weight: bold;
    border: 1px dashed #ddd;
}

.total-value-label {
    color: #e74c3c;
    font-size: 1.1rem;
}

.total-value {
    font-size: 1.3rem;
    color: #27ae60;
}


/* Estilo para impressão mantendo o design */
@media print {
    .page-footer {
        display: none !important;
    }

    .total-value-container {
        border: none;
        background: none;
        font-size: 0.9rem;
    }

    .total-value-label {
        font-size: 0.9rem;
    }

    .total-value {
        font-size: 1rem;
    }
}