/* Tamil Calendar - COMPLETE CSS with All Fixes */

/* Import Tamil font */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Tamil:wght@400;600;700&display=swap');

/* Base styles */
.tamil-calendar-wrapper {
    font-family: 'Noto Sans Tamil', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    max-width: 100%;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Header */
.tc-header,
.calendar-header,
.tamil-calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    background: linear-gradient(135deg, #c41e3a 0%, #e91e63 100%);
    color: #ffffff;
    flex-wrap: wrap;
}

.tc-title,
.month-year-selector {
    flex: 1;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
}

.tc-gregorian-month {
    display: block;
    font-size: 16px;
    margin-bottom: 5px;
}

.tc-separator {
    display: none;
}

.tc-tamil-months,
.tc-tamil-year {
    display: block;
    font-size: 13px;
    opacity: 0.95;
}

/* Navigation buttons */
.tc-nav-prev,
.tc-nav-next,
.tc-today,
.calendar-nav,
.prev-month,
.next-month,
.today-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 18px;
}

.tc-nav-prev:hover,
.tc-nav-next:hover,
.tc-today:hover,
.calendar-nav:hover,
.today-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

/* Tamil Month Bar */
.tamil-month-transitions {
    background: #f8f9fa;
    padding: 10px 15px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 13px;
}

.tamil-month-bar-title {
    font-weight: 600;
    color: #666;
    margin-right: 10px;
}

.tamil-month-period {
    background: #fff;
    padding: 5px 12px;
    border-radius: 15px;
    border: 1px solid #c41e3a;
}

.tamil-month-name {
    font-weight: 600;
    color: #c41e3a;
}

.tamil-month-dates {
    font-size: 11px;
    color: #666;
    margin-left: 5px;
}

/* Weekdays */
.tc-weekdays,
.tamil-calendar-grid thead {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
}

.tamil-calendar-grid thead {
    display: table-header-group;
}

.tc-weekday,
.tamil-calendar-grid thead th {
    padding: 10px 5px;
    text-align: center;
    font-weight: 600;
    font-size: 12px;
    color: #666;
    background: #f5f5f5;
}

/* Calendar grid */
.tc-dates-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: #e0e0e0;
    padding: 1px;
}

.tamil-calendar-grid {
    width: 100%;
    border-collapse: separate;
    border-spacing: 1px;
    background: #e0e0e0;
}

.tamil-calendar-grid tbody {
    background: #ffffff;
}

.tamil-calendar-grid tbody td {
    background: #ffffff;
    padding: 0;
    vertical-align: top;
    position: relative;
}

/* Day cell - ALL STRUCTURES */
.tc-day,
.calendar-day {
    background: #ffffff;
    min-height: 60px;
    padding: 4px;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
    display: block;
    width: 100%;
}

.tc-day:hover:not(.tc-day-empty):not(.empty-day),
.calendar-day:hover:not(.empty-day) {
    background: #f8f8f8;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 1;
}

/* Empty days */
.tc-day-empty,
.empty-day {
    background: #fafafa;
    cursor: default;
}

.tc-day-empty:hover,
.empty-day:hover {
    background: #fafafa;
    box-shadow: none;
}

/* Gregorian date */
.tc-day-gregorian,
.day-number {
    position: absolute;
    top: 4px;
    left: 6px;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

/* Tamil date */
.tc-day-tamil,
.tamil-date-display {
    position: absolute;
    bottom: 4px;
    right: 6px;
    text-align: right;
    color: #c41e3a;
}

.tc-tamil-month-label,
.tamil-month-english,
.tamil-month-tamil,
.tamil-month-label {
    display: block;
    font-size: 10px;
    color: #666;
    margin-bottom: 2px;
}

.tc-tamil-date-number,
.tamil-day-number {
    font-size: 14px;
    font-weight: 500;
    display: block;
}

/* Tamil month start indicator */
.tamil-month-start,
.tc-day.tamil-month-start {
    border-top: 3px solid #c41e3a;
}

.tamil-month-indicator {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: #c41e3a;
    color: white;
    font-size: 8px;
    text-align: center;
    padding: 1px;
}

/* Today highlight */
.tc-day-today,
.calendar-day.today {
    background: linear-gradient(135deg, #fff3cd 0%, #ffe8a1 100%) !important;
    border: 2px solid #ffc107 !important;
}

/* Weekend */
.tc-day-weekend,
.calendar-day.weekend {
    background: #fafafa;
}

/* Holiday (legacy rule — kept for backwards compatibility) */
.calendar-day.holiday,
.tc-day.holiday {
    background: #d4edda;
}

/* Has events */
.tc-day-has-events,
.calendar-day.has-events {
    /* Additional styling if needed */
}

/* ==========================================
   EVENT ICONS - CRITICAL FIX
   ========================================== */

/* Container for events - MUST BE VISIBLE */
.day-events,
.tc-events-indicator {
    position: absolute;
    top: 24px;
    right: 4px;
    display: flex !important;
    flex-direction: row;
    gap: 2px;
    flex-wrap: wrap;
    max-width: 50%;
    justify-content: flex-end;
    align-items: flex-start;
    z-index: 10;
}

/* Individual event wrapper */
.event-indicator,
.tc-event-wrapper {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    cursor: help;
    transition: transform 0.2s ease;
}

.event-indicator:hover,
.tc-event-wrapper:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
}

/* The actual emoji/icon - CRITICAL */
.event-icon,
.tc-event-emoji {
    display: inline-block !important;
    font-size: 13px !important;
    line-height: 1 !important;
    font-style: normal !important;
    font-weight: normal !important;
    visibility: visible !important;
    opacity: 1 !important;
    /* Force emoji font rendering */
    font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji', sans-serif !important;
    text-rendering: optimizeLegibility !important;
    -webkit-font-smoothing: antialiased !important;
}

/* More events indicator */
.more-events,
.tc-more-events {
    display: inline-flex;
    font-size: 9px;
    background: #e0e0e0;
    padding: 2px 5px;
    border-radius: 10px;
    color: #666;
    font-weight: 600;
    line-height: 1.2;
    align-items: center;
}

/* Footer */
.tc-footer {
    padding: 10px;
    background: #f5f5f5;
    border-top: 1px solid #e0e0e0;
}

.tc-legend,
.calendar-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.tc-legend-item,
.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #666;
}

