/* Base Styles */
body {
    font-family: Arial, sans-serif;
    background-color: #f4f4f9;
    color: #333;
    padding: 20px;
    box-sizing: border-box;
    max-width: 1400px; /* Limit maximum width */
    margin: 0 auto; /* Center the content */
}

/* Header Styles */
header {
    text-align: center;
    margin-bottom: 20px;
    position: relative; /* For proper positioning of controls */
    padding-top: 10px; /* Give space for the controls */
}

header h1 {
    font-size: 2em;
    color: #222140;
    margin: 0;
    padding: 10px;
    border-bottom: 2px solid #222140;
}

/* Controls Container */
#button-container {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    align-items: center;
    z-index: 1000;
}

/* Custom Location Selector */
.custom-select {
    position: relative;
    display: inline-block;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 1em;
    font-weight: bold;
    color: #fff;
    background-color: #222140;
    border: none;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    height: 38px;
    min-width: 130px;
    box-sizing: border-box;
}

.custom-select-trigger:hover {
    background-color: #1a1a33;
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

.custom-select-trigger .flag-icon {
    width: 18px;
    height: 12px;
    flex-shrink: 0;
}

.custom-select-trigger .location-text {
    flex: 1;
}

.custom-select-trigger .dropdown-arrow {
    font-size: 0.8em;
    margin-left: auto;
}

.custom-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    display: none;
    z-index: 1000;
    min-width: 100%;
}

.custom-select.open .custom-select-dropdown {
    display: block;
}

.custom-select-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.custom-select-option:hover {
    background-color: #f0f0f0;
}

.custom-select-option:first-child {
    border-radius: 8px 8px 0 0;
}

.custom-select-option:last-child {
    border-radius: 0 0 8px 8px;
}

.custom-select-option .flag-icon {
    width: 18px;
    height: 12px;
    flex-shrink: 0;
}

.custom-select-option .location-text {
    color: #222140;
    font-weight: 500;
}

/* Flag SVGs */
.flag-icon.spain {
    background-image: url("data:image/svg+xml;utf8,<svg width='18' height='12' xmlns='http://www.w3.org/2000/svg'><rect width='18' height='12' fill='%23AA151B'/><rect y='3' width='18' height='6' fill='%23F1BF00'/></svg>");
}

.flag-icon.mexico {
    background-image: url("data:image/svg+xml;utf8,<svg width='18' height='12' xmlns='http://www.w3.org/2000/svg'><rect width='6' height='12' fill='%23006847'/><rect x='6' width='6' height='12' fill='white'/><rect x='12' width='6' height='12' fill='%23CE1126'/></svg>");
}

/* Year Selector Styles */
#year-input {
    padding: 0 30px 0 15px;
    font-size: 1em;
    font-weight: bold;
    color: #fff;
    background-color: #222140;
    border: none;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    text-align: center;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg fill='white' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 5px center;
    height: 38px;
    min-width: 90px;
    box-sizing: border-box;
}

#location-input:hover,
#year-input:hover {
    background-color: #1a1a33;
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

#location-input:focus,
#year-input:focus {
    outline: none;
    background-color: #1a1a33;
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

#location-input option,
#year-input option {
    background-color: #fff;
    color: #222140;
}


/* Settings button styles */
#settings-button {
    padding: 0; /* Remove padding */
    height: 38px;
    width: 38px;
    box-sizing: border-box;
    display: flex; /* Center the emoji */
    align-items: center;
    justify-content: center;
}

#back-button {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1000;
}

.button-squared {
    display: inline-block;
    padding: 10px;
    font-size: 1em;
    font-weight: bold;
    color: #fff;
    background-color: #222140; /* Base color */
    border: none;
    border-radius: 8px; /* Slightly rounded borders */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
}

