* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background: #f0f0f0;
    padding: 0;
    margin: 0;
    overflow-x: hidden;
    touch-action: manipulation;
    /* Improves touch response */
}

.container {
    width: 100vw;
    height: 100vh;
    margin: 0;
    background: white;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
}

h1 {
    font-size: 28px;
    margin-bottom: 8px;
    color: #000000;
    /* Toshiba Black */
    text-align: center;
    font-weight: bold;
    border-bottom: 2px solid #DA291C;
    /* Toshiba Red Underline */
    padding-bottom: 10px;
    display: inline-block;
}

h1 i {
    color: #DA291C;
    /* Toshiba Red Icon */
}

h2 {
    font-size: 18px;
    margin-bottom: 20px;
    color: #666;
    font-weight: normal;
    text-align: center;
}

.step {
    display: none;
    text-align: center;
    /* Center align step content */
}

.step.active {
    display: block;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Grid de años - optimizado con Flexbox */
.year-grid {
    display: flex;
    flex-wrap: wrap;
    /* gap removed for compatibility */
    margin-bottom: 20px;
    max-width: 100%;
}

.year-grid button,
.month-grid button {
    padding: 24px 10px;
    font-size: 20px;
    font-weight: bold;
    border: 2px solid #ddd;
    background: white;
    border-radius: 4px;
    /* Slightly squarer for tech look */
    cursor: pointer;
    transition: all 0.2s;
    min-height: 60px;
    color: #333;
    position: relative;
    overflow: hidden;
}

/* Red accent on hover/active */
.year-grid button:hover,
.month-grid button:hover,
.year-grid button:active,
.month-grid button:active {
    background: #fff;
    color: #DA291C;
    border-color: #DA291C;
    box-shadow: 0 0 5px rgba(218, 41, 28, 0.3);
}

.year-grid button i,
.month-grid button i {
    color: #DA291C;
    /* Red icons inside buttons */
    margin-right: 5px;
}

.year-grid button {
    flex: 1 1 calc(33.333% - 20px);
    /* 3 columnas con margen */
    min-width: 80px;
    margin-right: 10px;
    margin-left: 10px;
    margin-bottom: 20px;
}

/* Grid de meses - optimizado con Flexbox */
.month-grid {
    display: flex;
    flex-wrap: wrap;
    /* gap removed */
    margin-bottom: 20px;
    margin-left: -10px;
    margin-right: -10px;
}

.month-grid button {
    flex: 1 1 calc(33.333% - 24px);
    /* 3 columnas aprox */
    min-width: 80px;
    margin: 10px;
}

/* Tarjetas de vista - sin scroll horizontal */
.view-options {
    display: flex;
    flex-direction: column;
    /* gap removed */
    margin-bottom: 20px;
}

.view-card {
    padding: 25px;
    text-align: left;
    border: 2px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 90px;
    margin-bottom: 20px;
}

.view-card:hover,
.view-card:active {
    background: #fdfdfd;
    border-color: #DA291C;
    /* Toshiba Red */
    transform: translateX(3px);
}

.view-card:hover strong,
.view-card:active strong {
    color: #DA291C;
}

.view-card .icon {
    font-size: 28px;
    display: inline-block;
    margin-right: 10px;
    vertical-align: middle;
    color: #DA291C;
    /* Always Red */
}

.view-card strong {
    display: inline-block;
    font-size: 18px;
    margin-bottom: 3px;
    color: #333;
    vertical-align: middle;
    transition: color 0.2s;
}

.view-card p {
    color: #666;
    font-size: 13px;
    margin-top: 5px;
}

/* Opciones - layout compacto */
.option-group {
    margin-bottom: 18px;
    padding: 15px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 4px;
    border-top: 4px solid #DA291C;
    /* Top Accent */
    border-left: none;
    /* Changed from left to top for cleaner look */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.option-group>label:first-child {
    display: block;
    font-weight: bold;
    margin-bottom: 8px;
    color: #DA291C;
    /* Header in Red */
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.option-group label {
    display: block;
    margin: 6px 0;
    cursor: pointer;
    font-size: 14px;
}

.option-group input[type="radio"],
.option-group input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
    width: 18px;
    height: 18px;
    vertical-align: middle;
    accent-color: #DA291C;
    /* Toshiba Red checkbox/radio */
}

.option-group select {
    width: 100%;
    padding: 10px;
    font-size: 14px;
    border: 2px solid #ddd;
    border-radius: 4px;
    margin-top: 5px;
    color: #333;
}

.option-group select:focus {
    border-color: #DA291C;
    outline: none;
}

/* Flex container for options row */
.options-row {
    display: flex;
    /* gap removed */
    margin-bottom: 15px;
}

.options-row .option-group {
    flex: 1;
    margin-bottom: 0;
    margin-right: 15px;
}

/* Navegación - botones grandes y táctiles */
.navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    margin-top: 20px;
    /* gap removed */
}

button {
    padding: 14px 20px;
    font-size: 16px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 50px;
    flex: 1;
    margin: 0 5px;
    color: #333;
    font-weight: bold;
}

button:hover,
button:active {
    background: #fff;
    border-color: #DA291C;
    color: #DA291C;
}

.btn-primary {
    background: #DA291C;
    /* Toshiba Red */
    color: white;
    border-color: #DA291C;
}

.btn-primary:hover,
.btn-primary:active {
    background: #b01c11;
    /* Darker Red */
    border-color: #b01c11;
    color: white;
}

.btn-all i {
    color: inherit;
    /* Inherit color for icon in 'Todo el año' */
}

/* Año personalizado */
.custom-year {
    display: flex;
    /* gap removed */
    margin-top: 15px;
}

.custom-year input {
    flex: 1;
    margin-right: 10px;
    padding: 12px;
    font-size: 18px;
    border: 2px solid #ddd;
    border-radius: 4px;
}

.custom-year input:focus {
    border-color: #DA291C;
    outline: none;
}

.custom-year button {
    padding: 12px 24px;
    flex: 0 0 auto;
}

/* Optimización para 1024x600 */
@media (max-width: 1024px) and (min-width: 801px) {
    .container {
        padding: 15px;
    }

    h1 {
        font-size: 26px;
    }

    h2 {
        font-size: 16px;
        margin-bottom: 15px;
    }

    .year-grid,
    .month-grid {
        /* gap removed */
    }

    .year-grid button,
    .month-grid button {
        font-size: 18px;
        padding: 15px 8px;
        min-height: 55px;
        flex: 1 1 calc(33.333% - 20px);
        margin: 10px;
    }
}

/* Optimización para 800x480 */
@media (max-width: 800px) {
    .container {
        padding: 10px;
        height: 100vh;
    }

    h1 {
        font-size: 22px;
        margin-bottom: 5px;
    }

    h2 {
        font-size: 14px;
        margin-bottom: 10px;
    }

    .year-grid,
    .month-grid {
        /* gap removed */
        margin-bottom: 10px;
    }

    .year-grid button,
    .month-grid button {
        font-size: 16px;
        padding: 12px 5px;
        min-height: 48px;
        flex: 1 1 calc(33.333% - 10px);
        margin: 5px;
    }

    .view-card {
        padding: 12px;
        min-height: 70px;
    }

    .view-card .icon {
        font-size: 24px;
    }

    .view-card strong {
        font-size: 15px;
    }

    .view-card p {
        font-size: 11px;
    }

    .option-group {
        padding: 10px;
        margin-bottom: 12px;
    }

    .option-group>label:first-child {
        font-size: 13px;
    }

    .option-group label {
        font-size: 12px;
        margin: 4px 0;
    }

    button {
        padding: 10px 12px;
        font-size: 14px;
        min-height: 44px;
    }

    .navigation {
        margin-top: 10px;
        /* gap removed */
    }
}

/* Eliminar scrollbar visible pero mantener funcionalidad */
.container::-webkit-scrollbar {
    width: 8px;
}

.container::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.container::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Estilos de impresión */
@media print {
    body {
        background: white;
        padding: 0;
        margin: 0;
    }

    .container {
        display: none !important;
    }

    #print-area {
        display: block !important;
        width: 100%;
        height: 100%;
    }
}



