/* --- [GLOBAL CSS VARIABLES] --- */
:root {
    /* Brand Colors (based on existing components) */
    --lvn-primary-color: #d63384;

    /* Semantic Colors */
    --lvn-success-color: #198754;
    --lvn-success-light: #297050;
    --lvn-danger-color: #dc3545;
    --lvn-danger-light: #ac2a35;
    --lvn-info-color: #0dcaf0;
    --lvn-warning-color: #9e7805;

    /* Text Colors */
    --lvn-text-main: #212529;
    --lvn-text-muted: #6c757d;
    --lvn-text-label: #495057;

    /* Backgrounds & Borders */
    --lvn-bg-white: #ffffff;
    --lvn-bg-light: #f8f9fa;
    --lvn-border: #dee2e6;
    --lvn-divider: #e9ecef;

    /* Layout & Spacing */
    --lvn-radius-sm: 4px;
    --lvn-radius-md: 8px;
    --lvn-radius-lg: 12px;
    --lvn-radius-full: 50px;
    /* border */
    --lvn-border-color: #d1d1d1;
    /* Shadows */
    --lvn-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --lvn-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
}

/* --- [DARK MODE OVERRIDES] --- */
[data-theme="dark"] {
    --lvn-text-main: #e0d0b0;
    --lvn-text-muted: #a0a0a0;
    --lvn-text-label: #c0c0c0;
    --lvn-bg-white: #1a1a1a;
    --lvn-bg-light: #2a2a2a;
    --lvn-border: #3d3d3d;
    --lvn-divider: #333333;
    --lvn-border-color: #3d3d3d;
    --lvn-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --lvn-warning-color: #ffc107;
}

/* --- [SVG ICON STANDARDIZATION] --- */
.lvn-svg-icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

/* Reset mặc định nếu không khai báo size */
svg.lvn-svg-icon:not([class*="size-"]) {
    width: 1em;
    height: 1em;
}

/* Các lớp kích thước chuẩn */
.lvn-svg-icon.size-4 {
    width: 16px;
    height: 16px;
}

.lvn-svg-icon.size-5 {
    width: 20px;
    height: 20px;
}

.lvn-svg-icon.size-6 {
    width: 24px;
    height: 24px;
}

.lvn-svg-icon.size-8 {
    width: 32px;
    height: 32px;
}

/* --- [ANIMATIONS & EFFECTS] --- */
.lvn-icon-glow {
    filter: drop-shadow(0 0 2px currentColor);
    animation: lvn-pulse-glow 2s infinite ease-in-out;
}

@keyframes lvn-pulse-glow {
    0% {
        filter: drop-shadow(0 0 2px currentColor);
        opacity: 0.8;
        transform: scale(0.92);
    }

    50% {
        filter: drop-shadow(0 0 8px currentColor);
        opacity: 1;
        transform: scale(1.08);
    }

    100% {
        filter: drop-shadow(0 0 2px currentColor);
        opacity: 0.8;
        transform: scale(0.92);
    }
}

/* --- [COMMON LOADING - NGŨ HÀNH] --- */
.lvn-common-loader {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 40px 0;
    width: 100%;
    min-height: 100px;
}

.lvn-loader-dot {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    animation: lvn-loader-bounce 0.6s infinite alternate;
}