.tc-legend-color,
.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.tc-color-festival,
.legend-icon {
    background: #fff3cd;
}

.tc-color-holiday {
    background: #d4edda;
}

.tc-color-auspicious {
    background: #cce5ff;
}

.moon-icon {
    font-size: 14px;
}

.legend-toggle {
    cursor: pointer;
    background: none;
    border: 1px solid #ddd;
    padding: 5px 10px;
    border-radius: 4px;
}

.legend-content {
    margin-top: 10px;
}

/* ==========================================
   MODAL - CRITICAL SCROLLING FIX
   ========================================== */

/* Modal container - MUST ALLOW SCROLLING */
.tc-modal,
.tamil-calendar-daily-panel {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    /* CRITICAL for mobile scrolling */
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch !important;
    animation: fadeIn 0.3s ease;
}

/* Prevent body scroll when modal open */
body.modal-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Modal inner wrapper */
.tc-modal-inner {
    min-height: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px 0;
}

/* Modal content box */
.tc-modal-content {
    background-color: #ffffff;
    width: 90%;
    max-width: 600px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    position: relative;
    margin: 0 auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Close button */
.tc-modal-close,
.close-daily-panel {
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    color: #fff;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 10;
    padding: 5px 10px;
    line-height: 1;
}

.tc-modal-close:hover,
.close-daily-panel:hover {
    color: #ffcccc;
}

/* Modal header */
.tc-modal-header,
.daily-header {
    background: linear-gradient(135deg, #c41e3a 0%, #e91e63 100%);
    color: #ffffff;
    padding: 20px;
    border-radius: 8px 8px 0 0;
}

.tc-modal-header h3,
.daily-panel-title,
.daily-header h2 {
    margin: 0;
    padding-right: 40px;
    font-size: 18px;
}

.daily-header .tamil-date {
    font-size: 14px;
    margin-top: 5px;
    opacity: 0.95;
}

.tamil-date-additional {
    font-size: 12px;
    margin-top: 5px;
    opacity: 0.9;
}

/* Modal body */
.tc-modal-body,
.daily-panel-content,
.daily-content {
    padding: 20px;
}

.tc-modal-body h4,
.daily-panel-content h4,
.daily-content h3,
.daily-content h4 {
    color: #c41e3a;
    margin: 15px 0 10px 0;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 8px;
    font-size: 16px;
}

.tc-modal-body table,
.daily-panel-content table,
.daily-content table {
    width: 100%;
    margin-top: 10px;
    border-collapse: collapse;
}

.tc-modal-body table td,
.daily-panel-content table td,
.daily-content table td {
    padding: 8px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: top;
}

.tc-modal-body table td:first-child,
.daily-panel-content table td:first-child,
.daily-content table td:first-child {
    font-weight: 600;
    width: 40%;
    color: #555;
}

.tc-modal-body ul,
.daily-panel-content ul {
    list-style: none;
    padding: 0;
    margin: 10px 0;
}

.tc-modal-body ul li,
.daily-panel-content ul li {
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

/* Daily view sections */
.panchang-section,
.timings-section,
.events-section,
.calendar-sheet-section {
    margin: 20px 0;
}

.panchang-grid,
.timings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.panchang-item,
.timing-item {
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
}

.panchang-label,
.timing-label {
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
}

.panchang-value,
.timing-value {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.timing-item.inauspicious {
    background: #fff3cd;
    border-left: 3px solid #ffc107;
}

.timing-icon {
    font-size: 20px;
    margin-right: 8px;
}

/* Events list */
.events-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.event-card {
    display: flex;
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #c41e3a;
}

.event-card.holiday-event {
    background: #fff8e1;
    border-left-color: #ff9800;
}

.event-icon-large {
    font-size: 32px;
    line-height: 1;
}

.event-details {
    flex: 1;
}

.event-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0 0 5px 0;
}

.holiday-badge {
    display: inline-block;
    background: #ff9800;
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
}

.event-title-tamil {
    font-size: 14px;
    color: #666;
    margin: 5px 0;
}

.event-description {
    font-size: 13px;
    color: #666;
    margin: 8px 0;
}

.event-meta {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    font-size: 12px;
}

.event-type {
    color: #666;
    text-transform: capitalize;
}

.event-importance {
    color: #ffc107;
}

.no-events {
    text-align: center;
    padding: 40px;
    color: #999;
}

/* Calendar sheet image */
.calendar-sheet-image-wrapper {
    margin-top: 10px;
    text-align: center;
}

.calendar-sheet-image {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.calendar-sheet-not-found {
    padding: 40px;
    background: #f8f9fa;
    border-radius: 4px;
    color: #999;
    text-align: center;
}

/* Loading state */
.tc-loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.tc-loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-left: 10px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #c41e3a;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error state */
.tc-error,
.tc-no-data {
    text-align: center;
    padding: 40px;
    color: #dc3545;
}

.tc-no-data {
    color: #666;
}

/* Widgets */
.tamil-calendar-today-widget,
.tamil-calendar-upcoming-widget {
    background: #fff;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.widget-header {
    border-bottom: 2px solid #c41e3a;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.widget-header h3 {
    margin: 0;
    color: #c41e3a;
}

.today-date {
    font-size: 14px;
    color: #666;
    margin-top: 5px;
}

.widget-tamil-date {
    font-size: 24px;
    font-weight: 600;
    color: #c41e3a;
    text-align: center;
    padding: 15px 0;
}

.tamil-year-small {
    font-size: 14px;
    color: #666;
    margin-top: 5px;
}

.widget-events {
    margin-top: 15px;
}

.widget-event-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.widget-event-icon {
    font-size: 18px;
}

.widget-event-title {
    flex: 1;
    font-size: 14px;
}

.view-full-calendar {
    display: block;
    text-align: center;
    margin-top: 15px;
    color: #c41e3a;
    text-decoration: none;
    font-weight: 600;
}

/* Upcoming events widget */
.upcoming-events-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.upcoming-event-item {
    display: flex;
    gap: 15px;
    align-items: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
}

.event-date-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    padding: 10px;
    background: #c41e3a;
    color: white;
    border-radius: 8px;
    text-align: center;
}

.date-day {
    font-size: 24px;
    font-weight: bold;
    line-height: 1;
}

.date-month {
    font-size: 12px;
    margin-top: 2px;
}

.tamil-date-small {
    font-size: 10px;
    margin-top: 5px;
    opacity: 0.9;
}

.event-info {
    flex: 1;
}

.event-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 5px;
}

.event-emoji {
    margin-right: 5px;
}

.event-days-until {
    font-size: 12px;
    color: #666;
}

/* Tamil date widget */
.tamil-date-widget,
.tamil-date-simple,
.tamil-date-with-year {
    display: inline-block;
}

.tamil-day-large {
    font-size: 48px;
    font-weight: bold;
    color: #c41e3a;
}

.tamil-month-large {
    font-size: 24px;
    color: #666;
}

.tamil-year-info {
    font-size: 14px;
    color: #999;
    margin-top: 10px;
}

.tamil-additional-info {
    display: flex;
    gap: 15px;
    margin-top: 10px;
    font-size: 12px;
}

.tamil-paksha,
.tamil-zodiac {
    color: #666;
}

/* ==========================================
   MOBILE (up to 576px)
   ========================================== */
@media (max-width: 576px) {
    .tc-weekday,
    .tamil-calendar-grid thead th {
        font-size: 11px;
        padding: 8px 2px;
    }
    
    .tamil-month-transitions {
        font-size: 11px;
        padding: 8px 10px;
    }
    
    .day-events,
    .tc-events-indicator {
        top: 22px;
        right: 2px;
        gap: 1px;
        max-width: 55%;
    }
    
    .event-indicator,
    .tc-event-wrapper {
        min-width: 16px;
        height: 16px;
    }
    
    .event-icon,
    .tc-event-emoji {
        font-size: 11px !important;
    }
    
    .more-events,
    .tc-more-events {
        font-size: 8px;
        padding: 1px 3px;
    }
    
    /* CRITICAL: Mobile modal scrolling */
    .tc-modal,
    .tamil-calendar-daily-panel {
        padding: 0 !important;
    }
    
    .tc-modal-inner {
        padding: 10px 0;
        min-height: 100vh;
    }
    
    .tc-modal-content {
        width: 95%;
        margin: 10px auto;
    }
    
    .tc-modal-header,
    .daily-header {
        padding: 15px;
    }
    
    .tc-modal-header h3,
    .daily-header h2 {
        font-size: 16px;
    }
    
    .tc-modal-close,
    .close-daily-panel {
        font-size: 24px;
        right: 10px;
        top: 10px;
    }
    
    .tc-modal-body,
    .daily-panel-content,
    .daily-content {
        padding: 15px;
    }
    
    .panchang-grid,
    .timings-grid {
        grid-template-columns: 1fr;
    }
    
    .event-card {
        flex-direction: column;
        text-align: center;
    }
    
    .event-icon-large {
        font-size: 40px;
    }
}

/* ==========================================
   TABLET (577px - 768px)
   ========================================== */
@media (min-width: 577px) and (max-width: 768px) {
    .tc-header,
    .calendar-header {
        flex-wrap: nowrap;
    }
    
    .tc-title {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
    }
    
    .tc-gregorian-month,
    .tc-tamil-months,
    .tc-tamil-year {
        display: inline;
        margin: 0;
    }
    
    .tc-separator {
        display: inline;
        margin: 0 8px;
    }
    
    .tc-day,
    .calendar-day {
        min-height: 70px;
    }
    
    .tc-day-gregorian,
    .day-number {
        font-size: 18px;
    }
    
    .tc-tamil-date-number,
    .tamil-day-number {
        font-size: 15px;
    }
    
    .event-indicator,
    .tc-event-wrapper {
        min-width: 18px;
        height: 18px;
    }
    
    .event-icon,
    .tc-event-emoji {
        font-size: 13px !important;
    }
    
    .tc-modal-inner {
        padding: 15px 0;
    }
    
    .tc-modal-content {
        width: 80%;
    }
}

/* ==========================================
   DESKTOP (769px+)
   ========================================== */
@media (min-width: 769px) {
    .tamil-calendar-wrapper {
        max-width: 900px;
        margin: 20px auto;
    }
    
    .tc-header,
    .calendar-header {
        padding: 20px;
    }
    
    .tc-title {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 12px;
        font-size: 16px;
    }
    
    .tc-gregorian-month,
    .tc-tamil-months,
    .tc-tamil-year {
        display: inline;
        font-size: 16px;
        margin: 0;
    }
    
    .tc-separator {
        display: inline;
        margin: 0 10px;
        opacity: 0.7;
    }
    
    .tc-weekday,
    .tamil-calendar-grid thead th {
        padding: 12px;
        font-size: 14px;
    }
    
    .tc-day,
    .calendar-day {
        min-height: 80px;
        padding: 6px;
    }
    
    .tc-day-gregorian,
    .day-number {
        font-size: 20px;
        top: 6px;
        left: 8px;
    }
    
    .tc-tamil-month-label,
    .tamil-month-english,
    .tamil-month-tamil {
        font-size: 11px;
    }
    
    .tc-tamil-date-number,
    .tamil-day-number {
        font-size: 16px;
    }
    
    .day-events,
    .tc-events-indicator {
        top: 28px;
        right: 6px;
    }
    
    .event-indicator,
    .tc-event-wrapper {
        min-width: 20px;
        height: 20px;
    }
    
    .event-icon,
    .tc-event-emoji {
        font-size: 15px !important;
    }
    
    .tc-modal-inner {
        padding: 30px 0;
    }
    
    .tc-modal-content {
        width: 70%;
        max-width: 700px;
        margin: 30px auto;
    }
}

/* Scrollbar styling */
.tc-modal::-webkit-scrollbar,
.tamil-calendar-daily-panel::-webkit-scrollbar {
    width: 10px;
}

.tc-modal::-webkit-scrollbar-track,
.tamil-calendar-daily-panel::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.tc-modal::-webkit-scrollbar-thumb,
.tamil-calendar-daily-panel::-webkit-scrollbar-thumb {
    background: #c41e3a;
    border-radius: 5px;
}

.tc-modal::-webkit-scrollbar-thumb:hover,
.tamil-calendar-daily-panel::-webkit-scrollbar-thumb:hover {
    background: #a01729;
}

/* Print styles */
@media print {
    .tc-nav-prev,
    .tc-nav-next,
    .tc-today,
    .calendar-nav,
    .tc-modal {
        display: none !important;
    }
    
    .tamil-calendar-wrapper {
        box-shadow: none;
    }
    
    .tc-day,
    .calendar-day {
        min-height: 50px;
    }
}

/* Accessibility */
.tc-day:focus,
.calendar-day:focus,
.tc-nav-prev:focus,
.tc-nav-next:focus,
.tc-today:focus {
    outline: 2px solid #4CAF50;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .tc-day-today,
    .calendar-day.today {
        border: 3px solid #000;
    }
    
    .tc-day-gregorian,
    .day-number {
        font-weight: 700;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .tamil-calendar-wrapper {
        background: #1a1a1a;
        color: #e0e0e0;
    }
    
    .tc-day,
    .calendar-day {
        background: #2a2a2a;
        color: #e0e0e0;
    }
    
    .tc-day:hover:not(.tc-day-empty):not(.empty-day),
    .calendar-day:hover:not(.empty-day) {
        background: #333;
    }
    
    .tc-day-empty,
    .empty-day {
        background: #1f1f1f;
    }
    
    .tc-weekdays,
    .tamil-calendar-grid thead {
        background: #252525;
    }
    
    .tc-modal-content {
        background: #2a2a2a;
        color: #e0e0e0;
    }
}

/* ==========================================
   MODAL TWO-COLUMN LAYOUT & COMPACT STYLES
   ========================================== */

/* Calendar Sheet Section - MODERN FULL WIDTH */
#tc-modal-calendar-sheet {
    margin-bottom: 20px;
}

#tc-modal-calendar-sheet h4 {
    font-size: 13px;
    margin: 0 0 12px 0;
    color: #666;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tc-calendar-sheet-wrapper {
    position: relative;
    width: 100%;
    margin: 0;
    border-radius: 12px;
    overflow: hidden;
    background: #f8f9fa;
}

.tc-calendar-sheet-image {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.tc-calendar-sheet-image:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 30px rgba(196, 30, 58, 0.2);
}

/* Loading state */
.tc-calendar-sheet-wrapper::before {
    content: '';
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #f8f8f8 50%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    z-index: 1;
    border-radius: 12px;
}

.tc-calendar-sheet-wrapper img {
    position: relative;
    z-index: 2;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Error state */
.tc-sheet-not-found {
    padding: 60px 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    color: #999;
    text-align: center;
    font-size: 13px;
    border: 2px dashed #dee2e6;
}

.tc-sheet-not-found::before {
    content: '📅';
    display: block;
    font-size: 48px;
    margin-bottom: 10px;
    opacity: 0.5;
}

/* Two-Column Layout */
.tc-modal-two-column {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.tc-modal-column-left,
.tc-modal-column-right {
    min-width: 0; /* Prevent overflow */
}

/* Compact Section Headers */
.tc-modal-two-column h4,
#tc-modal-events h4 {
    font-size: 14px !important;
    margin: 0 0 8px 0 !important;
    color: #c41e3a;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 5px;
}

/* Compact Tables */
.tc-modal-two-column table,
#tc-modal-tamil-info table,
#tc-modal-timings table,
#tc-modal-weekly-info table {
    width: 100%;
    margin-top: 5px;
    border-collapse: collapse;
    font-size: 13px;
}

.tc-modal-two-column table td,
#tc-modal-tamil-info table td,
#tc-modal-timings table td,
#tc-modal-weekly-info table td {
    padding: 5px 0;
    border-bottom: 1px solid #f5f5f5;
    vertical-align: top;
}

