/* =============================================
   LỊCH TIẾT KHÍ — style.css
   Tông màu: Kem / Nâu ấm (warm cream & brown)
   ============================================= */

/* ---------- CSS Variables ---------- */
:root {
    --cream-lightest: #fdf8f2;
    --cream-light:    #f5ead8;
    --cream-mid:      #e8d5b7;
    --brown-light:    #c8a882;
    --brown-mid:      #9b7451;
    --brown-dark:     #6b4c2a;
    --brown-deepest:  #3e2a12;

    --sat-color:      #5b8dd9;   /* Thứ 7 — xanh dương */
    --sun-color:      #c0392b;   /* Chủ nhật — đỏ */

    --radius-card:    16px;
    --radius-cell:    10px;
    --shadow-card:    0 4px 24px rgba(107, 76, 42, 0.13);
    --shadow-hover:   0 6px 20px rgba(107, 76, 42, 0.22);

    --font-main: 'Be Vietnam Pro', sans-serif;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

[hidden] {
    display: none !important;
}

html, body {
    min-height: 100vh;
    font-family: var(--font-main);
    background: linear-gradient(145deg, #f7eedd 0%, #ede0c8 100%);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 24px 12px 48px;
}

/* ---------- Calendar Card ---------- */
.calendar-wrapper {
    width: 100%;
    max-width: 420px;
    background: var(--cream-lightest);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 20px 16px 24px;
    border: 1px solid var(--cream-mid);
}

/* ---------- Header ---------- */
.header-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
}

.today-action {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

#btn-today,
#date-picker {
    background-color: var(--cream-light);
    color: var(--brown-dark);
    border: 1px solid var(--cream-mid);
    border-radius: 10px;
    padding: 6px 18px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
}

#btn-today {
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#date-picker {
    width: 250px;
    max-width: 100%;
    min-width: 250px;
    padding-right: 10px;
    padding-left: 10px;
    cursor: pointer;
    color-scheme: light;
}

#date-picker:focus-visible {
    outline: 2px solid var(--brown-light);
    outline-offset: 2px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

#btn-today:hover {
    background-color: var(--brown-mid);
    color: var(--cream-lightest);
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

.month-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--brown-dark);
    letter-spacing: 0.02em;
}

.nav-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1.5px solid var(--cream-mid);
    background: var(--cream-light);
    color: var(--brown-mid);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s, transform 0.15s;
}

.nav-btn:hover {
    background: var(--brown-mid);
    color: var(--cream-lightest);
    transform: scale(1.08);
}

/* ---------- Weekday Header Row ---------- */
.weekdays-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 6px;
}

.weekday {
    text-align: center;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--brown-light);
    padding: 6px 0 4px;
    text-transform: uppercase;
}

.weekday.sat { color: var(--sat-color); }
.weekday.sun { color: var(--sun-color); }

/* ---------- Days Grid ---------- */
.days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
}

/* ---------- Day Cell ---------- */
.day-cell {
    aspect-ratio: 1 / 1;
    border-radius: var(--radius-cell);
    background: var(--cream-light);
    border: 1px solid var(--cream-mid);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.18s, box-shadow 0.18s, transform 0.15s;
    position: relative;
    overflow: hidden;
}

.day-cell:hover {
    background: var(--cream-mid);
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px) scale(1.04);
    z-index: 1;
}

.day-cell.empty {
    background: transparent;
    border-color: transparent;
    cursor: default;
    pointer-events: none;
}

/* Số ngày */
.day-number {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--brown-deepest);
    line-height: 1;
}

/* Thứ 7 */
.day-cell.sat .day-number { color: var(--sat-color); }

/* Chủ nhật */
.day-cell.sun .day-number { color: var(--sun-color); }

/* Ngày hôm nay */
.day-cell.today {
    background: var(--brown-dark);
    border-color: var(--brown-dark);
    box-shadow: 0 4px 14px rgba(107, 76, 42, 0.35);
}

.day-cell.today .day-number {
    color: var(--cream-lightest);
}

/* Ngày đã chọn */
.day-cell.selected {
    background: var(--brown-mid);
    border-color: var(--brown-dark);
    box-shadow: var(--shadow-hover);
    transform: scale(1.04);
    z-index: 2;
}

.day-cell.selected .day-number {
    color: var(--cream-lightest);
}

/* Ngày Âm lịch */
.lunar {
    font-size: 11px;
    color: var(--brown-light); /* Màu nhạt hơn để không tranh giành sự chú ý */
    margin-top: 3px;
    line-height: 1;
}

/* Màu ngày âm cho các trạng thái đặc biệt */
.day-cell.sat .lunar { color: rgba(91, 141, 217, 0.8); }
.day-cell.sun .lunar { color: rgba(192, 57, 43, 0.8); }
.day-cell.today .lunar,
.day-cell.selected .lunar {
    color: rgba(253, 248, 242, 0.8); /* var(--cream-lightest) nhạt đi một chút */
}

/* Tiết Khí */
.lunar.jieqi {
    font-size: 13px;
    font-weight: bold;
    color: #b35938; /* Màu cam đất / đỏ gạch để nổi bật */
    text-align: center;
    line-height: 1.1;
}

/* Giữ Tiết Khí dễ đọc khi ô được chọn hoặc là hôm nay */
.day-cell.today .lunar.jieqi,
.day-cell.selected .lunar.jieqi {
    color: #f7ddca; /* Màu cam nhạt / be sáng */
}

/* ---------- Bazi & Profile Panels ---------- */
#bazi-panel,
#profile-panel {
    margin-top: 24px;
    background: var(--cream-light);
    border-radius: var(--radius-cell);
    padding: 16px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--cream-mid);
}