.button-squared:hover {
    background-color: #1a1a33; /* Darker shade for hover */
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

.button-squared:active {
    background-color: #111122; /* Even darker shade for active */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Summary Section Styles */
.summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: 1fr auto;
    gap: 20px;
    margin-bottom: 20px;
    max-width: 100%;
    padding: 0 20px;
    box-sizing: border-box;
    transition: grid-template-columns 0.4s ease, grid-template-rows 0.4s ease, gap 0.4s ease;
}

/* Collapsed state - only show year */
.summary.collapsed {
    grid-template-columns: 1fr;
    grid-template-rows: 0fr 0fr;
    gap: 0;
}

.summary.collapsed .year-display {
    grid-column: 1 / -1;
}

/* Summary sections - use nested grid for smooth height animation */
.summary-section {
    min-width: 0;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 10px 20px;
    overflow: hidden;
    transition: opacity 0.4s ease, border-width 0.4s ease, padding 0.4s ease, margin 0.4s ease;
}

.summary.collapsed .summary-section {
    opacity: 0;
    padding: 0;
    margin: 0;
    border-width: 0;
    height: 0;
    min-height: 0;
}

.year-display {
    min-width: 0;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 10px 20px;
}

.summary-section h2,
.year-display h2 {
    font-variant: small-caps;
    font-size: 1.5em;
    margin: 5px 0 0 0;
    color: #222140;
}

.summary-section p,
.year-display p {
    padding-left: 15px;
    margin: 10px 0;
}

.summary-section p.warning-text,
.year-display p.warning-text {
    color: #dc3545;
    margin: 10px 0;
    font-weight: bold;
}

p.year {
    font-size: 5em;
    color: #222140;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    margin: 0 !important;
    padding: 0 !important;
    font-weight: bold;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* Calendar with Holidays - Main Grid */
.calendar-with-holidays {
    display: grid;
    grid-template-columns: 1fr 0;
    column-gap: 0;
    padding: 0 20px;
    box-sizing: border-box;
}

.calendar-with-holidays.holidays-visible {
    grid-template-columns: 4fr 1fr;
    column-gap: 20px;
}

/* Calendar Grid Styles */
.calendar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    justify-content: center;
}

.month {
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 10px;
    box-sizing: border-box;
    overflow: auto;
}

.month h2 {
    text-align: center;
    font-variant: small-caps;
    font-size: 1.5em;
    margin: 0 0 10px;
    color: #222140;
}

/* Calendar Table Styles */
table {
    border-collapse: collapse;
    width: 100%;
    table-layout: fixed; /* Ensures all cells have the same width */
}

th,
td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: center;
    width: calc(100% / 31); /* Ensures all cells have the same width */
}

th {
    background-color: #222140;
    color: white;
    font-weight: bold;
    text-align: center;
    padding: 8px 0;  /* Reduce horizontal padding */
    width: calc(100% / 7);  /* Force equal width for all header cells */
}

td {
    background-color: #f9f9f9;
}

td:nth-child(even) {
    background-color: #f1f1f1;
}

td:hover {
    background-color: #e2e6ea;
}

/* Calendar Special Day Styles */
td.festive {
    background-color: #ffcccc !important; /* Light reddish color */
}

td.festive:hover {
    background-color: #ff9999 !important; /* Darker reddish color */
}

/* National holidays - RED */
td.festive-national {
    background-color: #ffcccc !important; /* Red for national holidays */
}

td.festive-national:hover {
    background-color: #ff9999 !important; /* Darker red on hover */
}

td.festive-national-sunday {
    background-color: #ffe6e6 !important; /* Pale red for national holidays on Sunday */
}

td.festive-national-sunday:hover {
    background-color: #ffcccc !important; /* Slightly darker on hover */
}

/* Regional holidays - GREEN */
td.festive-regional {
    background-color: #ccffcc !important; /* Green for regional holidays */
}

td.festive-regional:hover {
    background-color: #99ff99 !important; /* Darker green on hover */
}

td.festive-regional-sunday {
    background-color: #e6ffe6 !important; /* Pale green for regional holidays on Sunday */
}

td.festive-regional-sunday:hover {
    background-color: #ccffcc !important; /* Slightly darker on hover */
}

/* Local holidays - BLUE */
td.festive-local {
    background-color: #cce5ff !important; /* Blue for local holidays */
}

td.festive-local:hover {
    background-color: #99ccff !important; /* Darker blue on hover */
}

td.festive-local-sunday {
    background-color: #e6f2ff !important; /* Pale blue for local holidays on Sunday */
}

td.festive-local-sunday:hover {
    background-color: #cce5ff !important; /* Slightly darker on hover */
}

/* Transferred from Sunday to Monday - special indicator */
td.festive-transferred {
    box-shadow: inset 0 0 0 2px rgba(34, 33, 64, 0.3) !important; /* Subtle inner shadow to indicate transfer */
}

