/* =============================================================================
   UTILITIES.CSS - Quick Navigation, History, Footer, Responsive
   =============================================================================
   Contains: Quick Nav Buttons, History Section, Footer Contact, Status Badges,
             ALL Media Queries
   ============================================================================= */

/* =============================================================================
   QUICK NAVIGATION - Links to Mobile-Friendly Subpages
   ============================================================================= */

.quick-nav-container {
    margin-top: 30px;
}

.quick-nav-card {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.1) 0%, rgba(33, 150, 243, 0.08) 100%);
    border: 2px solid rgba(212, 175, 55, 0.4);
}

.quick-nav-card .card-header {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.2) 0%, rgba(33, 150, 243, 0.15) 100%);
}

.quick-nav-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    padding: 10px;
}

.quick-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 30px;
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.3s ease;
    min-width: 160px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.quick-nav-btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.quick-nav-btn .nav-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.quick-nav-btn .nav-text {
    font-size: 1.1rem;
    font-weight: 700;
    font-family: var(--font-heading);
}

.quick-nav-btn .nav-desc {
    font-size: 0.8rem;
    opacity: 0.8;
    margin-top: 4px;
}

/* Nguyên Cục Button */
.nguyencuc-btn {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.3) 0%, rgba(76, 175, 80, 0.1) 100%);
    color: #81C784;
}

.nguyencuc-btn:hover {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.5) 0%, rgba(76, 175, 80, 0.2) 100%);
    border-color: rgba(76, 175, 80, 0.5);
}

/* Đại Vận Button */
.daivan-btn {
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.3) 0%, rgba(33, 150, 243, 0.1) 100%);
    color: #64B5F6;
}

.daivan-btn:hover {
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.5) 0%, rgba(33, 150, 243, 0.2) 100%);
    border-color: rgba(33, 150, 243, 0.5);
}

/* Niên Vận Button */
.nienvan-btn {
    background: linear-gradient(135deg, rgba(156, 39, 176, 0.3) 0%, rgba(156, 39, 176, 0.1) 100%);
    color: #CE93D8;
}

.nienvan-btn:hover {
    background: linear-gradient(135deg, rgba(156, 39, 176, 0.5) 0%, rgba(156, 39, 176, 0.2) 100%);
    border-color: rgba(156, 39, 176, 0.5);
}

/* =============================================================================
   HISTORY SECTION - Lịch Sử Phân Tích
   ============================================================================= */

.history-section {
    background-color: var(--bg-card);
    padding: 20px 30px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    margin-top: 20px;
    border: 1px solid rgba(212, 175, 55, 0.15);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
}

.history-header h2 {
    font-family: var(--font-heading);
    color: var(--accent-gold);
    font-size: 1.2rem;
    margin: 0;
}

.btn-clear-history {
    background: transparent;
    border: 1px solid rgba(244, 67, 54, 0.5);
    color: #EF5350;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.btn-clear-history:hover {
    background: rgba(244, 67, 54, 0.2);
    border-color: #EF5350;
}

