/* Simple Light Theme for Liturgical Calendar */

:root {
    --primary-color: #1a73e8;
    --primary-hover: #1557b0;
    --text-color: #202124;
    --text-light: #5f6368;
    --text-muted: #9aa0a6;
    --border-color: #dadce0;
    --surface-color: #f8f9fa;
    --background-color: #ffffff;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
    --radius: 8px;
    --transition: all 0.2s ease;
    --header-height: 60px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    overflow-x: hidden;
    border: none;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--background-color);
    color: var(--text-color);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
    border: none;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    position: relative;
}

/* Header */
.header {
    background: var(--background-color);
    border: none;
    padding: 0.5rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
    overflow: hidden;
    width: 100%;
    max-width: 100vw;
}

.header-content {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

.logo {
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-color);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.nav-controls {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
}

.month-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
    padding: 0.25rem 0.5rem;
    border-radius: 0;
    border: none;
    width: calc(14rem + 3em);
    flex-shrink: 0;
}

.nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border: none;
    background: transparent;
    color: var(--text-light);
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
    font-weight: 500;
}

.nav-btn:hover {
    background: transparent;
    color: var(--text-color);
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.current-month {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    min-width: 0;
    flex-shrink: 1;
    text-align: center;
    cursor: pointer;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    transition: var(--transition);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.current-month:hover {
    background: var(--surface-color);
}

/* Flatpickr Date Picker Styling */
.flatpickr-calendar {
    font-family: inherit;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    z-index: 10000 !important;
}

.flatpickr-calendar.open {
    z-index: 10000 !important;
}

/* Hide mobile date input */
.flatpickr-mobile {
    position: absolute !important;
    opacity: 0 !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    left: -9999px !important;
    visibility: hidden !important;
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange,
.flatpickr-day.selected.inRange,
.flatpickr-day.startRange.inRange,
.flatpickr-day.endRange.inRange {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.flatpickr-day:hover {
    background: var(--surface-color);
}

.flatpickr-day.today {
    border-color: var(--primary-color);
}

.flatpickr-day.today:hover {
    background: var(--primary-color);
    color: white;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
    min-width: 0;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-color);
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.75rem;
    font-weight: 500;
    font-family: inherit;
}

.action-btn:hover {
    background: var(--surface-color);
    border-color: var(--primary-color);
}

.action-btn.primary {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.action-btn.primary:hover {
    background: var(--primary-hover);
}

/* Main Container */
.container {
    width: 100%;
    margin: 0;
    padding: 0;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border: none;
    overflow: hidden;
}

/* Calendar */
.calendar-wrapper {
    background: var(--background-color);
    border-radius: 0;
    border: none;
    box-shadow: none;
    overflow: hidden;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--background-color);
    border-top: none;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    padding: 0.25rem 0;
}

.day-header {
    padding: 0.25rem 0.25rem;
    text-align: center;
    font-weight: 500;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(6, 1fr);
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    overflow: hidden;
}

.day-cell {
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    padding: 0.25rem;
    transition: var(--transition);
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--background-color);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.day-cell:nth-child(7n) {
    border-right: none;
}

.day-cell:nth-child(n+36) {
    border-bottom: none;
}

.day-cell:hover {
    background: var(--surface-color);
}

.day-cell.other-month {
    background: #f5f5f5;
    color: var(--text-muted);
}

/* Weekend days - Sunday (first column) and Saturday (last column) */
.calendar-grid .day-cell:not(.today):not(.other-month):nth-child(7n+1),
.calendar-grid .day-cell:not(.today):not(.other-month):nth-child(7n) {
    background: #f0f4f8;
}

.day-cell.today {
    background: var(--primary-color);
    color: white;
}

.day-cell.today:hover {
    background: var(--primary-hover);
}

.day-header-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.125rem;
}

.day-number {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.9rem;
    font-weight: 400;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    height: 1.9rem;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
    line-height: 1;
    letter-spacing: 0.02em;
    -webkit-text-stroke: 1px black;
    text-stroke: 1px black;
    text-shadow:
        2px 2px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 1px 0 #000;
}

.feast-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    overflow: hidden;
}

.feast-name {
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1;
    flex: 1;
    margin: 0;
    padding: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    /* Narrow font options - uncomment one to try:
    font-family: 'Arial Narrow', Arial, sans-serif;
    font-family: 'Roboto Condensed', sans-serif;
    font-family: 'Open Sans Condensed', sans-serif;
    font-family: 'PT Sans Narrow', sans-serif;
    */
    font-family: 'Roboto Condensed', sans-serif; /* Currently active */
}

.commemorations {
    font-size: 0.65rem;
    color: var(--text-muted);
    line-height: 1.2;
    margin-top: 0.125rem;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.today .commemorations {
    color: rgba(255, 255, 255, 0.75);
}

.feast-rank {
    font-size: 0.6rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: auto;
}

.today .feast-rank {
    color: rgba(255, 255, 255, 0.8);
}

.liturgical-indicator {
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

/* Liturgical Colors - applied as text color to day-number */
.liturgical-white .day-number { color: #ffffff; }
.liturgical-red .day-number { color: #dc2626; }
.liturgical-green .day-number { color: #16a34a; }
.liturgical-purple .day-number { color: #7c3aed; }
.liturgical-black .day-number { color: #374151; }
.liturgical-rose .day-number { color: #ec4899; }
.liturgical-gold .day-number { color: #ca8a04; }

/* Muted day-numbers for other-month days */
.other-month .day-number {
    color: #9ca3af !important;
    opacity: 0.6;
}

/* Special day indicators */
.special-indicators {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    gap: 0.25rem;
}

.special-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.holy-day { background: #eab308; }
.fast-day { background: #dc2626; }
.ember-day { background: #16a34a; }

/* Mobile View */
.mobile-view {
    display: none;
    flex: 1;
    overflow-y: auto;
}

.mobile-day {
    background: var(--background-color);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    margin-bottom: 1rem;
    padding: 1rem;
    transition: var(--transition);
    position: relative;
}

.mobile-day:hover {
    box-shadow: var(--shadow);
}

.mobile-day.today {
    background: var(--primary-color);
    color: white;
}

.mobile-day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.mobile-date {
    font-size: 4rem;
    font-weight: 700;
}

.mobile-day-name {
    font-size: 0.875rem;
    color: var(--text-light);
    font-weight: 500;
    text-transform: uppercase;
}

.mobile-feast {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    font-family: 'Roboto Condensed', sans-serif; /* Narrow font for mobile */
}

.mobile-commemorations {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.today .mobile-commemorations {
    color: rgba(255, 255, 255, 0.75);
}

.mobile-rank {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-style: italic;
}

.today .mobile-day-name,
.today .mobile-rank {
    color: rgba(255, 255, 255, 0.8);
}

/* Loading States */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.loading-spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 1.125rem;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.loading-subtext {
    font-size: 0.875rem;
    color: var(--text-light);
}

/* Error States */
.error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.error-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.error-message {
    color: var(--text-light);
    margin-bottom: 2rem;
    max-width: 32rem;
}

/* Modal (Native Dialog) */
dialog.modal {
    position: fixed;
    inset: 0;
    margin: auto;
    padding: 0;
    border: none;
    background: var(--background-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    width: auto;
    height: auto;
}

/* Native dialog backdrop */
dialog.modal::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

/* Dialog animation */
dialog.modal {
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

dialog.modal[open] {
    opacity: 1;
    transform: scale(1);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    flex: 1;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: var(--transition);
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--surface-color);
    color: var(--text-color);
}

.modal-content {
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

/* Detail Modal */
.detail-section {
    margin-bottom: 1.5rem;
}

.detail-section h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: start;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f3f4f6;
}

.detail-item:last-child {
    border-bottom: none;
}

.detail-label {
    font-weight: 500;
    color: var(--text-light);
    min-width: 6rem;
}

.detail-value {
    color: var(--text-color);
    text-align: right;
    flex: 1;
}


/* Responsive Design */
@media (max-width: 768px) {
    .header {
        padding: 0.25rem 0;
        border-bottom: 1px solid var(--border-color);
        overflow: hidden;
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
    }

    .header-content {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0 0.5rem;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
        box-sizing: border-box;
    }

    .logo {
        font-size: 0.75rem;
        width: 100%;
        text-align: center;
        justify-content: center;
    }

    .nav-controls {
        position: relative;
        left: auto;
        transform: none;
        order: -1;
        width: 100%;
        max-width: 100%;
        justify-content: center;
        overflow: hidden;
        box-sizing: border-box;
    }

    .month-nav {
        flex: 1;
        width: 100%;
        max-width: 100%;
        justify-content: space-between;
        position: relative;
        min-width: 0;
        gap: 0.25rem;
        padding: 0.25rem 0.5rem;
        box-sizing: border-box;
    }

    .current-month {
        font-size: 0.85rem;
        min-width: 0;
        flex: 1;
        max-width: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        padding: 0.25rem 0.5rem;
    }

    .nav-btn {
        width: 1.5rem;
        height: 1.5rem;
        font-size: 0.875rem;
        flex-shrink: 0;
    }

    .header-actions {
        width: 100%;
        max-width: 100%;
        justify-content: center;
        flex-wrap: nowrap;
        overflow: hidden;
        box-sizing: border-box;
    }

    .container {
        padding: 0;
    }

    .calendar-wrapper {
        display: none;
    }

    .day-cell {
        border-right: none;
        border-bottom: none;
    }

    .mobile-view {
        display: flex;
        flex-direction: column;
        padding: 0;
    }

    .mobile-day {
        margin-bottom: 0;
        border-radius: 0;
        min-height: 25vh;
        height: 25vh;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }


    .modal {
        width: 95vw;
        margin: 1rem;
    }

    .modal-content {
        max-height: 70vh;
    }

    .pdf-options {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 0.2rem 0;
    }

    .header-content {
        padding: 0 0.25rem;
        gap: 0.25rem;
    }

    .logo {
        font-size: 0.7rem;
    }

    .current-month {
        font-size: 0.8rem;
        padding: 0.2rem 0.4rem;
    }

    .nav-btn {
        width: 1.25rem;
        height: 1.25rem;
        font-size: 0.75rem;
    }

    .action-btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.7rem;
    }

    .mobile-day {
        padding: 0.75rem;
        margin-bottom: 0;
        border-radius: 0;
        min-height: 25vh;
        height: 25vh;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .modal-header,
    .modal-content {
        padding: 1rem;
    }

    .day-modal:not(.day-modal-drawer) {
        max-width: 90vw;
        min-width: 250px;
    }

    .day-modal-header {
        padding: 0.5rem 0.75rem;
    }

    .day-modal-content {
        padding: 0.5rem 0.75rem;
    }

    .day-modal-drawer .day-modal-content {
        padding-top: 0.5rem;
    }
}

/* Remove focus outlines */
*:focus {
    outline: none;
}

/* Day Modal/Tooltip */
.day-modal {
    position: fixed;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 320px;
    min-width: 280px;
    z-index: 10000;
    animation: modalFadeIn 0.2s ease;
}

/* Mobile Drawer Styles */
.day-modal-drawer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-width: 100%;
    min-width: 100%;
    width: 100%;
    border-radius: var(--radius) var(--radius) 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    animation: none;
}

.day-modal-drawer.drawer-open {
    transform: translateY(0);
}

.day-modal-drawer.drawer-closing {
    transform: translateY(100%);
}

.day-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.day-modal-backdrop.backdrop-visible {
    opacity: 1;
    pointer-events: auto;
}

.day-modal-drag-handle {
    width: 40px;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    margin: 8px auto;
    cursor: grab;
    flex-shrink: 0;
}

.day-modal-drag-handle:active {
    cursor: grabbing;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.day-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-color);
    border-radius: var(--radius) var(--radius) 0 0;
    flex-shrink: 0;
    touch-action: none;
}

.day-modal-drawer .day-modal-header {
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.day-modal-drawer .day-modal-header:active {
    cursor: grabbing;
}

.day-modal-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-color);
    flex: 1;
    line-height: 1.3;
    font-family: 'Roboto Condensed', sans-serif;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.day-modal-color-circle {
    width: 1em;
    height: 1em;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

.day-modal-color-circle.liturgical-white { background-color: #ffffff; border: 1px solid var(--border-color); }
.day-modal-color-circle.liturgical-red { background-color: #dc2626; }
.day-modal-color-circle.liturgical-green { background-color: #16a34a; }
.day-modal-color-circle.liturgical-purple { background-color: #7c3aed; }
.day-modal-color-circle.liturgical-black { background-color: #374151; }
.day-modal-color-circle.liturgical-rose { background-color: #ec4899; }
.day-modal-color-circle.liturgical-gold { background-color: #ca8a04; }

.day-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: var(--transition);
    flex-shrink: 0;
    margin-left: 0.5rem;
    line-height: 1;
}

.day-modal-close:hover {
    background: var(--border-color);
    color: var(--text-color);
}

.day-modal-content {
    padding: 0.75rem 1rem;
    max-height: 60vh;
    overflow-y: auto;
}

.day-modal-drawer .day-modal-content {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    flex: 1;
    min-height: 0;
    padding-top: 0.5rem;
}

.day-modal-section {
    margin-bottom: 0.75rem;
}

.day-modal-section:last-child {
    margin-bottom: 0;
}

.day-modal-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.day-modal-value {
    font-size: 0.85rem;
    color: var(--text-color);
    line-height: 1.4;
    word-wrap: break-word;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .day-modal {
        animation: none;
    }
}