/* ===== CSS Reset & Variables ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --background-color: #ecf0f1;
    --card-background: #ffffff;
    --text-color: #2c3e50;
    --text-light: #5d6d7e;
    --border-radius: 12px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --focus-color: #f39c12;
    --focus-outline: 3px solid var(--focus-color);
}

/* ===== Accessibility ===== */
.skip-link {
    position: absolute;
    top: -100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--focus-color);
    color: var(--primary-color);
    padding: 0.75rem 1.5rem;
    border-radius: 0 0 8px 8px;
    font-weight: 600;
    text-decoration: none;
    z-index: 1000;
    transition: top 0.3s ease;
}

.skip-link:focus { top: 0; outline: none; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

*:focus { outline: var(--focus-outline); outline-offset: 2px; }
*:focus:not(:focus-visible) { outline: none; }
*:focus-visible { outline: var(--focus-outline); outline-offset: 2px; }

/* ===== Base Styles ===== */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    font-size: 100%;
}

/* ===== Header ===== */
header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    flex: 1;
    min-width: 200px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===== Icon Buttons ===== */
.icon-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.icon-btn:hover { background: rgba(255, 255, 255, 0.25); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.enabled { background: var(--success-color); }
.icon-btn.denied { opacity: 0.5; cursor: not-allowed; }

/* ===== Search ===== */
.search-container {
    position: relative;
}

.search-input {
    padding: 0.5rem 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 0.9rem;
    width: 200px;
    transition: all 0.2s;
}

.search-input::placeholder { color: rgba(255, 255, 255, 0.7); }
.search-input:focus {
    background: white;
    color: var(--text-color);
    border-color: white;
    outline: none;
    width: 250px;
}

.search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
    max-height: 300px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.search-results.show { opacity: 1; visibility: visible; }

.search-result {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    color: var(--text-color);
}

.search-result:hover { background: #f8f9fa; }
.search-result:last-child { border-bottom: none; }
.search-icon { font-size: 1.2rem; }
.search-info strong { display: block; font-size: 0.9rem; }
.search-info span { font-size: 0.8rem; color: var(--text-light); }
.search-no-results { padding: 1rem; text-align: center; color: var(--text-light); }

/* ===== Language Selector ===== */
.language-selector { position: relative; }

.language-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.language-btn:hover { background: rgba(255, 255, 255, 0.25); }
.globe-icon { width: 20px; height: 20px; }
.chevron-icon { width: 16px; height: 16px; transition: transform 0.2s; }
.language-btn[aria-expanded="true"] .chevron-icon { transform: rotate(180deg); }

.language-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    list-style: none;
    min-width: 150px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s;
    z-index: 100;
    overflow: hidden;
}

.language-dropdown.open { opacity: 1; visibility: visible; transform: translateY(0); }

.language-dropdown li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    color: var(--text-color);
    transition: background 0.15s;
}

