/* General Body and Container Styles */
body {
    font-family: sans-serif;
    margin: 0;
    background-color: #f4f7f6;
    color: #333;
}

.container {
    max-width: 1600px;
    margin: auto;
    padding: 2em;
}

h1,
h2 {
    color: #333;
}

/* Menu Styles */
.navbar {
    overflow: hidden;
    background-color: #333;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.navbar a {
    float: left;
    display: block;
    color: white;
    text-align: center;
    padding: 14px 20px;
    text-decoration: none;
    font-size: 16px;
}

.navbar a:hover {
    background-color: #ddd;
    color: black;
}

.navbar a.active {
    background-color: #4CAF50;
    color: white;
}

/* --- Report Page Specific Styles --- */

/* Header with Title and Email Section */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.content-header h1 {
    margin: 0;
}

/* Email Section */
.email-section {
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.email-section h3 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 1em;
    color: #333;
    font-weight: 600;
}

.email-form {
    display: flex;
    align-items: center;
}

.email-form input[type="email"] {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px 0 0 4px;
    border-right: none;
    outline: none;
    transition: border-color 0.3s;
    min-width: 220px;
}

.email-form input[type="email"]:focus {
    border-color: #007bff;
}

.email-form button {
    padding: 10px 15px;
    border: 1px solid #007bff;
    background-color: #007bff;
    color: white;
    cursor: pointer;
    border-radius: 0 4px 4px 0;
    transition: background-color 0.3s;
    font-weight: bold;
    white-space: nowrap;
}

.email-form button:hover {
    background-color: #0056b3;
}

/* --- MODIFICATION START: Prettier Dropdown --- */
.controls {
    margin-bottom: 20px;
}

.select-container {
    display: inline-flex;
    align-items: center;
    background-color: #ffffff;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 5px 5px 5px 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.3s, border-color 0.3s;
}

.select-container:hover {
    border-color: #007bff;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.08);
}

.select-container label {
    font-weight: 600;
    color: #333;
    margin-right: 15px;
    font-size: 0.95em;
    white-space: nowrap;
}