.tc-modal-two-column table td:first-child,
#tc-modal-tamil-info table td:first-child,
#tc-modal-timings table td:first-child,
#tc-modal-weekly-info table td:first-child {
    font-weight: 600;
    width: 45%;
    color: #555;
    font-size: 12px;
}

.tc-modal-two-column table td:last-child,
#tc-modal-tamil-info table td:last-child,
#tc-modal-timings table td:last-child,
#tc-modal-weekly-info table td:last-child {
    color: #333;
}

/* Events Inline Display */
#tc-modal-events {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.tc-events-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.tc-event-item {
    display: inline-flex;
    align-items: center;
    font-size: 13px;
    color: #333;
    padding: 4px 8px;
    background: #f8f9fa;
    border-radius: 4px;
    white-space: nowrap;
}

/* Reduce Modal Padding */
.tc-modal-body,
.daily-panel-content,
.daily-content {
    padding: 15px !important; /* Reduced from 20px */
}

.tc-modal-header,
.daily-header {
    padding: 15px !important; /* Reduced from 20px */
}

.tc-modal-header h3,
.daily-header h2 {
    font-size: 16px !important; /* Reduced from 18px */
}

/* ==========================================
   MOBILE RESPONSIVE (up to 576px)
   ========================================== */
@media (max-width: 576px) {
    /* Stack columns on mobile */
    .tc-modal-two-column {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    /* Calendar sheet maintains full width on mobile */
    .tc-calendar-sheet-image {
        border-radius: 8px;
    }
    
    .tc-calendar-sheet-image:hover {
        transform: scale(1.01); /* Less zoom on mobile */
    }
    
    #tc-modal-calendar-sheet h4 {
        font-size: 12px;
    }
    
    .tc-modal-body,
    .daily-panel-content {
        padding: 12px !important;
    }
    
    .tc-modal-two-column h4,
    #tc-modal-events h4 {
        font-size: 13px !important;
    }
    
    .tc-modal-two-column table,
    .tc-events-inline {
        font-size: 12px;
    }
}

