/* --- file: static/css/style.css --- */

/* =========================================
   1. GLOBAL STYLES (Chung)
   ========================================= */
body, html {
    height: 100%;
    background-color: #f4f6f8;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Các style phụ trợ */
.transit-input { font-weight: bold; color: #198754; }
.planet-symbol { font-weight: bold; cursor: help; font-size: 24px;}
.chart-tooltip {
    position: absolute;
    text-align: left;
    padding: 10px;
    font: 14px sans-serif;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    border-radius: 4px;
    pointer-events: none;
    z-index: 9999;
    max-width: 250px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
.tt-header { font-size: 10px; text-transform: uppercase; color: #aaa; letter-spacing: 1px; margin-bottom: 4px; }
.tt-title { font-size: 16px; font-weight: bold; color: #ffd700; }
.tt-pos { color: #0dcaf0; }
.tt-content { line-height: 1.4; font-size: 13px; }

/* Map Styling Chung */
#map-container {
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0; 
}
#map-status {
    font-size: 11px;
    background: #f8f9fa;
    padding: 4px 8px;
    border-bottom: 1px solid #eee;
    font-weight: bold;
    color: #666;
    text-align: center;
}

/* SVG Responsive */
#astro-wheel {
    width: 100%;
    height: 100%;
    display: block;
}

/* =========================================
   2. DESKTOP STYLES (Chỉ áp dụng cho màn hình > 768px)
   ========================================= */
@media (min-width: 769px) {
    body, html {
        overflow: hidden; /* Desktop không cuộn body */
    }

    /* Ẩn Header Mobile */
    .navbar.d-md-none {
        display: none;
    }

    /* Sidebar Cố định dạng cột */
    .sidebar {
        width: 320px;
        min-width: 320px;
        height: 100vh;
        overflow-y: auto;
        background: #fff;
        border-right: 1px solid #ddd;
        display: flex; 
        flex-direction: column;
        z-index: 1050;
        
        /* QUAN TRỌNG: Thiết lập này giúp Sidebar nằm yên bên trái */
        position: relative !important; 
        visibility: visible !important;
        transform: none !important;
    }

    /* Vùng nội dung chính */
    #capture-area {
        flex-grow: 1;
        display: flex;
        flex-direction: row; /* Xếp ngang */
        height: 100vh;
        overflow: hidden;
    }

    .chart-section {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
        background-color: #f4f6f8;
    }

    #chart-wrapper {
        width: 95%;
        max-width: 750px;
        aspect-ratio: 1/1;
        position: relative;
    }

    .info-section {
        width: 350px;
        min-width: 350px;
        display: flex;
        flex-direction: column;
        border-left: 1px solid #eee;
        background: #fff;
        height: 100%;
    }

    .info-top {
        flex: 1;
        overflow-y: auto;
        padding: 10px;
    }

    .info-bottom {
        flex: 0 0 auto;
        padding: 10px;
        background-color: #fcfcfc;
        border-top: 1px solid #eee;
    }

    #map { height: 200px; }
}

/* =========================================
   3. MOBILE & TABLET STYLES (Màn hình <= 768px)
   ========================================= */
@media (max-width: 768px) {
    body, html { 
        height: auto !important; 
        overflow-y: auto !important; 
    }

    /* Sidebar Mobile */
    .sidebar {
        position: fixed !important;
        top: 0; left: 0;
        height: 100vh;
        z-index: 1055;
        border-right: none;
        width: 85% !important; 
        max-width: 400px;
        visibility: hidden; 
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
    }
    .sidebar.show {
        visibility: visible !important;
        transform: none !important;
    }

    /* [SỬA LỖI QUAN TRỌNG TẠI ĐÂY] */
    #capture-area {
        display: flex;
        flex-direction: column !important;
        height: auto !important;
        overflow: visible !important;
        padding-top: 10px;
        
        /* Thêm dòng này để ép khung nội dung bung full chiều rộng */
        width: 100% !important; 
        flex-grow: 1; 
    }

    /* Căn giữa biểu đồ */
    .chart-section {
        width: 100%;
        min-height: 50vh; 
        padding: 0;
        background-color: #fff;
        
        /* Flexbox căn giữa tuyệt đối */
        display: flex;
        justify-content: center;
        align-items: center;
    }

    #chart-wrapper {
        width: 100%; 
        max-width: 100%; /* Cho phép bung hết cỡ trên mobile */
        aspect-ratio: 1/1;
        margin: 0 auto;
    }

    .info-section {
        width: 100% !important;
        border-left: none;
        border-top: 1px solid #ddd;
        height: auto !important;
        
        /* Thay display: block thành flex column để xếp chồng cứng */
        display: flex !important;
        flex-direction: column !important;
    }
    
    .info-top {
        /* Cho phép cuộn nếu bảng dài, nhưng không chiếm hết chỗ */
        max-height: 400px; 
        overflow-y: auto;
        padding: 15px;
        flex: 0 0 auto; /* Không co giãn, giữ nguyên chiều cao nội dung */
    }
    
    .info-bottom {
        padding: 10px;
        flex: 0 0 auto;
        
        /* Tạo khoảng cách rõ ràng với bảng bên trên */
        margin-top: 20px; 
        border-top: 1px dashed #eee; /* Thêm đường kẻ mờ ngăn cách cho đẹp */
    }

    /* Bảng Aspect Grid */
    #right-aspect-grid {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 20px;
        display: flex;         
        justify-content: center;
    }
    
    /* Đảm bảo SVG bên trong luôn nằm giữa ngay cả khi cuộn */
    #right-aspect-grid svg {
        display: block;
        margin: 0 auto;
    }

    #map { height: 250px; }
    
    #astro-wheel text { font-size: 1.3em; }
}