/* Ensure global box-sizing for consistent sizing */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f8f9fa;
    color: #212529;
    line-height: 1.5;
}

.calendar-container {
    max-width: 100%;
    padding: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px 0;
    border-bottom: 1px solid #e9ecef;
}

.ad-month-year {
    font-size: 1.2rem;
    font-weight: 600;
    color: #495057;
    flex: 1;
    display: flex;
    align-items: center;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-controls .btn {
    padding: 6px 10px;
    border: 1px solid #dee2e6;
    background: white;
    color: #495057;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.nav-controls .btn:hover {
    background: #e9ecef;
    border-color: #bdadad;
}

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

.form-select {
    width: 120px;
    padding: 5px 8px;
    font-size: 0.9rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
}

.form-select:focus {
    border-color: #7eb9ea;
    box-shadow: 0 0 0 3px rgba(126, 185, 234, 0.2);
}

.left-placeholder,
.right-placeholder {
    width: 200px; /* same as left skeleton */
    flex-shrink: 0;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}


.weekdays {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr)); /* Ensure equal column widths */
    gap: 1px;
    background: #286e57;
    margin-bottom: 1px;
}

.weekdays div {
    padding: 8px;
    text-align: center;
    font-weight: 600;
    background: #286e57;
    color: white;
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.weekdays .english-day {
    font-size: 0.75rem;
    font-weight: 400;
}

.calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr)); /* Ensure equal column widths */
    gap: 1px;
    background: #dee2e6;
}

.day {
    position: relative;
    padding: 6px 4px;
    text-align: center;
    background: #ffffff;
    cursor: pointer;
    min-height: 100px;
    width: 100%; /* Ensure full width within grid column */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border: 1px solid #85bba1;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.day:hover {
    background: #f1f3f4;
    transform: scale(1.02);
}

.day.other-month {
    background: #f0f2f5;
    color: #a0aec0;
    min-height: 100px;
    width: 100%; /* Ensure full width */
    border: 1px solid #d1d5db;
    cursor: default;
}

.day.current-month {
    background: #ffffff;
    color: #212529;
    min-height: 100px;
    width: 100%; /* Ensure full width */
}

.day.current-day {
    background: #227c5e;
    position: relative;
}

.day.current-day::after {
    content: '•';
    position: absolute;
    top: 6px;
    right: 6px;
    color: #7eb9ea;
    font-size: 1.1rem;
}

.day.current-day .nepali-date,
.day.current-day .english-date,
.day.current-day .tithi,
.day.current-day .holiday-title {
    color: #ffffff;
}

.day.saturday .nepali-date,
.day.saturday .english-date,
.day.saturday .tithi {
    color: #c53030;
}

.day.has-holiday {
    background: #ffffff;
    border: 1px solid #85bba1;
}

.day.has-holiday .nepali-date,
.day.has-holiday .english-date,
.day.has-holiday .tithi,
.day.has-holiday .holiday-title {
    color: #c53030;
}

.day.current-day.has-holiday {
    background: #c53030;
    border: 1px solid #85bba1;
}

.day.current-day.has-holiday .nepali-date,
.day.current-day.has-holiday .english-date,
.day.current-day.has-holiday .tithi,
.day.current-day.has-holiday .holiday-title {
    color: #ffffff;
}

.holiday-title {
    font-size: 0.65rem;
    color: #1d4062;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
    font-weight: 500;
    padding: 2px 5px;
    border-radius: 4px;
    max-width: 100%; /* Prevent overflow */
}

.nepali-date {
    font-size: 1.8rem;
    font-weight: 600;
    color: #1d4062;
    line-height: 1;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 90%; /* Prevent overflow */
    overflow: hidden;
    text-overflow: ellipsis;
}

.english-date {
    font-size: 0.8rem;
    color: #1d4062;
    position: absolute;
    bottom: 6px;
    left: 6px;
    margin: 0;
    max-width: 90%; /* Prevent overflow */
    overflow: hidden;
    text-overflow: ellipsis;
}

.tithi {
    font-size: 0.65rem;
    color: #1d4062;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
    position: absolute;
    bottom: 6px;
    right: 6px;
    max-width: 90%; /* Prevent overflow */
}

