/* Global styles */
body {
    font-family: Arial, sans-serif;
    margin: 20px; /* Adds margin around the entire site */
    background: #f9f9f9;
    box-sizing: border-box; /* Ensures padding/margin don't affect layout */
}

/* Tab navigation styles */
.tab-nav {
    display: flex;
    background: #f4f4f4;
    border-bottom: 2px solid #ccc;
    padding: 0;
    margin: 0;
}

.tab {
    flex: 0 0 auto;
    padding: 12px 24px;
    cursor: pointer;
    background: #ddd;
    border: 2px solid #ccc;
    border-bottom: none;
    border-radius: 4px 4px 0 0; /* Rounded top corners */
    margin: 0 4px -2px 0; /* Align with bottom border */
    font-size: 16px;
    color: #333;
    transition: background 0.2s, color 0.2s;
    position: relative;
    z-index: 1; /* Ensure tabs are above content */
}

.tab:hover {
    background: #e6e6e6;
}

.tab.active {
    background: #fff; /* White to blend with content */
    color: #007bff;
    border-bottom: 2px solid #fff; /* Visually connects to content */
    z-index: 2; /* Active tab above others */
}

/* Tab content styles */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Common tab content styles */
.content {
    background: #fff;
    border: 2px solid #ccc;
    border-top: none;
    padding: 20px;
    border-radius: 0 0 4px 4px;
    margin: 0;
}

.small-text {
    font-size: 12px;
    margin-left: 60px;
}

/* Introduction section */
.introduction {
    margin-bottom: 20px;
    font-style: italic;
}

/* Footer styles */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #f4f4f4; /* Matches tab-nav background */
    color: #333;
    text-align: center;
    padding: 10px 0;
    font-size: 14px;
    border-top: 2px solid #ccc; /* Matches tab-nav border */
    z-index: 10; /* Ensure footer is above other content */
}

/* Cloud tab styles */
.chart-container {
    display: flex; /* Use flexbox to place SVG and control panel side by side */
    flex-wrap: nowrap; /* Prevent wrapping */
    align-items: flex-start; /* Align items at the top */
    position: relative;
    width: 100%;
    overflow: hidden;
}

#point-cloud {
    flex: 1; /* Take available space minus control panel */
}

#point-cloud svg {
    display: block;
    width: 100%; /* Ensure SVG scales to container */
    height: auto; /* Maintain aspect ratio */
}

/* Responsive SVG container */
.svg-content-responsive {
    display: inline-block;
    position: relative;
    width: 100%;
    height: auto;
}

.control-panel {
    width: 200px; /* Fixed width as specified */
    margin-top: 20px; /* Space between top of chart and panel */
    margin-left: 20px; /* Space between SVG and panel */
    box-sizing: border-box;
}

.control-section {
    padding: 10px;
    background: #f9f9f9;
    border-radius: 4px;
    margin-bottom: 20px; /* Space between sections */
}

.control-section:last-child {
    margin-bottom: 0; /* No margin for the last section */
}

.control-panel h4 {
    margin: 0 0 10px;
    font-size: 14px;
}

.control-panel select,
.control-panel input[type="text"] {
    width: 100%;
    padding: 5px;
    padding-right: 22px; /* Space for clear button */
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

.input-wrapper {
    position: relative;
    width: 100%;
}

.clear-button {
    position: absolute;
    right: 6px;
    top: 0px; /* Manual positioning */
    background: transparent !important;
    border: none !important;
    outline: none !important;
    color: #999 !important;
    cursor: pointer;
    padding: 0;
    width: 16px;
    height: 16px;
    font-size: 18px;
    line-height: 1;
    text-align: center;
    display: none; /* Hidden by default */
    opacity: 0.7;
    font-family: Arial, sans-serif;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    box-shadow: none !important;
}

.clear-button:focus,
.clear-button:active,
.clear-button:visited {
    outline: none !important;
    background: transparent !important;
    color: #999 !important;
    box-shadow: none !important;
}

.clear-button:hover {
    color: #666 !important;
    opacity: 1;
    background: transparent !important;
}

.input-wrapper.has-value .clear-button {
    display: block;
}

.control-panel label {
    display: block;
    margin-bottom: 5px;
}

.control-panel button {
    padding: 3px 6px;
    margin-right: 5px;
    /*background: #007bff;*/
    color: black;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.control-panel button:hover {
    background: #007bff;
    color: white;
}

.tooltip {
    position: absolute;
    background: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    pointer-events: none;
    font-size: 12px;
    opacity: 0;
}

/* FAQ tab styles */
.faq-item {
    margin-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.faq-question {
    cursor: pointer;
    font-weight: bold;
    color: #333;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
    font-style: italic;
}

.faq-question:hover {
    background: #e6e6e6;
    color: #007bff;
}

.faq-answer {
    display: none;
    padding: 10px 15px;
    color: #555;
}

.faq-answer.active {
    display: block;
}

/* Hide warning by default */
.mobile-warning {
    display: none;
}

/* Mobile styles */
@media (max-width: 768px) {
    /* Hide footer on mobile devices */
    .footer {
        display: none;
    }
    
    /* Adjust chart layout for mobile */
    .chart-container {
        flex-direction: column; /* Stack vertically instead of horizontally */
        align-items: stretch; /* Stretch items to full width */
    }
    
    /* Make point cloud take full width on mobile */
    #point-cloud {
        width: 100%;
        margin-bottom: 20px; /* Add space below the chart */
    }
    
    /* Control panel adjustments for mobile */
    .control-panel {
        width: 100%; /* Full width on mobile */
        margin-left: 0; /* Remove left margin */
        margin-top: 0; /* Remove top margin */
        display: flex; /* Use flexbox for control sections */
        flex-wrap: wrap; /* Allow wrapping */
        gap: 15px; /* Space between control sections */
    }
    
    /* Control sections in rows on mobile */
    .control-section {
        flex: 1 1 calc(50% - 7.5px); /* Two sections per row with gap */
        min-width: 150px; /* Minimum width */
        margin-bottom: 0; /* Remove margin-bottom, using gap instead */
    }
    
    /* Ensure search and technology filters are full width */
    #search-filter,
    #technology-filter {
        flex: 1 1 100%; /* Full width for these filters */
    }
    
    /* Adjust body margins on mobile */
    body {
        margin: 10px; /* Reduce margin on mobile */
    }
    
    /* Adjust content padding on mobile */
    .content {
        padding: 10px; /* Reduce padding on mobile */
    }
}

/* Only show warning on mobile screens in portrait mode */
@media (max-width: 768px) and (orientation: portrait) {
    .mobile-warning {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.7);
        z-index: 9999;
    }

    .mobile-warning-content {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: white;
        padding: 20px;
        border-radius: 8px;
        text-align: center;
        max-width: 90%;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    }

    .mobile-warning button {
        margin-top: 10px;
        padding: 8px 16px;
        background: #007bff;
        color: white;
        border: none;
        border-radius: 4px;
        cursor: pointer;
        transition: background 0.2s;
    }
    
    .mobile-warning button:hover {
        background: #0056b3;
    }
}
