:root {
    --primary-color: #d32f2f;
    --secondary-color: #ffc107;
    --text-color: #333;
    --bg-color: #f5f5f5;
    --card-bg: rgba(255, 255, 255, 0.9);
    --header-text: #ffffff;
    --pill-bg: rgba(255, 255, 255, 0.15);
    --modal-bg: #ffffff;
    --divider-color: #eee;
    --input-border: #f0f0f0;
    --input-bg: #fcfcfc;
    --surface-color: #ffffff;
    --quote-title-color: #666;
    --quote-body-color: #444;
}

[data-theme="dark"] {
    --primary-color: #f44336;
    --secondary-color: #ffca28;
    --text-color: #e0e0e0;
    --bg-color: #121212;
    --card-bg: rgba(30, 30, 30, 0.95);
    --header-text: #ffffff;
    --pill-bg: rgba(255, 255, 255, 0.1);
    --modal-bg: #1e1e1e;
    --divider-color: #333;
    --input-border: #444;
    --input-bg: #2a2a2a;
    --surface-color: #242424;
    --quote-title-color: #bbb;
    --quote-body-color: #eee;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.app-container {
    width: 100%;
    max-width: 450px;
    background: var(--card-bg);
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
    text-align: center;

    /* Smooth Load optimization */
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.6s ease-out, transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

body.ready .app-container {
    opacity: 1;
    transform: translateY(0);
}

header {
    background: var(--primary-color);
    color: white;
    padding: 30px 24px;
    /* Tăng padding để thoáng hơn */
    margin: -24px -24px 24px -24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    /* Tạo khoảng cách giữa các khối chính */
}

.header-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    /* Khoảng cách giữa tiêu đề và ngày */
}

header h1 {
    font-family: 'Playfair Display', serif;
    color: white;
    margin: 0;
    text-transform: uppercase;
    font-size: 1.6rem;
    letter-spacing: 2px;
}