.modal-content {
    border-radius: 8px;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.modal-header {
    background: #ffffff;
    color: #459575;
    border-radius: 8px 8px 0 0;
    padding: 14px;
}

.modal-title {
    font-weight: 600;
}

.modal-body {
    padding: 18px;
    background: #f8f9fa;
}

/* Contact Box (Panchang) Styles */
.contact-box {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    padding: 18px;
    margin-bottom: 18px;
}

.np-color {
    color: #c22727;
}

.opacity-8 {
    opacity: 0.8;
}

.opacity-9 {
    opacity: 0.9;
}

.fs-14 {
    font-size: 0.875rem;
}

.top-banner {
    position: relative;
}

.rectangle-circle-today {
    background: white;
    border-radius: 8px;
    padding: 8px;
    text-align: center;
    width: 75px;
}

.top-day {
    font-size: 1.8rem;
    line-height: 1;
}

.todaysEvents {
    background: white;
    border-radius: 4px;
    padding: 7px;
    font-weight: 500;
    width: fit-content;
    margin: 0 auto;
}

.clock {
    font-size: 1.2rem;
    font-weight: 600;
}

.panchanga {
    font-size: 0.85rem;
    border-bottom: 1px solid #e9ecef;
}

.panchanga b {
    color: #459575;
}

.learnReadMoreBtn {
    background: #227c5e;
    color: white;
    border: none;
    font-size: 0.85rem;
}

.learnReadMoreBtn .fa-chevron-up {
    transition: transform 0.3s ease;
}

.learnReadMoreBtn.active .fa-chevron-up {
    transform: rotate(180deg);
}

.panchanga-details {
    display: none;
}

.panchanga-details.active {
    display: block;
}

/* Skeleton Loader Styles */
.skeleton-day {
    pointer-events: none;
    cursor: default;
}

.skeleton {
    background: linear-gradient(90deg, 
        #f0f0f0 0%, 
        #e0e0e0 20%, 
        #d0d0d0 40%, 
        #e0e0e0 60%, 
        #f0f0f0 80%, 
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

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

.skeleton-holiday {
    height: 10px;
    width: 80%;
    margin: 2px auto 3px;
}

.skeleton-nepali-date {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    height: 28px;
    width: 40px;
    border-radius: 6px;
}

.skeleton-english-date {
    position: absolute;
    bottom: 6px;
    left: 6px;
    height: 10px;
    width: 20px;
}

.skeleton-tithi {
    position: absolute;
    bottom: 6px;
    right: 6px;
    height: 8px;
    width: 30px;
}

.skeleton-weekday {
    height: 16px;
    width: 60%;
    margin: 0 auto;
}

.skeleton-ad-month,
.skeleton-dropdown,
.skeleton-nav-btn {
    border-radius: 4px;
}

/* Calendar Loading Spinner */
.calendar-spinner {
    animation: fadeIn 0.3s ease-in;
}

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

@media (max-width: 768px) {
    .calendar-container,
    .contact-box {
        padding: 10px;
        margin: 8px;
    }

    .calendar-header {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    .form-select {
        width: 100px;
    }

    .calendar {
        grid-template-columns: repeat(7, minmax(40px, 1fr)); /* Add min width for columns */
    }

    .day {
        min-height: 80px;
        width: 100%; /* Ensure full width */
    }

    .day.other-month {
        min-height: 80px;
        width: 100%; /* Ensure full width */
        background: #f0f2f5;
    }

    .nepali-date {
        font-size: 1.3rem;
        max-width: 85%; /* Tighter constraint for mobile */
    }

    .english-date {
        font-size: 0.7rem;
        bottom: 5px;
        left: 5px;
        max-width: 85%;
    }

    .tithi {
        font-size: 0.6rem;
        bottom: 5px;
        right: 5px;
        max-width: 85%;
    }

    .holiday-title {
        font-size: 0.6rem;
        max-width: 85%;
    }

    .weekdays div {
        padding: 6px 3px;
        font-size: 0.75rem;
    }

    .weekdays .english-day {
        font-size: 0.65rem;
    }

    .contact-box .rectangle-circle-today {
        width: 55px;
    }

    .top-day {
        font-size: 1.4rem;
    }

    .clock {
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    .calendar {
        grid-template-columns: repeat(7, minmax(35px, 1fr)); /* Tighter min width for small screens */
    }

    .day {
        min-height: 65px;
        width: 100%; /* Ensure full width */
        padding: 4px; /* Reduce padding for smaller screens */
    }

    .day.other-month {
        min-height: 65px;
        width: 100%; /* Ensure full width */
        background: #f0f2f5;
    }

    .nepali-date {
        font-size: 1rem;
        max-width: 80%; /* Even tighter constraint */
    }

    .english-date {
        font-size: 0.65rem;
        bottom: 4px;
        left: 4px;
        max-width: 80%;
    }

    .tithi {
        font-size: 0.55rem;
        bottom: 4px;
        right: 4px;
        max-width: 80%;
    }

    .holiday-title {
        font-size: 0.55rem;
        max-width: 80%;
    }

    .calendar-container,
    .contact-box {
        padding: 8px;
    }

    .panchanga {
        font-size: 0.75rem;
    }

    .weekdays div {
        padding: 5px 2px;
        font-size: 0.7rem;
    }

    .weekdays .english-day {
        font-size: 0.6rem;
    }
}