.history-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-card {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.history-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(212, 175, 55, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.history-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.history-card-title {
    font-weight: 600;
    color: var(--accent-gold);
    font-size: 1rem;
}

.history-card-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.history-card-body {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.history-info-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 10px;
    border-radius: 15px;
}

.history-info-item .icon {
    font-size: 0.9rem;
}

.history-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.history-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.progress-bar-wrapper {
    width: 80px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-gold), #e5c454);
    border-radius: 3px;
    transition: width 0.5s ease;
}

.history-actions {
    display: flex;
    gap: 8px;
}

.btn-history-action {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-history-action.load {
    color: #4CAF50;
}

.btn-history-action.load:hover {
    background: rgba(76, 175, 80, 0.2);
}

.btn-history-action.delete {
    color: #EF5350;
}

.btn-history-action.delete:hover {
    background: rgba(244, 67, 54, 0.2);
}

.history-empty {
    text-align: center;
    padding: 30px;
    color: var(--text-secondary);
}

.history-empty-icon {
    font-size: 3rem;
    margin-bottom: 10px;
    opacity: 0.5;
}

/* Gender badge styles */
.gender-badge {
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.gender-badge.male {
    background: rgba(33, 150, 243, 0.2);
    color: #64B5F6;
}

.gender-badge.female {
    background: rgba(233, 30, 99, 0.2);
    color: #F48FB1;
}

/* Status badge styles */
.status-badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.status-badge.vuong {
    background: rgba(76, 175, 80, 0.2);
    color: #81C784;
}

.status-badge.suy {
    background: rgba(244, 67, 54, 0.2);
    color: #EF5350;
}

.status-badge.neutral {
    background: rgba(255, 193, 7, 0.2);
    color: #FFD54F;
}

/* =============================================================================
   FOOTER CONTACT STYLES - Subtle but accessible
   ============================================================================= */

footer {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-top: 1px solid rgba(212, 175, 55, 0.2);
    margin-top: 30px;
}

footer p {
    margin: 5px 0;
}

.footer-contact {
    margin-top: 10px;
    font-size: 0.8rem;
    opacity: 0.85;
    transition: opacity 0.3s ease;
}

.footer-contact:hover {
    opacity: 1;
}

.footer-contact span {
    color: var(--text-secondary);
}

.footer-contact a {
    color: var(--accent-gold);
    text-decoration: none;
    margin-left: 5px;
    transition: all 0.3s ease;
}

.footer-contact a:hover {
    text-decoration: underline;
    filter: brightness(1.2);
}

/* =============================================================================
   RESPONSIVE - Mobile Adjustments (ALL MEDIA QUERIES)
   ============================================================================= */

@media (max-width: 768px) {
    .section-container {
        flex-direction: column;
    }

    .base-scores-row {
        flex-wrap: wrap;
    }

    .dual-pie-container,
    .triple-pie-container {
        flex-direction: column;
    }

    .pie-arrow {
        transform: rotate(90deg);
    }

    .pie-chart-container.small {
        width: 120px;
        height: 120px;
    }

    .pie-chart-center.small {
        width: 70px;
        height: 70px;
    }

    /* Collapsible responsive */
    .calculation-details summary {
        padding: 12px 14px;
        font-size: 0.9rem;
    }

    .toggle-icon {
        width: 18px;
        height: 18px;
        font-size: 0.7rem;
    }

    .toggle-hint {
        font-size: 0.75rem;
    }

    .details-content {
        padding: 12px;
    }

    /* Pillar grid responsive */
    .pillar-grid {
        min-width: 500px;
        gap: 4px;
    }

    .pillar-column {
        padding: 8px 3px;
    }

    .pillar-can,
    .pillar-chi {
        font-size: 0.8rem;
        padding: 6px 2px;
    }

    .pillar-label {
        font-size: 0.65rem;
    }

    .interaction-legend {
        gap: 10px;
    }

    .legend-item {
        font-size: 0.7rem;
    }
}

@media (max-width: 600px) {
    .pie-chart-container {
        width: 180px;
        height: 180px;
    }

    .pie-chart-center {
        width: 100px;
        height: 100px;
    }

    .pie-total {
        font-size: 1.4rem;
    }

    .pie-legend {
        gap: 10px;
    }

    .legend-item {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    /* Quick nav responsive */
    .quick-nav-buttons {
        flex-direction: column;
        gap: 15px;
    }

    .quick-nav-btn {
        width: 100%;
        flex-direction: row;
        justify-content: flex-start;
        gap: 15px;
        padding: 15px 20px;
    }

    .quick-nav-btn .nav-icon {
        font-size: 1.5rem;
        margin-bottom: 0;
    }

    .quick-nav-btn .nav-text {
        font-size: 1rem;
    }

    .quick-nav-btn .nav-desc {
        display: none;
    }

    /* History section responsive */
    .history-section {
        padding: 15px 20px;
    }

    .history-card-header {
        flex-direction: column;
        gap: 5px;
    }

    .history-card-body {
        flex-wrap: wrap;
    }

    .history-card-footer {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .history-progress {
        width: 100%;
    }

    .progress-bar-wrapper {
        flex: 1;
    }
}

/* =============================================================================
   MOBILE COMPARISON TABLE - Responsive for small screens
   USER REQUIREMENT: Bars MUST be visible, use horizontal scroll
   FIXED: Title stays fixed, only table scrolls horizontally
   ============================================================================= */

/* Wrapper for comparison section - title + scrollable table */
.calc-section-wrapper {
    margin: 15px 0;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 12px;
}

.calc-section-wrapper h5 {
    color: var(--accent-gold, #D4AF37);
    font-size: 1rem;
    margin-bottom: 12px;
    padding: 0;
}

/* Table scroll wrapper - ONLY this scrolls horizontally */
.table-scroll-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* STICKY FIRST COLUMN - Keep "Hành" column fixed while scrolling */
.comparison-table th:first-child,
.comparison-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--bg-dark, #1a1625);
}

@media (max-width: 768px) {

    /* Add scroll hint indicator AFTER the table */
    .table-scroll-wrapper::after {
        content: '← Cuộn để xem thêm →';
        display: block;
        text-align: center;
        font-size: 0.7rem;
        color: var(--text-secondary, #888);
        opacity: 0.7;
        padding-top: 8px;
    }

    /* Make comparison tables scrollable but complete */
    .comparison-table {
        font-size: 0.8rem;
        min-width: 550px;
        table-layout: fixed;
    }

    .comparison-table th,
    .comparison-table td {
        padding: 8px 6px;
        white-space: nowrap;
    }

    /* KEEP bars visible - reduce their min-width for compact display */
    .comparison-bar {
        min-width: 80px;
        max-width: 100px;
    }

    .three-stage-bars {
        min-width: 90px;
        max-width: 110px;
    }

    /* Smaller bar labels */
    .bar-label {
        font-size: 0.65rem;
        width: 20px;
    }

    /* Three-stage table (6 columns) needs more width */
    .comparison-table.three-stage {
        min-width: 650px;
    }

    .comparison-table.three-stage th,
    .comparison-table.three-stage td {
        padding: 6px 5px;
        font-size: 0.75rem;
    }

    /* Progress bars in three-stage table */
    .three-stage-bars .progress-stage {
        height: 5px;
    }

    .stage-bar-row {
        gap: 4px;
    }

    /* Wrapper adjustments for mobile */
    .calc-section-wrapper {
        padding: 10px;
        margin: 10px 0;
    }

    .calc-section-wrapper h5 {
        font-size: 0.9rem;
        margin-bottom: 10px;
    }
}

/* Very small screens - even more compact but still visible */
@media (max-width: 480px) {
    .comparison-table {
        min-width: 520px;
        font-size: 0.75rem;
    }

    .comparison-table th,
    .comparison-table td {
        padding: 6px 4px;
    }

    .comparison-table.three-stage {
        min-width: 600px;
    }

    .comparison-table.three-stage th,
    .comparison-table.three-stage td {
        padding: 5px 4px;
        font-size: 0.7rem;
    }

    /* Compact bars */
    .comparison-bar {
        min-width: 70px;
    }

    .three-stage-bars {
        min-width: 80px;
    }

    .bar-label {
        font-size: 0.6rem;
        width: 18px;
    }
}

/* =============================================================================
   BACK TO TOP BUTTON - Float button for quick scroll to top
   ============================================================================= */

.back-to-top {
    position: fixed;
    bottom: 80px;
    /* Above bottom nav on mobile */
    right: 16px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-gold, #D4AF37), #b8922e);
    color: var(--bg-primary, #0d0d1a);
    border: none;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 998;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.5);
}

.back-to-top:active {
    transform: scale(0.95);
}

/* On desktop, position higher */
@media (min-width: 769px) {
    .back-to-top {
        bottom: 30px;
        right: 30px;
    }
}