.date-display {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

.header-actions-fixed {
    margin-top: 5px;
    width: 100%;
    display: flex;
    justify-content: center;
}

.nav-pill-group {
    display: inline-flex;
    background: var(--pill-bg);
    padding: 5px;
    border-radius: 50px;
    backdrop-filter: blur(15px) saturate(180%);
    -webkit-backdrop-filter: blur(15px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.btn-pill {
    background: transparent;
    border: none;
    color: var(--header-text);
    padding: 0 22px;
    height: 44px;
    /* Standard touch target */
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}



#lang-toggle {
    min-width: 50px;
    justify-content: center;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px 0 0 50px;
    padding: 10px 15px;
    font-weight: 800;
}

#btn-today {
    border-radius: 0;
}

.btn-pill:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.btn-pill svg {
    stroke: white;
    stroke-width: 2.5;
    opacity: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.day-cell.is-holiday .solar-num,
.day-cell.is-holiday .lunar-num {
    color: #d32f2f;
}

.zodiac-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.zodiac-dot.good {
    background: #d32f2f;
    box-shadow: 0 0 5px rgba(211, 47, 47, 0.3);
}

.zodiac-dot.bad {
    background: #000;
}

/* Discovery Modal Compact Layout */
.discovery-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    padding: 5px;
}

@media (min-width: 600px) {
    .discovery-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.info-card-compact {
    padding: 12px;
    border-radius: 12px;
    border-left: 4px solid var(--border-color, #ddd);
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.info-card-compact h3 {
    margin: 0 0 8px 0;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-card-compact p {
    font-size: 0.85rem;
    line-height: 1.4;
    margin: 0;
    color: #555;
}

.calendar-bloc {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 20px;
    margin: 0 16px 24px 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    position: relative;
}

/* Month View Styles */
#month-view-modal .modal-content {
    max-width: 900px;
    width: 95%;
    max-height: 95vh;
    padding: 0;
    overflow: hidden;
    border-radius: 20px;
    border: none;
    display: flex;
    flex-direction: column;
    position: relative;
}

#close-month-view {
    position: absolute;
    top: 15px;
    right: 20px;
    z-index: 100;
    font-size: 2rem;
    line-height: 1;
    color: white;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.1);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.month-header {
    background: var(--primary-color);
    color: white;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 20px 20px 0 0;
    flex-shrink: 0;
}

.header-title-nav {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-title-nav h2 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
}

.nav-arrow {
    background: white;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    color: #4caf50;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.month-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: 30px;
}

.month-controls select {
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.month-grid-container {
    padding: 10px;
    background: white;
    overflow-y: auto;
    flex-grow: 1;
}

.weekday-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-weight: 600;
    font-size: 0.8rem;
    color: #666;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.weekday-header div:last-child {
    color: #d32f2f;
}

.month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #e0e0e0;
    gap: 1px;
    border-bottom: 1px solid #ddd;
}

.day-cell {
    background: white;
    aspect-ratio: 1 / 1;
    padding: 4px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
    overflow: hidden;
}

.day-cell:hover {
    background: #f5f5f5;
}

.day-cell.today {
    background: #fff3e0 !important;
    box-shadow: inset 0 0 0 2px #ffb74d;
}

.day-cell.other-month {
    background: #fafafa;
}

.day-cell.other-month span {
    opacity: 0.4;
}

.solar-num {
    position: absolute;
    top: 3px;
    left: 6px;
    font-size: 1rem;
    font-weight: 700;
    color: #333;
}

.day-cell:nth-child(7n) .solar-num {
    color: #d32f2f;
}

.zodiac-dot {
    position: absolute;
    top: 6px;
    left: 28px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.lunar-num {
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 0.7rem;
    color: #888;
    font-weight: 500;
}

.can-chi-label {
    position: absolute;
    bottom: 18px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.6rem;
    color: #777;
    white-space: nowrap;
}

.holiday-label {
    position: absolute;
    bottom: 3px;
    left: 2px;
    right: 2px;
    text-align: center;
    font-size: 0.6rem;
    color: #d32f2f;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.day-cell.is-holiday .solar-num {
    color: #d32f2f;
}

.nav-container {
    display: flex;
    align-items: center;
    background: var(--primary-color);
    color: white;
}

.nav-btn {
    background: none;
    border: none;
    color: white;
    padding: 10px 15px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

.nav-btn:hover {
    opacity: 0.8;
}

.bloc-header {
    flex: 1;
    padding: 10px;
    font-weight: 700;
    font-size: 1.1rem;
}

.bloc-split {
    display: flex;
    position: relative;
    padding: 50px 10px;
    background: linear-gradient(to bottom, #fff, #fafafa);
}

.split-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 10px;
    min-width: 0;
}

.solar-side {
    border-right: 2px dashed #eee;
}

.side-label {
    font-size: 0.9rem;
    color: #888;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 20px;
}

.solar-day {
    font-size: 6rem;
    font-weight: 800;
    line-height: 1;
    /* Fix line-height to reserve space */
    min-height: 6rem;
    /* Support skeleton look */
    color: var(--primary-color);
    margin-bottom: 15px;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.solar-month-year {
    font-size: 1rem;
    color: #444;
    font-weight: 600;
}

.lunar-day {
    font-size: 6rem;
    font-weight: 800;
    line-height: 1;
    /* Fix line-height to reserve space */
    min-height: 6rem;
    /* Support skeleton look */
    color: #4A148C;
    margin-bottom: 15px;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.lunar-month-info {
    font-size: 1rem;
    color: #444;
    font-weight: 600;
    margin-bottom: 5px;
}

.holiday-text {
    font-size: 0.9rem;
    color: #e53935;
    font-weight: 700;
    min-height: 1.4rem;
    text-align: center;
    padding: 0 10px;
}

.side-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.05);
    background: rgba(255, 255, 255, 0.95);
    color: var(--primary-color);
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.12);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 20;
}

.side-nav-btn:hover {
    background: #fff;
    transform: translateY(-50%) scale(1.1);
}

.side-nav-btn.prev {
    left: -15px;
}

.side-nav-btn.next {
    right: -15px;
}

/* --- Mobile Responsive Fixes --- */
@media (max-width: 480px) {

    .solar-day,
    .lunar-day {
        font-size: 4.5rem;
        /* Sửa lỗi số đè lên nhau */
    }

    .side-nav-btn {
        width: 38px;
        height: 38px;
    }

    .side-nav-btn.prev {
        left: -8px;
    }

    .side-nav-btn.next {
        right: -8px;
    }

    .bloc-split {
        gap: 15px;
    }

    /* Fix Month View Modal for mobile */
    .month-header {
        flex-direction: column;
        gap: 12px;
        align-items: center;
        padding: 15px 10px;
    }

    .header-title-nav h2 {
        font-size: 1.1rem;
    }

    .month-controls {
        margin-right: 0;
        gap: 6px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .month-controls select {
        padding: 4px 6px;
        font-size: 0.85rem;
    }

    #btn-view-month {
        font-size: 0.8rem;
        padding: 4px 10px !important;
    }

    #month-view-modal .modal-content {
        width: 100%;
        height: 100vh;
        margin: 0;
        border-radius: 0;
    }

    /* Optimize Grid Cells for mobile */
    .solar-num {
        font-size: 0.9rem;
        top: 2px;
        left: 4px;
    }

    .lunar-num {
        font-size: 0.6rem;
        top: 2px;
        right: 4px;
    }

    .can-chi-label {
        font-size: 0.5rem;
        bottom: 14px;
    }

    .holiday-label {
        font-size: 0.5rem;
        bottom: 2px;
    }

    .zodiac-dot {
        top: 4px;
        left: 20px;
        width: 4px;
        height: 4px;
    }

    .weekday-header {
        font-size: 0.7rem;
        padding: 4px 0;
    }
}

@media (max-width: 360px) {

    .solar-day,
    .lunar-day {
        font-size: 3.5rem;
    }

    .side-nav-btn.prev {
        left: -5px;
    }

    .side-nav-btn.next {
        right: -5px;
    }

    .side-nav-btn svg {
        width: 18px;
        height: 18px;
    }
}

.bloc-footer-info {
    padding: 25px;
    background: var(--surface-color);
    border-top: 1px solid var(--divider-color);
    text-align: left;
    font-size: 0.9rem;
}

.day-status {
    color: #555;
    line-height: 1.8;
}

.day-status strong {
    color: var(--primary-color);
    font-weight: 700;
}

.quote-container {
    padding: 0 16px;
    margin-bottom: 24px;
    perspective: 1000px;
}

.quote-banner {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 18px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: slideUpFade 0.6s ease-out;
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.quote-header {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    background: linear-gradient(to right, rgba(255, 255, 255, 0.2), transparent);
}

.quote-icon {
    font-size: 1.2rem;
    animation: sparkle 2s infinite;
}

@keyframes sparkle {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

#quote-title {
    flex: 1;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--quote-title-color);
    text-align: left;
}

.collapse-btn {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s;
}

.quote-banner.collapsed .collapse-btn {
    transform: rotate(-90deg);
}

.quote-body {
    max-height: 200px;
    overflow: hidden;
    transition: max-height 0.4s ease-in-out, padding 0.4s;
    padding: 0 16px 16px 16px;
}

.quote-banner.collapsed .quote-body {
    max-height: 0;
    padding-bottom: 0;
}

#daily-quote {
    font-size: 0.95rem;
    font-style: italic;
    font-weight: 500;
    color: var(--quote-body-color);
    line-height: 1.5;
    text-align: left;
    margin: 0;
}

.quick-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.btn {
    flex: 1;
    height: 44px;
    /* Standard touch target */
    padding: 0 12px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background-color 0.2s;
}

.btn:active {
    transform: scale(0.95);
}

.btn.primary {
    background: var(--primary-color);
    color: #fff;
}

.btn.secondary {
    background: var(--secondary-color);
    color: #333;
}

/* Modal Style */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--modal-bg);
    color: var(--text-color);
    margin: 10% auto;
    padding: 24px;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.close-btn {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    color: #666;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.close-btn:hover {
    color: #333;
}