/* ==========================================
   TABLET (577px - 768px)
   ========================================== */
@media (min-width: 577px) and (max-width: 768px) {
    /* Calendar sheet looks great at full width on tablet */
    .tc-calendar-sheet-image {
        border-radius: 10px;
    }
}

/* ==========================================
   TAMIL EVENTS LIST  (.tel-*)
   Shortcode: [tamil_events_list]
   ========================================== */

.tel-wrapper {
    font-family: 'Noto Sans Tamil', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    max-width: 800px;
    margin: 0 auto;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,.1);
    overflow: hidden;
}

/* --- Period heading (used by today/week/month/range shortcodes) --- */
.tel-period-heading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #c41e3a 0%, #e91e63 100%);
    color: #fff;
}

.tel-period-label {
    font-size: 18px;
    font-weight: 700;
    text-align: center;
}

/* --- Year navigation --- */
.tel-year-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #c41e3a 0%, #e91e63 100%);
    color: #fff;
}

.tel-year-display {
    font-size: 18px;
    font-weight: 700;
    min-width: 60px;
    text-align: center;
}

.tel-year-prev,
.tel-year-next {
    background: rgba(255,255,255,.2);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
}

.tel-year-prev:hover,
.tel-year-next:hover {
    background: rgba(255,255,255,.35);
}

