/* Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    /* Gradient matching the provided image */
    background: linear-gradient(135deg, #7ab2eb 0%, #b2a3d4 40%, #52187a 100%);
    background-attachment: fixed;
    color: #333;
    min-height: 100vh;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Toggles (ẩn hiện các tầng sao) */
.hide-sao-luu .luu-tinh { display: none !important; }
.hide-sat-tinh .sao-sat-tinh { display: none !important; }
.hide-trong-so .trong-so { display: none !important; }
.hide-phu-tinh .phu-tinh:not(.tu-hoa) { display: none !important; }

/* Bố cục phụ tinh mỗi sao 1 dòng */
.sao-group {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.sao-group .sao {
    display: block;
}

.hidden { display: none !important; }

/* Main Container */
.main-container {
    width: 100%;
    max-width: 1000px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding: 0 1rem;
    margin-bottom: 2rem;
}

/* Header & Navigation */
.top-header {
    width: 100%;
    background-color: #fff;
    padding: 20px 0;
    display: flex;
    justify-content: center;
}

.header-container {
    width: 100%;
    max-width: 1000px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
}

.logo-placeholder {
    display: flex;
    justify-content: center;
    align-items: center;
}
.logo-placeholder img {
    height: 50px;
    width: auto;
    object-fit: contain;
}

.auth-section {
    font-size: 1.1rem;
}

.auth-link {
    color: #ef5350;
    text-decoration: none;
}

.auth-link:hover {
    text-decoration: underline;
}

.main-menu-container {
    width: 100%;
    max-width: 1000px;
    margin: 20px 0;
    padding: 0 1rem;
}

.main-menu {
    display: flex;
    gap: 4px;
}

/* Dropdown CSS */
.menu-dropdown {
    position: relative;
    display: flex;
    flex: 1;
}

.menu-dropdown > .menu-item {
    width: 100%;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: #52187a; /* Solid background */
    min-width: 200px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.5);
    z-index: 1000;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
}

.dropdown-content a {
    color: #ffffff; /* White text */
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
    transition: background-color 0.3s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.dropdown-content a:last-child {
    border-bottom: none;
}

.dropdown-content a:hover {
    background-color: rgba(255, 215, 0, 0.1);
    color: var(--gold-primary);
}

.menu-dropdown:hover .dropdown-content {
    display: block;
}

.menu-item {
    flex: 1;
    background-color: rgba(255, 255, 255, 0.35);
    color: #8b0000;
    text-align: center;
    padding: 15px 0;
    text-decoration: none;
    font-weight: bold;
    text-transform: uppercase;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
    border-radius: 4px;
}

.menu-item.active {
    background-color: #b89753; /* Gold */
    color: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.menu-item:hover:not(.active) {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Cards */
.card {
    background-color: #F8F4E6;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.section-title {
    color: #8B5A2B; /* Brown/Gold */
    font-family: 'Merriweather', serif;
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #e0d8c3;
    padding-bottom: 0.5rem;
}

/* Form Styles */
.form-group {
    margin-bottom: 1rem;
}

.row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.col-12 { flex: 0 0 100%; }
.col { flex: 1; min-width: 80px; }

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: #4a4a4a;
}

.form-control {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #d1c9b4;
    border-radius: 4px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    background-color: #fff;
}

.form-control:focus {
    outline: none;
    border-color: #b89753;
}

.radio-group {
    align-items: center;
    gap: 1.5rem;
}

.radio-label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-weight: normal;
    cursor: pointer;
}

.five-cols .col { flex: 1 1 15%; }
.two-cols .col { flex: 1 1 45%; }

/* Buttons */
.action-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    justify-content: center;
}

.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    font-family: 'Inter', sans-serif;
}

.btn:hover { opacity: 0.9; }

.btn-gold {
    background: linear-gradient(to right, #d4af37, #e5c158);
    color: #111;
}

.btn-brown {
    background-color: #4a3320;
    color: #fff;
}

.btn-dark-green {
    background-color: #3b4636;
    color: #fff;
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
}

/* Result Toolbar */
.result-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    background-color: #eee9d8;
    padding: 0.5rem 1rem;
    border-radius: 4px;
}

