/* ====================================================
   TUTRU.CSS - Complete Bát Tự Mệnh Bàn Stylesheet
   Matches "Nguyên Cát" reference design exactly
   ==================================================== */

@import url('https://fonts.googleapis.com/css2?family=Noto+Serif:ital,wght@0,400;0,600;0,700;1,400&family=Be+Vietnam+Pro:wght@400;500;600;700;800&display=swap');

:root {
    --color-wood: #2e7d32;
    /* Xanh lá - Mộc */
    --color-fire: #c62828;
    /* Đỏ - Hỏa */
    --color-earth: #e67e22;
    /* Cam vàng - Thổ */
    --color-metal: #7f8c8d;
    /* Xám - Kim */
    --color-water: #000000;
    /* Đen - Thủy */
    --color-red: #c0392b;
    --color-dark: #1a1a2e;
    --border: 1px solid #ccc;
    --font-main: 'Be Vietnam Pro', 'Noto Serif', 'Times New Roman', serif;
}

/* =========================================
   WRAPPER + CARD
   ========================================= */
.tutru-menbàn-wrapper {
    max-width: 860px;
    width: 98%;
    margin: 1rem auto;
    font-family: var(--font-main);
}

.printable-sheet {
    background: #fff;
    border: 1px solid #aaa;
    border-radius: 0 !important;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.13);
    overflow: hidden;
    font-family: var(--font-main);
}

/* =========================================
   HEADER
   ========================================= */
.tutru-premium-header {
    background: #fff;
    border-bottom: 2px solid #bbb !important;
    padding: 12px 18px !important;
}

.tutru-logo img {
    border-radius: 50%;
    height: 55px;
    width: 55px;
    object-fit: cover;
}

.header-center h3 {
    font-family: var(--font-main);
    font-size: 1.35rem !important;
    letter-spacing: 3px !important;
    color: #1a1a2e !important;
    font-weight: 800 !important;
}

.header-right {
    font-size: 0.8rem !important;
    line-height: 1.7;
}

/* =========================================
   MAIN TABLE
   ========================================= */
.tutru-menbàn-table {
    border-collapse: collapse;
    width: 100%;
    table-layout: fixed;
    font-family: var(--font-main);
}

.tutru-menbàn-table td {
    border: var(--border);
    padding: 7px 5px;
    text-align: center;
    vertical-align: middle;
    font-size: 0.82rem;
}

/* Labels (left column) */
.label-column {
    background-color: #eef2f7;
    color: #1a1a2e;
    font-size: 0.7rem !important;
    font-weight: 700 !important;
    text-align: center !important;
    padding: 5px 3px !important;
    letter-spacing: 0.3px;
    width: 14% !important;
    line-height: 1.3;
    vertical-align: middle;
}

/* Highlight current Nhật Chủ (Day Pillar header) */
.tutru-nhatchu-label {
    background-color: #fff8f0;
    font-weight: 700;
    color: #1a1a2e;
    font-size: 0.78rem !important;
}

/* =========================================
   BÁT TỰ ROW - Large Pillars
   ========================================= */
.tutru-gz-cell {
    padding: 8px 5px !important;
    background: #fff;
}

.tutru-can {
    display: block;
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1.1;
    font-family: var(--font-main);
    letter-spacing: 0.5px;
}

.tutru-chi {
    display: block;
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1.1;
    font-family: var(--font-main);
    letter-spacing: 0.5px;
}

/* Day pillar Can (Nhật Chủ) is always red */
.tutru-can.tutru-nhatchu {
    color: var(--color-fire) !important;
}

/* =========================================
   DATA ROWS (Tàng Ẩn, Phó Tinh, etc.)
   ========================================= */
.tutru-data-row td {
    font-size: 0.78rem;
    background: #fff;
    color: #1a1a2e;
}

/* =========================================
   SECTION DIVIDERS (Đại Vận / Lưu Niên)
   ========================================= */
.tutru-section-divider {
    background: #eef2f7 !important;
    border-top: var(--border) !important;
    border-bottom: var(--border) !important;
    padding: 5px 14px !important;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: #1a1a2e;
    text-transform: uppercase;
}

/* =========================================
   ĐẠI VẬN / LƯU NIÊN CELLS
   ========================================= */
.tutru-dv-container {
    background: #fff;
    gap: 0;
    flex-wrap: nowrap !important;
}

.tutru-dv-cell {
    flex: 1 1 0;
    text-align: center;
    border-right: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    padding: 6px 3px;
    min-width: 76px;
    background: #fff;
    transition: background 0.18s;
}

.tutru-dv-cell:last-child {
    border-right: none;
}

.dv-gz {
    display: block;
    font-weight: 700;
    font-size: 0.88rem;
    line-height: 1.2;
    font-family: var(--font-main);
}

.dv-age {
    display: block;
    font-size: 0.68rem;
    font-weight: 600;
    color: #1673cc;
    margin-top: 2px;
}

.dv-year {
    display: block;
    font-size: 0.68rem;
    color: #555;
}

/* Active cycle highlight - matches the orange/yellow in reference */
.active-cycle {
    background-color: #fce8b2 !important;
    border-color: #e6a800 !important;
}

.active-year {
    background-color: #fce8b2 !important;
    border-color: #e6a800 !important;
}

/* =========================================
   BOTTOM SECTION - Extra Info + Thần Sát
   ========================================= */
.extra-item {
    background: #f9f9f9;
}