/* --- Category tabs --- */
.tel-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    background: #f8f8f8;
    border-bottom: 2px solid #e0e0e0;
}

.tel-tab {
    flex: 1 1 auto;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    cursor: pointer;
    transition: color .2s, border-color .2s, background .2s;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 5px;
}

.tel-tab-emoji {
    font-size: 15px;
    line-height: 1;
    flex-shrink: 0;
}

.tel-tab-label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
}

.tel-tab-label-ta {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    font-family: 'Noto Sans Tamil', sans-serif;
}

.tel-tab-label-en {
    font-size: 10px;
    font-weight: 500;
    line-height: 1.2;
    opacity: 0.75;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.tel-tab:hover {
    background: #efefef;
    color: #222;
}

.tel-tab-active {
    color: #c41e3a;
    border-bottom-color: #c41e3a;
    background: #fff;
}

.tel-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e0e0e0;
    color: #444;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
    min-width: 20px;
    height: 18px;
    padding: 0 5px;
    margin-left: 2px;
}

.tel-tab-active .tel-tab-count {
    background: #c41e3a;
    color: #fff;
}

/* --- Tab panels --- */
.tel-panel {
    display: none;
    padding: 0 0 16px;
}

.tel-panel-active {
    display: block;
}

/* --- Month section --- */
.tel-month-section {
    margin: 0;
}