.month-header .close-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 20px;
    color: white;
    font-size: 24px;
    opacity: 0.8;
    margin-left: 0;
}

.month-header .close-btn:hover {
    opacity: 1;
    color: white;
}

.scrollable {
    overflow-y: auto;
    max-height: 60vh;
    text-align: left;
    white-space: pre-line;
    line-height: 1.6;
    margin-top: 20px;
    padding-right: 10px;
}

/* Search Form Style */
.search-form {
    margin-top: 20px;
}

.input-group {
    margin-bottom: 20px;
    text-align: left;
}

.input-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #666;
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--input-border);
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s;
    background: var(--input-bg);
    color: var(--text-color);
}

.input-group input:focus {
    border-color: var(--primary-color);
    outline: none;
    background: var(--surface-color);
}

.divider {
    margin: 15px 0;
    font-size: 0.75rem;
    color: #999;
    font-weight: 700;
    position: relative;
    text-align: center;
}

.divider::before,
.divider::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 35%;
    height: 1px;
    background: #eee;
}

.divider::before {
    left: 0;
}

.divider::after {
    right: 0;
}

.lunar-inputs,
.solar-inputs-group {
    display: flex;
    gap: 8px;
}

.lunar-inputs input,
.solar-inputs-group input {
    flex: 1;
    min-width: 0;
    width: auto;
}

.app-footer {
    margin-top: 20px;
    padding-bottom: 20px;
    text-align: center;
}

#footer-credit {
    font-size: 0.75rem;
    color: #888;
    opacity: 0.8;
    margin: 0;
    font-style: italic;
    letter-spacing: 0.2px;
}