.select-container select {
    padding: 10px 35px 10px 15px;
    border: none;
    background-color: transparent;
    font-size: 1em;
    cursor: pointer;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23333%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 10px;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.select-container select:hover {
    background-color: #f0f0f0;
}

/* --- MODIFICATION END --- */


/* Report Table Container (with scrolling) */
.report {
    margin-top: 0px;
    border: 1px solid #ccc;
    padding: 15px;
    border-radius: 5px;
    background-color: white;
    overflow: auto;
    max-height: 75vh;
}


/* --- General Table Styles --- */
.summary-table,
.ranking-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.summary-table th,
.summary-table td,
.ranking-table th,
.ranking-table td {
    border: 1px solid #ccc;
    padding: 8px;
    text-align: center;
    white-space: nowrap;
}

.summary-table thead th,
.ranking-table thead th {
    font-weight: bold;
}

/* --- Summary Table Specific Styles (Preserved) --- */
.summary-table thead th {
    background-color: paleturquoise;
}

.summary-table .header-blue {
    background-color: #007acc !important;
    color: white !important;
    font-weight: bold;
}

.summary-table .column-yellow {
    background-color: #f7fc4b !important;
}

.summary-table .cell-blue {
    background-color: #73b3eeff !important;
    font-weight: bold;
}

.summary-table .cell-yellow {
    background-color: #e0a80dff !important;
    font-weight: bold;
}

.summary-table .cell-orange {
    background-color: #e05b08ff !important;
    font-weight: bold;
}

.summary-table .cell-green {
    background-color: #0fa814ff !important;
    font-weight: bold;
}

.summary-table .cell-gray {
    background-color: #d3d3d3 !important;
    font-weight: bold;
}

.summary-table .cell-light-gray {
    background-color: #f0f0f0 !important;
}

.summary-table .cell-light-yellow {
    background-color: #f0f1d0ff !important;
}


/* --- Ranking Table Specific Styles (Preserved) --- */
.ranking-table thead th {
    background-color: #f0f0f0;
    /* --- MODIFICATION: Sticky header removed. No position: sticky here. --- */
}

.ranking-table .rank-green {
    background-color: #28a745 !important;
    color: white !important;
    font-weight: bold !important;
}

.ranking-table .rank-bold {
    font-weight: bold !important;
}

.ranking-table .diem-header {
    background-color: #bce9ff !important;
    font-weight: bold !important;
}

.ranking-table .tong-diem-cell {
    font-weight: bold !important;
}

.ranking-table .tong-diem-header {
    background-color: #E2EFD9 !important;
    font-weight: bold !important;
}

.ranking-table .rank-final-header {
    background-color: #007acc !important;
    color: white !important;
    font-weight: bold !important;
}

.ranking-table .rank-final-cell {
    font-weight: bold !important;
    background-color: #abe8ee !important;
    /* Light blue background for rank_final column */
}

/* Top 5 and Bottom 5 ranking row styles */
.ranking-table .top-5-row {
    background-color: #d4f8d4 !important;
    /* Light green for top 5 */
}

.ranking-table .bottom-5-row {
    background-color: #f8d4d4 !important;
    /* Light red for bottom 5 */
}

/* Ensure cell-specific styles still apply on colored rows */
.ranking-table .top-5-row .rank-final-cell,
.ranking-table .bottom-5-row .rank-final-cell {
    background-color: #abe8ee !important;
    /* Keep rank_final column color */
}

/* Left-aligned numeric values */
.ranking-table .numeric-left {
    text-align: left !important;
}

/* Tooltip styles */
.tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 350px;
    background-color: #555;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 12px 15px;
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    left: 50%;
    margin-left: -175px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 13px;
    line-height: 1.5;
    white-space: normal;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.tooltip .tooltiptext::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #555 transparent transparent transparent;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* Business Description Table Styles */
.business-description-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.business-description-table th,
.business-description-table td {
    border: 1px solid #ccc;
    padding: 12px 8px;
    text-align: left;
    vertical-align: top;
}

.business-description-table th {
    background-color: #4472C4;
    color: white;
    font-weight: bold;
    text-align: center;
}

.business-description-table td:first-child {
    text-align: left;
    font-weight: bold;
}

.business-description-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.business-description-table tr:hover {
    background-color: #f0f8ff;
}

/* Special styling for main section rows */
.business-description-table tr.section-main {
    background-color: #fff3cd !important;
}

.business-description-table tr.section-main:hover {
    background-color: #ffeaa7 !important;
}

/* Special styling for subsection rows */
.business-description-table tr.section-sub {
    background-color: #d4f8d4 !important;
}

.business-description-table tr.section-sub:hover {
    background-color: #c3f0c3 !important;
}

/* --- Home Page Specific Styles (Preserved) --- */
.welcome-header {
    text-align: center;
    margin: 40px 0;
}

.welcome-header h1 {
    color: #2c3e50;
    font-size: 2.5em;
}

.welcome-header p {
    color: #7f8c8d;
    font-size: 1.2em;
    max-width: 600px;
    margin: 0 auto;
}

/* Context section styles */
.context-section {
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 40px;
    margin: 40px auto;
    max-width: 800px;
    border-left: 4px solid #3498db;
}

.context-section h2 {
    color: #2c3e50;
    font-size: 1.8em;
    margin-bottom: 20px;
    text-align: center;
}

.context-content p {
    color: #555;
    font-size: 1.1em;
    line-height: 1.6;
    margin-bottom: 15px;
    text-align: center;
}

/* Flow chart section styles */
.flowchart-container {
    margin: 30px 0;
    padding: 25px;
    background-color: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e9ecef;
}

.flowchart-container h3 {
    color: #2c3e50;
    font-size: 1.4em;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 600;
}

.flowchart-image {
    text-align: center;
    background-color: #ffffff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.flowchart-img {
    max-width: 100%;
    max-height: 70vh;
    /* Prevents oversized image from pushing content off-screen */
    height: auto;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
    background-color: #ffffff;
}

.flowchart-img:hover {
    transform: scale(1.02);
    cursor: zoom-in;
}

/* Placeholder for missing flowchart image */
.flowchart-placeholder {
    padding: 30px;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    background-color: #f8f9fa;
    color: #6c757d;
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.flowchart-placeholder p {
    margin: 10px 0;
    font-size: 1em;
}

.flowchart-placeholder ol {
    margin: 15px 0;
    padding-left: 20px;
}

.flowchart-placeholder li {
    margin: 8px 0;
    text-align: left;
}

.flowchart-placeholder code {
    background-color: #e9ecef;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: #495057;
}

.flowchart-placeholder small {
    color: #868e96;
    font-size: 0.85em;
}

.flowchart-caption {
    margin-top: 15px;
    color: #6c757d;
    font-size: 0.95em;
    font-style: italic;
    line-height: 1.4;
    max-width: 90%;
    margin-left: auto;
    margin-right: auto;
}

.report-highlights {
    margin-top: 25px;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
}

.highlight-item {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px;
    background-color: #ffffff;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.highlight-item:last-child {
    margin-bottom: 0;
}

.highlight-icon {
    font-size: 1.5em;
    margin-right: 15px;
    color: #3498db;
}

.highlight-text {
    color: #555;
    font-size: 1em;
    line-height: 1.4;
}

.nav-cards {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 50px;
    flex-wrap: wrap;
}

.card {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    width: 300px;
    text-align: center;
    padding: 30px;
    text-decoration: none;
    color: inherit;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-10px);
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.15);
}

.card-icon {
    font-size: 3em;
    color: #3498db;
}

.card h3 {
    margin-top: 20px;
    color: #34495e;
}

.card p {
    color: #95a5a6;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    padding-top: 100px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.8);
}

.modal-content {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 700px;
    animation: zoom 0.3s;
}

@keyframes zoom {
    from {
        transform: scale(0)
    }

    to {
        transform: scale(1)
    }
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    user-select: none;
}

.close-modal:hover,
.close-modal:focus {
    color: #ff4444;
    background-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
    text-decoration: none;
}

#modal-caption {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 700px;
    text-align: center;
    color: #ccc;
    padding: 10px 0;
    height: 150px;
}

.flowchart-debug-link a {
    color: #0d6efd;
    text-decoration: underline;
}