.toolbar-options {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.toolbar-options label {
    margin-bottom: 0;
    font-weight: normal;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

.inline-input {
    width: 60px;
    display: inline-block;
    padding: 0.2rem;
    text-align: center;
}

.info-summary {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 1rem;
    color: #333;
}

/* Chart Wrapper */
.chart-outer-wrapper {
    width: 100%;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    background-color: #F8F4E6;
}

#chart-wrapper {
    position: relative;
    width: 800px; /* Fixed width to maintain aspect ratio */
    height: 1100px;
    min-width: 800px;
    min-height: 1100px;
    flex-shrink: 0;
    background-color: #F2EBE1; /* Màu giấy bồi */
    border: 2px solid #000000;
    padding: 2px;
}

#chart-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(4, minmax(0, 1fr));
    width: 100%;
    height: 100%;
    position: relative;
}

#arrow-svg-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 1;
}

.arrow-line { stroke: #686868; stroke-width: 1; }
.arrow-line.xung-chieu { stroke-dasharray: 3, 3; }

/* Palaces */
.palace {
    border: 1px solid #000000;
    display: flex;
    flex-direction: column;
    padding: 15px 4px 15px 4px;
    position: relative;
    color: #333333; /* Dark text for light bg */
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.cung-ty  { grid-area: 1 / 1; } .cung-ngo { grid-area: 1 / 2; }
.cung-mui { grid-area: 1 / 3; } .cung-than{ grid-area: 1 / 4; }
.cung-thin{ grid-area: 2 / 1; } .cung-dau { grid-area: 2 / 4; }
.cung-mao { grid-area: 3 / 1; } .cung-tuat{ grid-area: 3 / 4; }
.cung-dan { grid-area: 4 / 1; } .cung-suu { grid-area: 4 / 2; }
.cung-ty-bottom { grid-area: 4 / 3; } .cung-hoi { grid-area: 4 / 4; }

.palace-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: bold;
    color: #000000; /* Brown/Gold */
}

.menh-tai-quan-bg {
    background-color: transparent;
}

.ngu-ho-don-text { color: #000000; } /* Default light grey */

.palace-name {
    text-align: center;
    margin: 8px 0;
}

.chinh-tinh-container {
    display: flex;
    flex-direction: column;
    font-family: 'Merriweather', serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: #e5c158; /* Main Gold */
    /* text-shadow removed */
    gap: 0.3rem; /* Thu nhỏ khoảng cách giữa 2 chính tinh */
    padding: 0.6rem 0; /* Bù lại khoảng trống của thẻ br bị xóa để không thay đổi chiều cao tổng */
    line-height: 1.3;
}

.palace-content {
    display: flex;
    justify-content: space-between;
    flex-grow: 1;
    font-size: 0.75rem;
    line-height: 1.3;
}

.sao-column {
    display: flex;
    flex-direction: column;
    width: 48%;
}

.sao-column-left { align-items: flex-start; }
.sao-column-right { align-items: flex-end; text-align: right; }

.palace-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    font-size: 0.8rem;
    margin-top: auto;
}

.tieu-van-chi, .vong-trang-sinh, .dai-van-text {
    color: #000000;
}

.nguyet-han-marker {
    font-size: 0.7rem;
    color: #000000;
}

/* Center Info */
#center-info {
    grid-area: 2 / 2 / 4 / 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 1px solid #000000;
    color: #333333;
    position: relative;
    padding: 0.5rem;
    background-color: transparent;
    z-index: 5;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    gap: 2px;
}

.center-title {
    font-family: 'Merriweather', serif;
    font-size: 1.25rem;
    color: #0000FF;
    margin-bottom: 0;
    letter-spacing: 1px;
}

.center-website {
    font-size: 0.8rem;
    color: #FF0000;
    margin-bottom: 0.25rem;
}

.center-subtitle {
    font-family: 'Merriweather', serif;
    font-size: 1.1rem;
    color: #0000FF;
    margin-bottom: 0.5rem;
}

.center-table {
    width: 85%;
    margin: 0 auto 0.5rem auto;
    font-size: 0.8rem;
    text-align: left;
    border-collapse: collapse;
}

.center-table td {
    padding: 0.15rem;
}

.center-table .lbl {
    font-weight: bold;
    color: #000000;
    width: 40%;
}

.info-block {
    text-align: left;
    width: 85%;
    font-size: 0.8rem;
    line-height: 1.35;
}

.info-block span.lbl {
    font-weight: bold;
    color: #000000;
    display: inline-block;
    width: 40%;
}

.contact-info {
    margin-top: 0.5rem;
    color: #000000;
    font-weight: bold;
    font-size: 0.8rem;
}

/* Tuan Triet Markers */
.tuan-triet-marker {
    position: absolute;
    background-color: #ffffff;
    color: #000000;
    border: 1px solid #000000;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.8rem;
    font-weight: bold;
    z-index: 15;
    transform: translate(-50%, -50%);
}