.tel-month-heading {
    margin: 0;
    padding: 10px 16px 8px;
    font-size: 14px;
    font-weight: 700;
    color: #c41e3a;
    border-bottom: 1px solid #f0f0f0;
    background: #fafafa;
    letter-spacing: .3px;
}

/* --- Event rows --- */
.tel-event-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid #f5f5f5;
    border-left: 3px solid transparent;
    transition: background .15s;
}

.tel-event-row:hover {
    background: #fafafa;
}

.tel-event-row:last-child {
    border-bottom: none;
}

/* Type accent colours on left border */
.tel-type-festival   { border-left-color: #c41e3a; }
.tel-type-holiday    { border-left-color: #28a745; }
.tel-type-religious  { border-left-color: #e67e22; }
.tel-type-auspicious { border-left-color: #0056b3; }
.tel-type-tithi      { border-left-color: #6f42c1; }
.tel-type-cultural   { border-left-color: #20c997; }
.tel-type-other      { border-left-color: #6c757d; }

/* Past events: slightly faded */
.tel-past {
    opacity: .5;
}

/* Today's event: highlighted */
.tel-today-row {
    background: #fff8e1 !important;
    border-left-color: #ffc107 !important;
    opacity: 1 !important;
}

/* --- Date badge --- */
.tel-date-badge {
    flex-shrink: 0;
    width: 48px;
    background: linear-gradient(135deg, #c41e3a 0%, #e91e63 100%);
    color: #fff;
    border-radius: 6px;
    text-align: center;
    padding: 5px 4px;
    line-height: 1.2;
}

.tel-day {
    display: block;
    font-size: 18px;
    font-weight: 700;
}

.tel-month-abbr {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .5px;
    opacity: .9;
}

/* --- Event info --- */
.tel-event-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.tel-emoji {
    font-size: 20px;
    flex-shrink: 0;
}

.tel-names {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.tel-name-en {
    font-size: 14px;
    font-weight: 600;
    color: #222;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tel-name-ta {
    font-size: 12px;
    color: #666;
    font-family: 'Noto Sans Tamil', sans-serif;
    margin-top: 1px;
}

/* --- Empty / loading states --- */
.tel-no-data {
    padding: 24px;
    text-align: center;
    color: #888;
}

.tel-loading {
    padding: 32px;
    text-align: center;
    color: #999;
    font-style: italic;
}

/* --- Mobile (≤576px) --- */
@media (max-width: 576px) {
    .tel-tab {
        font-size: 12px;
        padding: 9px 8px;
        justify-content: center;
    }

    .tel-tab-label {
        align-items: center;
    }

    .tel-tab-label-ta {
        font-size: 12px;
    }

    .tel-tab-label-en {
        font-size: 9px;
    }

    .tel-date-badge {
        width: 40px;
    }

    .tel-day {
        font-size: 16px;
    }

    .tel-name-en {
        font-size: 13px;
    }

    .tel-name-ta {
        font-size: 11px;
    }

    .tel-emoji {
        font-size: 17px;
    }
}

/* ==========================================================================
   OPTION C: TWO-PANE iOS CALENDAR LAYOUT — v2 (corrected)
   ========================================================================== */

/* Wrapper stays flex-column; tc-main-area handles the grid/panel split */
.tamil-calendar-wrapper {
    display: flex;
    flex-direction: column;
    overflow: visible;
}

/* Main area: left column (grid + footer) + daily panel */
.tc-main-area {
    display: flex;
    flex-direction: column; /* stacked on mobile */
}

.tc-left-column {
    flex: 1;
    min-width: 0;
}

/* ---- CELL: flex column (replaces absolute positioning) ---- */
.tc-day,
.calendar-day {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: stretch;
    min-height: 60px;
    padding: 3px 4px;
    position: relative;
}

.tc-day-gregorian,
.day-number {
    position: static;
    font-size: clamp(11px, 3vw, 16px);
    font-weight: 700;
    line-height: 1;
    color: #333;
    align-self: flex-start;
}

.tc-day-tamil,
.tamil-date-display {
    position: static;
    text-align: right;
    color: #c41e3a;
    align-self: flex-end;
    line-height: 1;
}

.tc-tamil-date-number {
    font-size: clamp(9px, 2.6vw, 14px);
    font-weight: 600;
    display: block;
}

/* Hide old month label — replaced by ::before on the cell */
.tc-tamil-month-label {
    display: none !important;
}

/* ---- TAMIL MONTH START: ::before label (no grid disruption) ---- */
.tc-tamil-month-start::before {
    content: attr(data-month-label);
    display: block;
    font-size: 8px;
    font-weight: 700;
    color: #c41e3a;
    background: rgba(196, 30, 58, 0.08);
    margin: -3px -4px 2px -4px;
    padding: 1px 3px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- EVENT INDICATORS ---- */
.tc-events-indicator,
.day-events {
    position: static;
    display: flex;
    flex-direction: row;
    gap: 2px;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    overflow: hidden;
    padding: 1px 0;
    z-index: auto;
}

/* Mobile: show events as coloured dots */
@media (max-width: 768px) {
    .tc-event-emoji,
    .event-icon {
        font-size: 0 !important;
        line-height: 0 !important;
        display: inline-block !important;
        width: 6px !important;
        height: 6px !important;
        min-width: 6px !important;
        border-radius: 50% !important;
        background: #c41e3a !important;
        vertical-align: middle !important;
        padding: 0 !important;
        box-shadow: none !important;
    }
    .tc-event-emoji[data-type="holiday"]    { background: #28a745 !important; }
    .tc-event-emoji[data-type="religious"]  { background: #e67e22 !important; }
    .tc-event-emoji[data-type="auspicious"] { background: #0056b3 !important; }
    .tc-event-emoji[data-type="festival"]   { background: #c41e3a !important; }
    .tc-event-emoji[data-type="tithi"]      { background: #6f42c1 !important; }

    .tc-more-events,
    .more-events { display: none !important; }

    /* Remove old badge wrapper styling */
    .event-indicator,
    .tc-event-wrapper {
        background: transparent !important;
        box-shadow: none !important;
        min-width: unset !important;
        height: auto !important;
        border-radius: 0 !important;
    }
}

/* ---- SELECTED DATE ---- */
.tc-day-selected,
.calendar-day.selected {
    outline: 2px solid #c41e3a !important;
    outline-offset: -2px;
    background: #fff0f3 !important;
    z-index: 2;
}
.tc-day-today.tc-day-selected {
    background: linear-gradient(135deg, #ffe8a1 0%, #fff0f3 100%) !important;
}

/* ---- PERMANENT DAILY PANEL ---- */
.tc-daily-panel {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-top: 2px solid #e0e0e0;
}
.tc-daily-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #c41e3a 0%, #e91e63 100%);
    color: #fff;
    padding: 10px 14px;
    flex-shrink: 0;
}
.tc-daily-panel-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    text-align: center;
    flex: 1;
    color: #fff;
    padding: 0 8px;
}
.tc-day-prev,
.tc-day-next {
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 4px;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    padding: 6px 10px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    flex-shrink: 0;
}
.tc-day-prev:hover,
.tc-day-next:hover { background: rgba(255,255,255,0.3); }

.tc-daily-panel-body {
    padding: 14px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Calendar sheet image fills panel */
.tc-daily-panel-body .tc-calendar-sheet-image,
.tc-daily-panel-body .tc-calendar-sheet-wrapper img {
    width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 12px;
}

/* Single-column layout on mobile */
@media (max-width: 576px) {
    .tc-modal-two-column {
        display: block !important;
        grid-template-columns: 1fr !important;
    }
}

/* ---- DESKTOP: side-by-side via tc-main-area (769px+) ---- */
@media (min-width: 769px) {
    .tc-main-area {
        flex-direction: row;
        align-items: flex-start;
    }
    .tc-left-column {
        flex: 0 0 56%;
        border-right: 1px solid #e0e0e0;
    }
    .tc-daily-panel {
        flex: 0 0 44%;
        border-top: none;
        border-left: 2px solid #e0e0e0;
        position: sticky;
        top: 0;
        max-height: 85vh;
        overflow: hidden;
    }
    .tc-daily-panel-body {
        max-height: calc(85vh - 54px);
        overflow-y: auto;
    }

    /* Larger cells on desktop */
    .tc-day,
    .calendar-day { min-height: 75px; }
    .tc-day-gregorian, .day-number { font-size: 16px; }
    .tc-day-tamil, .tamil-date-display { font-size: 13px; }
    .tc-tamil-date-number { font-size: 13px; }

    /* Restore emoji on desktop */
    .tc-event-emoji,
    .event-icon {
        font-size: 12px !important;
        line-height: 1 !important;
        display: inline-block !important;
        width: auto !important;
        height: auto !important;
        min-width: unset !important;
        border-radius: 0 !important;
        background: transparent !important;
        font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif !important;
    }
    .tc-more-events,
    .more-events { display: inline-flex !important; font-size: 9px; }
}

/* =========================================================================
   Calendar Sheet Lightbox
   Click the sheet image to view full-size in an overlay.
   Works on both desktop and mobile.
   ========================================================================= */

.tc-lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.88);
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    /* fade in via JS adding .tc-lightbox-open */
    opacity: 0;
    transition: opacity 0.22s ease;
}

.tc-lightbox-overlay.tc-lightbox-open {
    display: flex;
    opacity: 1;
}

.tc-lightbox-inner {
    position: relative;
    max-width: 92vw;
    max-height: 92vh;
    cursor: default;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tc-lightbox-img {
    max-width: 92vw;
    max-height: 88vh;
    width: auto;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    display: block;
    /* subtle entrance scale */
    transform: scale(0.94);
    transition: transform 0.22s ease;
    /* Allow pinch-to-zoom on touch devices */
    touch-action: pinch-zoom;
}

.tc-lightbox-overlay.tc-lightbox-open .tc-lightbox-img {
    transform: scale(1);
}

/* Close button (×) */
.tc-lightbox-close {
    position: fixed;
    top: 16px;
    right: 20px;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 24px;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    z-index: 100000;
}

.tc-lightbox-close:hover,
.tc-lightbox-close:focus {
    background: rgba(255, 255, 255, 0.3);
    outline: none;
}

/* Prevent body scroll while lightbox is open */
body.tc-lightbox-body-lock {
    overflow: hidden;
}

/* Zoom-in cursor hint on the sheet image itself */
.tc-calendar-sheet-image,
.tc-daily-panel-body .tc-calendar-sheet-image,
.tc-daily-panel-body .tc-calendar-sheet-wrapper img {
    cursor: zoom-in !important;
}

/* Zoom icon badge overlaid on the image (desktop only) */
@media (min-width: 769px) {
    .tc-calendar-sheet-wrapper {
        position: relative;
    }
    .tc-calendar-sheet-wrapper::after {
        content: '🔍';
        position: absolute;
        bottom: 8px;
        right: 8px;
        font-size: 16px;
        background: rgba(0, 0, 0, 0.45);
        color: #fff;
        border-radius: 50%;
        width: 30px;
        height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.2s ease;
        z-index: 3;
    }
    .tc-calendar-sheet-wrapper:hover::after {
        opacity: 1;
    }
}
