/* Lịch Vạn Niên Styles */
body.apt-lunar-calendar-page {
    font-family: 'Inter', sans-serif;
    background-color: #f0fdf4;
}

.apt-lunar-calendar {
    font-family: 'Inter', sans-serif;
}

.apt-lunar-calendar .serif-font {
    font-family: 'Merriweather', serif;
}

.apt-lunar-calendar .calendar-shadow {
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.1);
}

.apt-lunar-calendar .lunar-text {
    font-size: 0.75rem;
    color: #6b7280;
}

.apt-lunar-calendar .today-highlight {
    background-color: #059669;
    color: white !important;
    border-radius: 0.5rem;
}

.apt-lunar-calendar .today-highlight .lunar-text {
    color: #d1fae5 !important;
}

/* Animation cho Chat & Modal */
.apt-lunar-calendar .fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

.apt-lunar-calendar .slide-up {
    animation: slideUp 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

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

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Scrollbar đẹp cho chat */
.apt-lunar-calendar .custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.apt-lunar-calendar .custom-scrollbar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.apt-lunar-calendar .custom-scrollbar::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.apt-lunar-calendar .custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Chat modal specific styles */
#chat-modal {
    display: flex !important;
    flex-direction: column;
}

#chat-modal.hidden {
    display: none !important;
}

/* Hide chat button when modal is open */
#chat-modal:not(.hidden)~#apt-chat-button,
body:has(#chat-modal:not(.hidden)) #apt-chat-button {
    display: none !important;
}

#chat-messages {
    flex: 1 1 0%;
    height: 0;
    /* Force the flex item to shrink and respect overflow */
    min-height: 0;
    max-height: 100%;
    overflow-y: scroll !important;
    /* Changed from auto to scroll to force scrollbar */
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
    /* Reserve space for scrollbar */
}

/* Ensure chat message content is visible */
#chat-messages>div {
    opacity: 1 !important;
    visibility: visible !important;
}

#chat-messages .bg-emerald-100,
#chat-messages .bg-white {
    color: inherit !important;
}

#chat-messages .text-gray-800 {
    color: #1f2937 !important;
}

#chat-messages .text-gray-700 {
    color: #374151 !important;
}

/* Loading Dots */
.apt-lunar-calendar .typing-indicator span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: #059669;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
    margin: 0 1px;
}

.apt-lunar-calendar .typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.apt-lunar-calendar .typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Chat Button Styling - Ensure it's always clickable */
#apt-chat-button {
    cursor: pointer !important;
    pointer-events: auto !important;
    user-select: none;
}

/* Responsive adjustments */
.apt-lunar-calendar .calendar-cell {
    border: 1px solid #e5e7eb;
    position: relative;
    aspect-ratio: 1 / 1;
    /* Make cells square */
    padding: 0.5rem;
}

.apt-lunar-calendar .calendar-cell:hover {
    background-color: #f0fdf4;
}

/* Improved calendar cell content layout */
.apt-lunar-calendar .calendar-cell .solar-date {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
}

.apt-lunar-calendar .calendar-cell .lunar-date {
    font-size: 0.65rem;
    color: #9ca3af;
    margin-top: 0.25rem;
    line-height: 1;
}

.apt-lunar-calendar .calendar-cell.today-highlight .lunar-date {
    color: #fca5a5;
}

@media (max-width: 768px) {
    .apt-lunar-calendar .calendar-cell {
        padding: 0.35rem;
    }

    /* Adjust solar date size on mobile */
    .apt-lunar-calendar .calendar-cell .solar-date {
        font-size: 0.875rem;
    }

    /* Adjust lunar date size on mobile */
    .apt-lunar-calendar .calendar-cell .lunar-date {
        font-size: 0.55rem;
    }

    /* Điều chỉnh table header */
    .apt-lunar-calendar table th {
        padding: 0.4rem 0.1rem;
    }

    /* Điều chỉnh width cho table trên mobile */
    .apt-lunar-calendar table {
        min-width: 100%;
    }
}

@media (max-width: 480px) {
    .apt-lunar-calendar .calendar-cell {
        padding: 0.25rem;
    }

    /* Font nhỏ hơn nữa cho màn hình rất nhỏ */
    .apt-lunar-calendar .calendar-cell .solar-date {
        font-size: 0.75rem;
    }

    .apt-lunar-calendar .calendar-cell .lunar-date {
        font-size: 0.5rem;
    }

    .apt-lunar-calendar table th {
        padding: 0.3rem 0.05rem;
    }

    /* Ensure table cells use proper padding class */
    .apt-lunar-calendar table td {
        padding: 0.25rem;
    }

    /* Chat button responsive */
    #apt-chat-button {
        bottom: 70px !important;
        right: 1rem !important;
        padding: 0.625rem 1rem !important;
        font-size: 0.75rem !important;
    }

    #apt-chat-button i {
        font-size: 1rem !important;
    }

    #apt-chat-button span {
        font-size: 0.75rem !important;
    }

    /* Chat modal responsive */
    #chat-modal {
        width: calc(100vw - 2rem) !important;
        max-width: 320px !important;
        right: 1rem !important;
    }
}