/* Màu sắc ngũ hành */
.lvn-loader-kim {
    background: linear-gradient(135deg, #e2e2e2, #999);
    box-shadow: 0 2px 8px rgba(153, 153, 153, 0.4);
    animation-delay: 0s;
}

.lvn-loader-moc {
    background: linear-gradient(135deg, #22c55e, #15803d);
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.4);
    animation-delay: 0.1s;
}

.lvn-loader-thuy {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
    animation-delay: 0.2s;
}

.lvn-loader-hoa {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
    animation-delay: 0.3s;
}

.lvn-loader-tho {
    background: linear-gradient(135deg, #92400e, #78350f);
    box-shadow: 0 2px 8px rgba(146, 64, 14, 0.4);
    animation-delay: 0.4s;
}

@keyframes lvn-loader-bounce {
    from {
        transform: translateY(0);
        opacity: 0.6;
    }

    to {
        transform: translateY(-15px);
        opacity: 1;
    }
}

/* Modifier khi loader nằm trong button */
button .lvn-common-loader {
    padding: 0;
    min-height: auto;
    gap: 6px;
    display: inline-flex;
    width: auto;
}

button .lvn-common-loader .lvn-loader-dot {
    width: 8px;
    height: 8px;
    animation: lvn-loader-bounce-btn 0.6s infinite alternate;
}

@keyframes lvn-loader-bounce-btn {
    from {
        transform: translateY(0);
        opacity: 0.6;
    }

    to {
        transform: translateY(-6px);
        opacity: 1;
    }
}

.lvn-loading {
    position: relative;
    min-height: 200px;
    /* Đảm bảo không bị giật layout khi tải */
    pointer-events: none;
}

.lvn-flex-row {
    display: flex;
    justify-content: space-around;
}

.lvn-tabular-row {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1.2fr;
    gap: 5px;
    align-items: center;
    padding: 2px 0;
}

.lvn-tabular-row .lvn-flex-row-item {
    text-align: center;
}

.lvn-tabular-row .lvn-flex-row-item:first-child {
    text-align: right;
    padding-right: 15px;
}

.lvn-tabular-row .lvn-flex-row-item:last-child {
    text-align: left;
    padding-left: 15px;
}

.lvn-tabular-row-ext {
    display: grid;
    grid-template-columns: 140px 140px 1fr;
    gap: 15px;
    align-items: center;
    padding: 8px 0;
}

@media (max-width: 768px) {
    .lvn-tabular-row-ext {
        grid-template-columns: 125px 1fr;
        gap: 2px 10px;
    }

    .lvn-tabular-row-ext .lvn-flex-row-item:first-child {
        grid-row: span 2;
        align-self: start;
        padding-top: 5px;
    }

    .lvn-tabular-row-ext .lvn-flex-row-item:nth-child(2) {
        grid-column: 2;
        grid-row: 1;
        font-weight: 600;
    }

    .lvn-tabular-row-ext .lvn-flex-row-item:last-child {
        grid-column: 2;
        grid-row: 2;
        padding-top: 0;
        color: var(--lvn-text-muted);
        font-style: italic;
        font-size: 0.8rem;
        text-align: left;
    }
}

.lvn-flex-row-item {}

.lvn-section.lvn-nenlam-kiengky .lvn-flex-row-item {
    border-bottom: 1px dashed rgba(var(--lvn-border), 1);
}

/* Grid Layout for Nen Lam / Kieng Ky */
.lvn-grid-layout {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 1rem;
}

.lvn-grid-item {
    padding: 10px;
    background: var(--lvn-bg-light);
    border: 1px solid var(--lvn-border);
    border-radius: var(--lvn-radius-md, 8px);
    text-align: center;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--lvn-text-main);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
}

.lvn-grid-item:hover {
    background: var(--lvn-bg-white);
    box-shadow: var(--lvn-shadow-sm);
    transform: translateY(-2px);
    border-color: var(--lvn-primary-color);
}

@media (max-width: 768px) {
    .lvn-grid-layout {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* --- [MONTH HEADER - COMMON STYLE] --- */
.lvn-month-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
    width: 100%;
}

.lvn-month-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.lvn-month-left button {
    margin: 0;
}

.lvn-current-time-display {
    font-size: 18px;
    font-weight: 600;
    min-width: 160px;
    text-align: center;
}

.lvn-prev-month,
.lvn-next-month,
.lvn-current-month {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    border-radius: 4px;
    height: 36px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.lvn-prev-month,
.lvn-next-month {
    width: 46px;
}

.lvn-prev-month svg,
.lvn-next-month svg {
    width: 22px;
    height: 22px;
}

.lvn-current-month {
    padding: 0 12px;
    gap: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 13px;
    white-space: nowrap;
}

.lvn-current-month svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.lvn-prev-month:hover,
.lvn-next-month:hover,
.lvn-current-month:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.lvn-month-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lvn-select-month,
.lvn-select-year {
    border-radius: 0px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 95px;
    padding: 0.3rem 0.5rem;
    background-color: transparent;
    height: 36px;
    box-sizing: border-box;
}

[data-theme="dark"] .lvn-select-month option,
[data-theme="dark"] .lvn-select-year option {
    background-color: #1a1a1a;
    color: #e0d0b0;
}

.lvn-select-month:focus,
.lvn-select-year:focus {
    outline: none;
}

.lvn-go-month {
    background: linear-gradient(135deg, #ff9a56, #ff7b7b);
    border: none;
    border-radius: 4px;
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 80px;
    height: 36px;
}

.lvn-go-month:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 123, 123, 0.3);
}

/* Biến container chung áp dụng cho cả 3 shortcode */
#lvn-month-section,
#lvn-daiminhnhat-month-section,
#lvn-ngaylecuoi-month-section {
    padding: 10px;
    border: 1px solid #8d82636b;
    position: relative;
    z-index: 1;
    width: 100%;
    box-sizing: border-box;
}

/* Thống nhất bảng lịch 100% chiều ngang */
.lvn-month-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
    table-layout: fixed;
    /* Đảm bảo các cột đều nhau */
}