/* Colors for stars matching the dark theme */
.sao-green { color: #008000; } /* Light green */
.sao-red { color: #FF0000; } /* Light red */
.sao-blue { color: #0000FF; } /* Light blue */
.sao-gray { color: #808080; } /* Gray */
.sao-black { color: #000000; } /* Light gray to replace black on dark bg */
.sao-yellow { color: #D4A017; } /* Yellow/Amber */

/* Hanh colors */
.hanh-kim { color: #808080; }
.hanh-moc { color: #008000; }
.hanh-thuy { color: #000000; }
.hanh-hoa { color: #FF0000; }
.hanh-tho { color: #D4A017; }

/* Custom star boldings */
.sao-bold-1 { font-weight: 700; color: #008000; }
.sao-bold-2 { font-weight: 700; color: #FF0000; }
.sao-bold-3 { font-weight: 600; color: #000000; }

/* Bazi Table Styles */
.bazi-center-table {
    width: 95%;
    margin: 0.25rem auto;
    border-collapse: collapse;
    font-size: 0.75rem;
    color: #000000;
}

.bazi-center-table td {
    border: 1px solid rgba(184, 151, 83, 0.3);
    padding: 2px;
    text-align: center;
}

.bazi-header td {
    font-weight: bold;
    color: #000000;
}

.bazi-can, .bazi-chi {
    font-weight: bold;
    font-size: 0.9rem;
}

.bazi-tang-can {
    font-size: 0.7rem;
    color: #9ca3af;
}

.bazi-truong-sinh {
    font-size: 0.7rem;
    font-style: italic;
}

.bazi-dai-van {
    text-align: left !important;
    padding-top: 4px !important;
    font-size: 0.75rem;
    color: #b89753;
}

.hide-phu-tinh .tuan-triet-marker { display: none !important; }


/* Responsive adjustments for header */
@media (max-width: 768px) {
    .auth-section {
        font-size: 0.85rem !important;
    }
    .logo-placeholder img {
        width: 120px !important;
    }
    .banner-container div {
        height: 100px !important; /* Smaller banner on mobile */
    }
}


/* Mystic Banner Styles */
.mystic-banner {
    position: relative;
    width: 100%;
    aspect-ratio: 5 / 1;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: #fff;
    background-color: #2b1b3d;
    background-image: radial-gradient(circle at 50% 0%, #4a2c5a 0%, transparent 70%),
                      radial-gradient(circle at 100% 100%, #1e112a 0%, transparent 50%);
}

.mystic-banner::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    opacity: 0.15;
    background-image: 
        radial-gradient(circle at center, transparent 0, transparent 40px, #b89753 40px, #b89753 42px, transparent 42px),
        radial-gradient(circle at center, transparent 0, transparent 60px, #b89753 60px, #b89753 61px, transparent 61px);
    background-size: 100px 100px;
    z-index: 1;
    pointer-events: none;
}

.mystic-banner-content {
    position: relative;
    z-index: 2;
    padding: 10px;
}

.mystic-banner-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0 0 5px 0;
    color: #ffd700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.mystic-banner-text {
    font-size: 0.95rem;
    margin: 0 0 15px 0;
    color: #f8f4e6;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.mystic-banner-btn {
    display: inline-block;
    padding: 8px 24px;
    background: linear-gradient(135deg, #b89753, #8a6d3b);
    color: #fff !important;
    font-weight: bold;
    text-decoration: none;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.mystic-banner-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(184, 151, 83, 0.4);
    text-decoration: none;
}

@media (max-width: 768px) {
    .mystic-banner {
        aspect-ratio: unset !important;
        height: auto !important;
        min-height: 150px !important;
        padding: 20px 10px;
    }
    .mystic-banner-title {
        font-size: 1.3rem;
        margin-bottom: 2px;
    }
    .mystic-banner-text {
        font-size: 0.85rem;
        margin-bottom: 8px;
    }
    .banner-btn-group {
        gap: 8px;
        margin-top: 5px;
    }
    .social-banner-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
        white-space: nowrap;
    }
}


/* --- Banners Social Buttons --- */
.banner-btn-group {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
    margin-top: 15px;
    flex-wrap: nowrap;
    width: 100%;
}

.social-banner-btn {
    display: inline-flex;
    align-items: center;
    padding: 10px 24px;
    color: #fff !important;
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: all 0.2s ease-in-out;
}

.social-banner-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
    text-decoration: none;
    color: #fff !important;
}

.btn-fb {
    background-color: #1877F2;
}

.btn-zl {
    background-color: #0068FF;
}


.luan-giai-status {
    color: #000000;
    font-weight: bold;
}