.extra-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: #1a1a2e;
    background: #eef2f7 !important;
    padding: 4px 3px;
    text-align: center;
    text-transform: uppercase;
    border-bottom: 1px solid #ccc;
}

#tutru-menh-cung,
#tutru-thai-nguyen,
#tutru-nien-khong,
#tutru-nhat-khong {
    font-size: 0.82rem;
    color: #1a1a2e;
    font-weight: 600;
    line-height: 1.5;
}

/* Thần sát headers */
.than-sat-header {
    font-size: 0.72rem;
    font-weight: 700;
    color: #1a1a2e;
    letter-spacing: 0.5px;
    background: #eef2f7;
    border-bottom: 1px solid #ccc !important;
    padding: 5px 3px;
    text-align: center;
}

/* =========================================
   LEGEND AT BOTTOM
   ========================================= */
.tutru-legend {
    background: #f5f5f5 !important;
    border-top: 1px solid #bbb !important;
    font-size: 0.75rem;
    padding: 6px 10px !important;
    gap: 16px;
    justify-content: center;
    align-items: center;
}

.legend-box {
    width: 22px;
    height: 10px;
    display: inline-block;
    border: 1px solid rgba(0, 0, 0, 0.15);
    margin-right: 4px;
    vertical-align: middle;
}

.legend-box.metal {
    background-color: #7f8c8d;
}

.legend-box.wood {
    background-color: #2e7d32;
}

.legend-box.water {
    background-color: #000000;
}

.legend-box.fire {
    background-color: #c62828;
}

.legend-box.earth {
    background-color: #e67e22;
}

/* =========================================
   TEXT COLOR CLASSES (Five Elements)
   ========================================= */
.text-success-gz {
    color: #2e7d32 !important;
}

/* Mộc - Green */
.text-danger-gz {
    color: #c62828 !important;
}

/* Hỏa - Red */
.text-warning-gz {
    color: #e67e22 !important;
}

/* Thổ - Orange */
.text-secondary-gz {
    color: #7f8c8d !important;
}

/* Kim - Gray */
.text-primary-gz {
    color: #000000 !important;
}

/* Thủy - Black */

/* =========================================
   PRINT STYLES
   ========================================= */
@media print {

    body,
    html {
        margin: 0;
        padding: 0;
        background: #fff !important;
    }

    .no-print,
    nav,
    .navbar,
    .jeg_topbar,
    .jeg_midbar,
    .jeg_bottombar,
    .sidebar,
    .form-container,
    .btn,
    footer,
    .print-tools,
    .tutru-form-card,
    .tutru-luan-giai-box,
    #section-tutru>.container>.row {
        display: none !important;
    }

    .tutru-menbàn-wrapper {
        margin: 0 !important;
        padding: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    .printable-sheet {
        border: none !important;
        box-shadow: none !important;
        width: 100% !important;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    @page {
        size: A4 portrait;
        margin: 8mm;
    }

    .tutru-menbàn-table td {
        border: 1px solid #bbb !important;
    }
}

/* =========================================
   SCROLLBAR
   ========================================= */
.tutru-dv-container::-webkit-scrollbar {
    height: 4px;
}

.tutru-dv-container::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 10px;
}

/* =========================================
   RESPONSIVE - MOBILE OPTIMIZATION
   ========================================= */
@media screen and (max-width: 768px) {
    .tutru-premium-header {
        flex-direction: column !important;
        text-align: center !important;
        padding: 10px !important;
    }

    .header-left,
    .header-right {
        justify-content: center !important;
        border: none !important;
        padding: 5px 0 !important;
        margin: 0 !important;
    }

    .header-center h3 {
        font-size: 1.1rem !important;
        margin: 10px 0 !important;
    }

    /* Shrink the large pillars */
    .tutru-can {
        font-size: 1.1rem !important;
    }

    .tutru-chi {
        font-size: 1.1rem !important;
    }

    .label-column {
        font-size: 0.65rem !important;
        width: 18% !important;
    }

    .tutru-menbàn-table td {
        padding: 4px 2px !important;
        font-size: 0.75rem !important;
    }

    /* Extra Info Section */
    .extra-info-grid {
        flex-direction: column !important;
    }

    .col-md-2,
    .col-md-10 {
        max-width: 100% !important;
        flex: 0 0 100% !important;
    }

    /* Make Đại Vận, Lưu Niên containers scrollable if needed */
    .tutru-dv-container {
        padding-bottom: 8px !important;
    }

    .extra-item {
        border-bottom: 1px solid #eee;
    }
}

@media screen and (max-width: 480px) {
    .tutru-menbàn-wrapper {
        width: 100%;
        margin: 0.5rem 0;
    }

    .printable-sheet {
        border: none;
    }

    /* Micro-scaling for very small screens */
    .tutru-menbàn-table {
        font-size: 0.7rem;
    }

    .header-right {
        font-size: 0.75rem !important;
    }
}

/* Compact Timezone Select (Select2 override) */
.select2-container--default .select2-selection--single {
    height: 32px !important;
    font-size: 0.75rem !important;
    border: 1px solid #ced4da !important;
    border-radius: 4px !important;
    padding-top: 2px !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 28px !important;
    color: #495057 !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 30px !important;
}

.select2-dropdown {
    font-size: 0.75rem !important;
    border: 1px solid #ced4da !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

.select2-results__option {
    padding: 6px 10px !important;
}

.select2-search--dropdown .select2-search__field {
    padding: 4px 8px !important;
    font-size: 0.75rem !important;
    border: 1px solid #ddd !important;
}