/* Prevenir zoom accidental en inputs */
input[type="number"] {
    font-size: 16px;
    /* Evita zoom automático en iOS/Android */
}

/* Scroll suave */
.container {
    -webkit-overflow-scrolling: touch;
}

/* Optimización de renderizado */
.step {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* --- ESTILOS DEL CALENDARIO (Compartidos para previsualización e impresión) --- */

/* Contenedor de previsualización */
.calendar-preview {
    border: 1px solid #ccc;
    margin-bottom: 20px;
    margin-top: 0;
    background: white;
    overflow: auto;
    /* Para manejar contenido grande */
    max-height: 400px;
    /* Altura máxima en pantalla */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: center;
}

/* Escalar la previsualización para que quepa mejor */
.calendar-preview .calendar-page {
    transform: scale(0.65);
    transform-origin: top center;
    /* Ancho terico A4 aprox para que el zoom encaje */
    width: 210mm;
    flex-shrink: 0;
}

/* Estilos internos del calendario */
.calendar-page {
    width: 100%;
    background: white;
    padding: 10mm;
    /* Padding visual */
    box-sizing: border-box;
}

.calendar-page h1 {
    text-align: center;
    margin-bottom: 15px;
    color: #DA291C;
    font-size: 24px;
}

.calendar-page h2 {
    font-size: 18px;
    margin: 10px 0;
    text-align: center;
    color: #666;
}

.calendar-page h3 {
    font-size: 16px;
    margin: 8px 0;
    border-bottom: 1px solid #333;
    padding-bottom: 3px;
    color: #DA291C;
}

.calendar-page table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

.calendar-page th,
.calendar-page td {
    border: 1px solid #333;
    padding: 8px;
    text-align: center;
    vertical-align: top;
}

.calendar-page th {
    background: #f0f0f0;
    color: #333;
    font-weight: bold;
    font-size: 14px;
}

.calendar-page td {
    height: 60px;
    font-size: 13px;
}

.calendar-page .day-number {
    font-weight: bold;
    font-size: 16px;
}

.calendar-page .holiday {
    color: #DA291C;
    font-weight: bold;
}

.calendar-page .holiday-name {
    font-size: 9px;
    color: #DA291C;
    margin-top: 2px;
}

.calendar-page .weekend {
    background: #f5f5f5;
}

.calendar-page .notes-lines {
    border-top: 1px solid #ccc;
    margin-top: 8px;
    padding-top: 8px;
    line-height: 1.8;
    font-size: 12px;
}

.calendar-page .planner-time {
    width: 70px;
    font-weight: bold;
    background: #f0f0f0;
}

.calendar-page .week-number {
    font-size: 12px;
    color: #666;
    background: #f9f9f9;
    vertical-align: middle;
}

/* Ajustes para Horizontal (Landscape) */
.calendar-preview .calendar-page.landscape,
.calendar-page.landscape {
    width: 297mm;
    /* Ancho A4 horizontal */
}

.calendar-page.landscape h1 {
    font-size: 22px;
}

.calendar-page.landscape h2 {
    font-size: 16px;
}

.calendar-page.landscape h3 {
    font-size: 14px;
}

.calendar-page.landscape th {
    font-size: 12px;
    padding: 6px;
}

.calendar-page.landscape td {
    height: 45px;
    font-size: 11px;
    padding: 6px;
}

.calendar-page.landscape .day-number {
    font-size: 14px;
}

.calendar-page.landscape .holiday-name {
    font-size: 8px;
}

.calendar-page.landscape .notes-lines {
    margin-top: 5px;
    padding-top: 5px;
    line-height: 1.5;
    font-size: 10px;
}

.calendar-page.landscape .planner-time {
    width: 60px;
}

.calendar-page.landscape .week-number {
    font-size: 10px;
}

.calendar-page.landscape .week-content {
    column-count: 2;
    column-gap: 20px;
}


/* --- ESTILOS DE IMPRESIÓN --- */
@media print {
    @page {
        margin: 0;
    }

    html,
    body {
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
    }

    body {
        background: white;
    }

    .container,
    .navigation,
    #message-container {
        display: none !important;
    }

    #print-area {
        display: block !important;
    }

    /* Flexbox layout for full page height */
    .calendar-page {
        width: 100% !important;
        height: 100% !important;
        margin: 0 !important;
        padding: 5mm !important;
        /* Reduced padding for more space */
        page-break-after: always;
        page-break-inside: avoid;
        transform: none !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between;
        /* Start/End alignment */
        box-sizing: border-box !important;
    }

    .calendar-page h1 {
        margin-bottom: 5px !important;
        flex: 0 0 auto;
        /* Header takes content height */
    }

    .calendar-page h2,
    .calendar-page h3 {
        flex: 0 0 auto;
    }

    /* Standard Table Layout for Printing */
    .calendar-page table {
        display: table !important;
        width: 100% !important;
        height: 100% !important;
        border-collapse: collapse !important;
        border: 1px solid #000;
        table-layout: fixed;
        /* Ensures equal width columns */
    }

    .calendar-page thead {
        display: table-header-group !important;
    }

    .calendar-page tbody {
        display: table-row-group !important;
    }

    .calendar-page tr {
        display: table-row !important;
        height: auto !important;
        /* Let content or JS define height, but for full page fill we might need calc */
    }

    /* Distribute height evenly */
    .calendar-page tbody tr {
        height: 16.66% !important;
        /* Approx 100% / 6 rows */
    }

    .calendar-page th,
    .calendar-page td {
        display: table-cell !important;
        border: 1px solid #000 !important;
        /* Force black border */
        vertical-align: top !important;
        width: auto !important;
        /* Let table-layout: fixed handle it */
        box-sizing: border-box;
        overflow: hidden;
    }

    /* Ensure external border is solid */
    .calendar-page {
        border: none !important;
        /* The table has the border */
    }

    /* Specific fixes for month planner */
    .calendar-page td {
        height: auto !important;
        /* Rely on row height */
    }

    /* Force text to wrap */
    .holiday-name {
        white-space: normal !important;
        font-size: 8pt !important;
    }
}

/* Scroll suave */
.container {
    -webkit-overflow-scrolling: touch;
}

/* Optimización de renderizado */
.step {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}