#bazi-panel h3,
#profile-panel h3 {
    font-size: 1rem;
    color: var(--brown-dark);
    margin-bottom: 4px;
    text-align: center;
    font-weight: 700;
}

#profile-panel h3 {
    margin-bottom: 12px;
}

.profile-auth-row {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    text-align: center;
}

#user-info {
    flex: 1 1 100%;
    color: var(--brown-mid);
    font-size: 0.8rem;
    font-weight: 500;
}

#btn-login,
#btn-logout {
    border: 1px solid var(--cream-mid);
    border-radius: 999px;
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.15s, box-shadow 0.2s;
}

#btn-login {
    background: var(--cream-lightest);
    color: var(--brown-dark);
    padding: 9px 16px;
    box-shadow: 0 3px 12px rgba(107, 76, 42, 0.12);
}

#btn-login::before {
    content: "G";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-right: 8px;
    border-radius: 50%;
    background: #ffffff;
    color: #4285f4;
    font-weight: 800;
    box-shadow: inset 0 0 0 1px rgba(66, 133, 244, 0.18);
}

#btn-login:hover {
    background: var(--brown-dark);
    color: var(--cream-lightest);
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

#btn-logout {
    background: transparent;
    color: var(--brown-mid);
    padding: 7px 13px;
}

#btn-logout:hover {
    background: var(--brown-mid);
    color: var(--cream-lightest);
    transform: translateY(-1px);
}

.profile-input-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
    margin-top: 8px;
}

#profile-name {
    min-width: 0;
    flex: 1;
    border: 1px solid var(--cream-mid);
    border-radius: 8px;
    background: var(--cream-lightest);
    color: var(--brown-deepest);
    padding: 9px 11px;
    font-family: inherit;
    font-size: 0.85rem;
}

#profile-name:focus-visible {
    outline: 2px solid var(--brown-light);
    outline-offset: 1px;
}

#btn-save-profile {
    border: 1px solid var(--brown-mid);
    border-radius: 8px;
    background: var(--brown-dark);
    color: var(--cream-lightest);
    padding: 8px 16px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
}

#btn-save-profile:hover {
    background: var(--brown-mid);
    transform: translateY(-1px);
}

#profile-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.profile-empty {
    grid-column: 1 / -1;
    color: var(--brown-mid);
    font-size: 0.82rem;
    font-style: italic;
    text-align: center;
    padding: 8px 0 2px;
}

.profile-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
    border: 1px solid var(--cream-mid);
    border-radius: 999px;
    background: var(--cream-lightest);
}

.profile-button {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    border: 0;
    border-radius: 999px 0 0 999px;
    background: transparent;
    color: var(--brown-dark);
    padding: 7px 10px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.15s;
}

.profile-button:hover {
    background: var(--brown-mid);
    color: var(--cream-lightest);
    transform: translateY(-1px);
}

.btn-delete-profile {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    margin-right: 3px;
    border: 0;
    border-radius: 50%;
    background: #f4d8d4;
    color: var(--sun-color);
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.15s;
}

.btn-delete-profile:hover {
    background: var(--sun-color);
    color: var(--cream-lightest);
    transform: scale(1.08);
}

.btn-delete-profile:focus-visible {
    outline: 2px solid var(--sun-color);
    outline-offset: 1px;
}

#bazi-time-info {
    font-size: 0.85em;
    font-style: italic;
    color: var(--brown-mid);
    text-align: center;
    margin-bottom: 12px;
}

.bazi-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.bazi-pillar {
    background: var(--cream-lightest);
    border: 1px solid var(--cream-mid);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.pillar-label {
    font-size: 0.75rem;
    color: var(--brown-mid);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.pillar-value {
    font-size: 1rem;
    font-weight: bold;
    color: var(--brown-deepest);
    line-height: 1.45;
    text-align: center;
}

.wuxing-part {
    display: inline-block;
}

.wx-kim { color: #a0a0a0; }
.wx-moc { color: #40b040; }
.wx-thuy { color: #3060c0; }
.wx-hoa { color: #e04040; }
.wx-tho { color: #a07040; }

#wuxing-summary {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 6px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--cream-mid);
}

.wuxing-stat {
    display: flex;
    flex: 1 1 0;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    border: 1px solid currentColor;
    border-radius: 8px;
    background: var(--cream-lightest);
    padding: 6px 3px;
    font-size: 0.7rem;
    font-weight: 600;
}

.wuxing-stat strong {
    font-size: 0.82rem;
}

.wuxing-stat.is-missing {
    opacity: 0.4;
    text-decoration: line-through;
}

/* ---------- Responsive: vùng thao tác ngày/giờ trên màn hình hẹp ---------- */
@media (max-width: 420px) {
    .today-action {
        flex-wrap: wrap;
    }
    #date-picker {
        flex: 1 0 100%;
        width: 100%;
        min-width: 0;
    }
}

/* ---------- Responsive: nhỏ hơn 360px ---------- */
@media (max-width: 360px) {
    .calendar-wrapper {
        padding: 16px 10px 20px;
    }
    .month-title {
        font-size: 1rem;
    }
    #btn-today,
    #date-picker {
        min-width: 0;
        padding-right: 10px;
        padding-left: 10px;
        font-size: 0.78rem;
    }
    #date-picker {
        flex-basis: 100%;
        width: 100%;
    }
    .day-number {
        font-size: 0.78rem;
    }
    .weekday {
        font-size: 0.65rem;
    }
}