/* Exceptional festivity - one-time special day */
td.festive-exceptional {
    box-shadow: inset 0 0 0 2px rgba(255, 140, 0, 0.5) !important; /* Orange border to indicate exceptional festivity */
}

td.festiveOnSaturday {
    background-color: #fcedbc !important; /* Light yellowish color */
}

td.festiveOnSaturday:hover {
    background-color: #f8d878 !important; /* Darker yellowish color */
}

td.festiveOnSunday {
    background-color: #c3fbc3 !important; /* Light greenish color - fallback */
}

td.festiveOnSunday:hover {
    background-color: #a3e6a3 !important; /* Darker greenish color - fallback */
}

/* Settings View Styles */
.form-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

label {
    display: block;
    margin: 10px 0 5px;
}

input,
textarea {
    width: calc(100% - 20px);
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .summary {
        grid-template-columns: 1fr;
    }

    .calendar-with-holidays {
        grid-template-columns: 1fr;
    }

    .calendar {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .month {
        width: 100%;
    }
}

/* Summary Content Styles */
.summary-content {
    display: grid;
    grid-template-columns: minmax(auto, max-content) minmax(auto, max-content) minmax(auto, max-content);
    gap: 8px 20px;
    align-items: baseline;
    padding: 10px 20px;

}

.summary-content b {
    text-align: left;
    white-space: nowrap;
}

.summary-content span {
    text-align: right;
    white-space: nowrap;
}

/* Holidays Panel (Static Column) */
.holidays-panel {
    display: none;
}

.calendar-with-holidays.holidays-visible .holidays-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 20px;
    height: auto;
}

.holidays-panel-header {
    padding: 15px 20px;
    border-bottom: 2px solid #222140;
    background-color: #f9f9f9;
}

.holidays-panel-header h2 {
    font-variant: small-caps;
    font-size: 1.3em;
    margin: 0;
    color: #222140;
}

/* Holiday List Styles */
.holiday-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    padding: 15px;
    flex: 1;
    min-height: 0;
}

.holiday-item {
    padding: 10px 15px;
    background-color: #f9f9f9;
    border-left: 4px solid #222140;
    border-radius: 4px;
    font-size: 0.85em;
    line-height: 1.5;
    transition: background-color 0.2s ease, border-left-color 0.2s ease;
    flex-shrink: 0;
}

.holiday-item:hover {
    background-color: #e8e8f0;
    border-left-color: #1a1a33;
}

/* Colored borders by holiday type */
.holiday-item.holiday-national {
    border-left-color: #ff6666;
    background-color: #fff5f5;
}

.holiday-item.holiday-national:hover {
    border-left-color: #ff3333;
    background-color: #ffe6e6;
}

.holiday-item.holiday-regional {
    border-left-color: #66ff66;
    background-color: #f5fff5;
}

.holiday-item.holiday-regional:hover {
    border-left-color: #33ff33;
    background-color: #e6ffe6;
}

.holiday-item.holiday-local {
    border-left-color: #6699ff;
    background-color: #f5f9ff;
}

.holiday-item.holiday-local:hover {
    border-left-color: #3366ff;
    background-color: #e6f2ff;
}

/* Special holiday markers - visual indicators */
.holiday-item.holiday-transferred {
    box-shadow: inset 0 0 0 2px rgba(34, 33, 64, 0.3);
}

.holiday-item.holiday-exceptional {
    box-shadow: inset 0 0 0 2px rgba(255, 140, 0, 0.5);
}

/* Holiday markers */
.holiday-weekend-marker {
    color: #dc3545;
    font-weight: bold;
    font-size: 0.85em;
}

.holiday-transfer-marker {
    color: #28a745;
    font-weight: bold;
    font-size: 0.85em;
}

.warning-text {
    color: #dc3545;
    font-weight: bold;
}

.notice {
    margin: 0 20px 20px;
    padding: 10px 20px;
    border: 1px solid #f0c36d;
    border-radius: 8px;
    background-color: #fff8e1;
    color: #7a5a00;
}

.notice:empty {
    display: none;
}

/* Footer Styles */
footer {
    text-align: center;
    padding: 20px;
    margin-top: 40px;
    color: #666;
    font-size: 0.9em;
    border-top: 1px solid #ddd;
}

footer a {
    color: #222140;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}