.language-dropdown li:hover { background: #f0f4f8; }
.language-dropdown li[aria-selected="true"] { background: #e8f4fc; color: var(--secondary-color); }

.lang-code {
    font-weight: 600;
    font-size: 0.85rem;
    background: #e0e0e0;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

.language-dropdown li[aria-selected="true"] .lang-code { background: var(--secondary-color); color: white; }

/* ===== Main Content ===== */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ===== Card ===== */
.card {
    background: var(--card-background);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.card h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid var(--secondary-color);
    font-size: 1.2rem;
}

/* ===== Countdown ===== */
.countdown-card {
    background: linear-gradient(135deg, var(--secondary-color), #2980b9);
    color: white;
    text-align: center;
}

.countdown-card h2 { border-color: rgba(255,255,255,0.3); color: white; }

.countdown-header h3 { font-size: 1.1rem; margin-bottom: 1rem; }

.countdown-timer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.countdown-unit { text-align: center; min-width: 70px; }
.countdown-value {
    font-size: 2.5rem;
    font-weight: 700;
    display: block;
    line-height: 1;
}
.countdown-label { font-size: 0.75rem; text-transform: uppercase; opacity: 0.9; }
.countdown-separator { font-size: 2rem; font-weight: 300; opacity: 0.5; }

.countdown-vacation {
    padding: 1rem;
}
.countdown-icon { font-size: 3rem; margin-bottom: 0.5rem; }
.countdown-vacation h3 { font-size: 1.3rem; }
.countdown-vacation p { opacity: 0.9; }

/* ===== Legend ===== */
.legend-bar {
    background: white;
    border-radius: var(--border-radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem 2rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.legend-color.vacation { background: var(--accent-color); }
.legend-color.holiday { background: var(--warning-color); }
.legend-color.today { background: var(--secondary-color); border: 2px solid var(--primary-color); }
.legend-color.trimester-end { background: #9b59b6; }

/* ===== Timeline ===== */
.timeline-container {
    position: relative;
    padding: 2rem 0 1rem;
}

.timeline-track {
    position: relative;
    height: 40px;
    background: #e0e0e0;
    border-radius: 20px;
    overflow: hidden;
}

.timeline-vacation {
    position: absolute;
    top: 0;
    height: 100%;
    opacity: 0.9;
    border-radius: 4px;
}

.timeline-holiday {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: var(--warning-color);
    border-radius: 50%;
    border: 2px solid white;
    z-index: 2;
}

.timeline-today {
    position: absolute;
    top: -8px;
    bottom: -8px;
    width: 3px;
    background: var(--primary-color);
    z-index: 3;
}

.timeline-today-marker {
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 12px;
    background: var(--primary-color);
    border-radius: 50%;
    border: 2px solid white;
}

.timeline-months {
    position: relative;
    height: 24px;
    margin-top: 0.5rem;
}

.timeline-month {
    position: absolute;
    font-size: 0.7rem;
    color: var(--text-light);
    transform: translateX(-50%);
}

/* ===== Calendar ===== */
.calendar-container {
    max-width: 400px;
    margin: 0 auto;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.calendar-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.calendar-nav {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    color: var(--primary-color);
    transition: background 0.2s;
}

.calendar-nav:hover { background: #f0f0f0; }
.calendar-nav svg { width: 20px; height: 20px; }

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 0.5rem;
}

.weekday {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-light);
    padding: 0.5rem 0;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    border-radius: 8px;
    cursor: default;
    transition: all 0.2s;
}

.calendar-day.empty { background: transparent; }
.calendar-day.weekend { color: var(--text-light); }
.calendar-day.today {
    background: var(--secondary-color);
    color: white;
    font-weight: 600;
}
.calendar-day.vacation { background: rgba(231, 76, 60, 0.2); }
.calendar-day.holiday { background: var(--warning-color); color: white; font-weight: 600; }
.calendar-day.trimester-end { border: 2px solid #9b59b6; }
.calendar-day.vacation.holiday { background: var(--warning-color); }

/* ===== Vacation List ===== */
.vacation-list { list-style: none; }

.vacation-list li {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    border-left: 4px solid var(--secondary-color);
    margin-bottom: 1rem;
    background: #f8f9fa;
    border-radius: 0 8px 8px 0;
    transition: all 0.2s;
}

.vacation-list li:hover { transform: translateX(5px); box-shadow: var(--shadow); }
.vacation-list .date-range { font-weight: 600; color: var(--primary-color); margin-bottom: 0.25rem; }
.vacation-list .label { color: var(--text-light); font-size: 0.9rem; }

.vacation-current { border-left-color: var(--success-color) !important; background: #d4edda !important; }
.vacation-upcoming { border-left-color: var(--warning-color) !important; }
.holiday-upcoming { background: #d4edda !important; }

/* ===== Table ===== */
table { width: 100%; border-collapse: collapse; }
thead { background: var(--primary-color); color: white; }
th, td { padding: 1rem; text-align: left; }
th { font-weight: 600; }
tbody tr { border-bottom: 1px solid #e0e0e0; transition: background 0.2s; }
tbody tr:hover { background: #f8f9fa; }
tbody tr:last-child { border-bottom: none; }
.day { color: var(--text-light); font-size: 0.85rem; }

/* ===== Trimesters ===== */
.trimestre-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.trimestre {
    background: linear-gradient(135deg, var(--secondary-color), #2980b9);
    color: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    text-align: center;
    transition: transform 0.2s;
}

.trimestre:hover { transform: translateY(-5px); }
.trimestre h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.trimestre p { font-size: 0.9rem; opacity: 0.9; }

.note {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 1rem;
    border-radius: 0 8px 8px 0;
    color: #664d03;
}

/* ===== Important Dates ===== */
.dates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.date-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    transition: all 0.2s;
}

.date-item:hover { background: #e9ecef; transform: translateX(5px); }
.date-item.highlight { background: #d4edda; border-left: 4px solid var(--success-color); }
.date-icon { font-size: 1.5rem; }
.date-info strong { display: block; margin-bottom: 0.25rem; }
.date-info span { font-size: 0.85rem; color: var(--text-light); }

/* ===== School Info ===== */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.info-item {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.info-icon {
    width: 24px;
    height: 24px;
    color: var(--secondary-color);
    flex-shrink: 0;
    margin-top: 2px;
}

.info-item strong { display: block; margin-bottom: 0.25rem; }
.info-item p { font-size: 0.9rem; color: var(--text-light); margin: 0; }

.edit-note {
    margin-top: 1.5rem;
    padding: 0.75rem;
    background: #e8f4fc;
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--secondary-color);
    text-align: center;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--primary-color);
    color: white;
    padding: 1rem 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s;
}

.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast-success { background: var(--success-color); }
.toast-error { background: var(--accent-color); }

/* ===== Install Banner ===== */
.install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 1rem;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    z-index: 1000;
    transform: translateY(100%);
    transition: transform 0.3s;
}

.install-banner.show { transform: translateY(0); }

.install-content {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.install-icon {
    width: 48px;
    height: 48px;
    background: var(--secondary-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.install-icon svg { width: 24px; height: 24px; }
.install-text { flex: 1; }
.install-text strong { display: block; margin-bottom: 0.25rem; }
.install-text p { font-size: 0.85rem; color: var(--text-light); margin: 0; }
.ios-hint { font-style: italic; margin-top: 0.25rem !important; }

.install-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.btn-install {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-install:hover { background: #2980b9; }

.btn-dismiss {
    background: none;
    border: none;
    color: var(--text-light);
    padding: 0.75rem;
    cursor: pointer;
}

/* ===== Footer ===== */
footer {
    background: var(--primary-color);
    color: white;
    text-align: center;
    padding: 1.5rem;
    margin-top: 2rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .header-content { flex-direction: column; text-align: center; }
    header h1 { font-size: 1.2rem; order: 1; }
    .header-actions { order: 0; width: 100%; justify-content: flex-end; flex-wrap: wrap; }
    .search-input { width: 150px; }
    .search-input:focus { width: 180px; }

    .countdown-value { font-size: 1.8rem; }
    .countdown-unit { min-width: 50px; }

    table, thead, tbody, th, td, tr { display: block; }
    thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
    tbody tr { margin-bottom: 1rem; border: 1px solid #e0e0e0; border-radius: 8px; padding: 0.5rem; }
    td { padding: 0.5rem 1rem; border-bottom: 1px solid #f0f0f0; }
    td:first-child { font-weight: 600; background: #f8f9fa; border-radius: 6px 6px 0 0; }
    td:last-child { border-bottom: none; color: var(--secondary-color); font-weight: 500; }

    .install-content { flex-direction: column; text-align: center; }
    .install-actions { width: 100%; justify-content: center; }
}

@media (max-width: 480px) {
    main { padding: 1rem 0.75rem; }
    .card { padding: 1rem; }
    .card h2 { font-size: 1rem; }
    .search-container { display: none; }
    .countdown-timer { gap: 0.25rem; }
    .countdown-value { font-size: 1.5rem; }
    .countdown-separator { font-size: 1.5rem; }
    .timeline-month { font-size: 0.6rem; }
}

/* ===== Animations ===== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.card { animation: fadeInUp 0.5s ease forwards; }
.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4) { animation-delay: 0.2s; }

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== High Contrast ===== */
@media (prefers-contrast: high) {
    .card { border: 2px solid var(--primary-color); }
    tbody tr { border-bottom: 2px solid #333; }
}

/* ===== Print ===== */
@media print {
    .skip-link, .language-selector, .header-actions, .install-banner, .toast { display: none; }
    header { background: none; color: black; border-bottom: 2px solid black; }
    .card { box-shadow: none; border: 1px solid #ccc; page-break-inside: avoid; }
    .trimestre { background: none; color: black; border: 1px solid #333; }
    footer { background: none; color: black; border-top: 1px solid black; }
}