.lvn-month-table thead th {
    padding: 12px 8px;
    text-align: center;
}

.lvn-month-table tbody td {
    width: 14.28%;
    vertical-align: top;
    border: 1px solid #c9a84c4a;
    position: relative;
    transition: all 0.3s ease;
}

.lvn-day-cell {
    cursor: pointer;
}

.lvn-day-cell:hover {
    background-color: rgba(240, 208, 128, 0.1);
}

.lvn-day-cell.lvn-selected {
    background: #F0D080 !important;
    color: #1F1F1F !important;
}

/* Định dạng nội dung ô ngày trong Bảng Lịch Tháng */
.lvn-month-table .lvn-solar {
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 4px;
}

.lvn-month-table .lvn-lunar {
    font-size: 14px;
    text-align: center;
    margin-bottom: 2px;
    color: #8d8b8b;
}

.lvn-month-table .lvn-can-chi {
    font-size: 1rem;
    text-align: center;
    margin-bottom: 2px;
    color: #888;
}

/* Các loại Legend (Chấm màu / Biểu tượng) */
.lvn-month-footer {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.lvn-month-footer span,
.lvn-month-footer .legend {
    display: flex;
    align-items: center;
    font-size: 13px;
    font-weight: 500;
}

.legend {
    display: flex;
    align-items: center;
    justify-content: center;
}

.legend::before {
    content: '';
    width: 12px;
    height: 12px;
    margin-right: 8px;
    flex-shrink: 0;
}

/* Định nghĩa màu sắc cụ thể cho từng loại Legend */
.legend.hoangdao::before,
.legend.daiminhnhat::before {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
}

.legend.hacdao::before,
.legend.khongdaiminhnhat::before {
    background: linear-gradient(135deg, #ff7b7b, #ff9a56);
}

.legend.super-ngay-le-cuoi::before,
.lvn-month-table .legend.super-ngay-le-cuoi {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.legend.ngay-le-cuoi::before,
.lvn-month-table .legend.ngay-le-cuoi {
    background: linear-gradient(135deg, #facc15, #f59e0b);
}

.legend.bat-tuong::before,
.lvn-month-table .legend.bat-tuong {
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
}

.legend.binh-thuong::before,
.lvn-month-table .legend.binh-thuong {
    background: #9ca3af;
}

.legend.ngay-xau::before,
.lvn-month-table .legend.ngay-xau {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
}

/* Style cho Legend indicator nhỏ trong ô ngày */
.lvn-day-cell .legend {
    position: absolute;
    top: 5px;
    right: 5px;
}

.lvn-day-cell .legend::before {
    width: 10px;
    height: 10px;
    margin-right: 0;
    /* Xóa margin vì không còn text */
}

/* Trường hợp đặc biệt chữ lồng trong Legend (Đại minh nhật) */
.legend.daiminhnhat {
    color: #4facfe;
}

.p-15 {
    padding: 15px;
}

/* --- [TAGS & GLOSSARY TOOLTIP (Shared)] --- */
.tags-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.tag-title {
    font-size: 11px;
    font-weight: 700;
    margin-top: 4px;
    min-width: 60px;
}

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.lvn-tag {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 5px;
    font-weight: 600;
    position: relative;
}

.lvn-tag.tag-danger,
.lvn-tag.tag-success {
    font-family: inherit;
    font-size: 11px;
}

.lvn-tag.tag-danger {
    background: rgba(220, 53, 69, 0.1);
    color: #ea4335;
    border: 1px solid rgba(220, 53, 69, 0.2);
}

.lvn-tag.tag-success {
    background: rgba(40, 167, 69, 0.1);
    color: #34a853;
    border: 1px solid rgba(40, 167, 69, 0.2);
}

.lvn-tag.bonus {
    background: rgba(40, 167, 69, 0.1);
    color: #34a853;
    border: 1px solid rgba(40, 167, 69, 0.2);
}

.lvn-tag.penalty {
    background: rgba(220, 53, 69, 0.1);
    color: #ea4335;
    border: 1px solid rgba(220, 53, 69, 0.2);
}

.lvn-tag.lvn-has-desc {
    cursor: help;
}

.lvn-tag.lvn-has-desc:hover::after,
.lvn-tag.lvn-has-desc.is-active::after {
    content: attr(data-desc);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(31, 41, 55, 0.95);
    color: #fff;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 12px;
    width: 220px;
    z-index: 100;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    margin-bottom: 10px;
    font-weight: 400;
    line-height: 1.5;
    text-align: left;
    white-space: pre-wrap;
    /* Quan trọng để tooltip xuống dòng được với \A hoặc &#10; */
    display: block;
}

.lvn-tag.lvn-has-desc:hover::before,
.lvn-tag.lvn-has-desc.is-active::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(31, 41, 55, 0.95);
    margin-bottom: -2px;
    z-index: 100;
    display: block;
}



/* Mobile specific tooltip adjustment */
@media (max-width: 768px) {
    .lvn-month-header {
        flex-direction: column;
        align-items: center;
    }

    .lvn-month-left,
    .lvn-month-right {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 10px;
    }

    .lvn-month-right .lvn-current-month {
        width: 100%;
    }

    .lvn-current-time-display {
        min-width: 120px;
    }

    .lvn-month-table * {
        font-size: 0.8rem;
    }



    .lvn-tag.lvn-has-desc.is-active::after {
        position: relative;
        bottom: 0;
        left: 0;
        transform: none;
        width: 100%;
        margin-top: 10px;
        margin-bottom: 5px;
        display: block;
        box-sizing: border-box;
    }

    .lvn-tag.lvn-has-desc.is-active::before {
        display: none;
    }

    .lvn-month-table tbody .lvn-day-cell {
        height: auto !important;
    }

    .lvn-month-table tbody .lvn-day-cell,
    .lvn-month-table tbody .lvn-day-cell .lvn-solar,
    .lvn-month-table tbody .lvn-day-cell .lvn-lunar,
    .lvn-month-table tbody .lvn-day-cell .lvn-can-chi {
        padding: 0;
        margin: 0;
    }

    .lvn-month-table tbody .lvn-day-cell .lvn-solar {}

    .lvn-month-table tbody .lvn-day-cell .lvn-lunar {
        font-size: 12px;
    }

    .lvn-month-table tbody .lvn-day-cell .lvn-can-chi {
        font-size: 0.6rem;
    }

    .lvn-day-cell .legend {
        right: 2px;
        top: 2px;
    }

    #lvn-month-section .legend::before {
        content: '';
        width: 6px;
        height: 6px;
        margin-right: 0px;
    }
}

/* --- [TOAST MESSENGER] --- */
#lvn-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lvn-toast {
    background: var(--lvn-bg-white);
    color: var(--lvn-text-main);
    padding: 12px 20px;
    border-radius: var(--lvn-radius-md);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    max-width: 400px;
    border-left: 5px solid var(--lvn-primary-color);
    animation: lvn-toast-in 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
    font-size: 14px;
    line-height: 1.4;
}

.lvn-toast.is-error { border-left-color: var(--lvn-danger-color); }
.lvn-toast.is-success { border-left-color: var(--lvn-success-color); }
.lvn-toast.is-warning { border-left-color: var(--lvn-warning-color); }

@keyframes lvn-toast-in {
    from { opacity: 0; transform: translateX(100%) scale(0.9); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

.lvn-toast.is-hiding {
    animation: lvn-toast-out 0.3s ease forwards;
}

@keyframes lvn-toast-out {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100%); }
}

@media (max-width: 768px) {
    #lvn-toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }
    .lvn-toast {
        max-width: 100%;
        min-width: auto;
    }
}