* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Titillium Web', sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    color: #333;
}

.container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* Upload Area (Full Screen Initially) */
.upload-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    background: white;
}

.upload-area.active {
    width: 100vw;
}

.upload-area.hidden {
    display: none;
}

.upload-content {
    text-align: center;
    max-width: 900px;
    width: 100%;
    padding: 2rem;
}

.logo h1 {
    color: #333;
    font-size: 2rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.logo p {
    color: #666;
    font-size: 1.0rem;
    margin-bottom: 2rem;
}

.upload-main-section {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 3rem;
    margin: 2rem 0;
    position: relative;
    min-height: 300px;
    width: 100%;
}

.drop-zone {
    background: white;
    border: 3px dashed #ddd;
    border-radius: 15px;
    padding: 3rem 2rem;
    transition: all 0.3s ease;
    cursor: pointer;
    width: 400px;
    flex-shrink: 0;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: #667eea;
    background: #f8f9ff;
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.drop-zone h2 {
    color: #333;
    margin-bottom: 0.5rem;
    font-weight: 400;
}

.drop-zone p {
    color: #666;
    font-size: 1rem;
}

/* Supported Systems List */
.supported-systems {
    margin: 0;
    text-align: left;
    width: 300px;
    flex-shrink: 0;
    padding-top: 1rem;
}

.supported-systems h3 {
    color: #333;
    font-size: 1.2rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.systems-list {
    list-style: none;
    padding: 0;
    margin: 0;
    background: transparent;
    border-radius: 8px;
    padding: 1rem;
    border: none;
}

.systems-list li {
    padding: 0.4rem 0;
    font-size: 0.95rem;
    font-weight: 500;
}

.systems-list li:last-child {
    border-bottom: none;
}

.systems-list li.supported {
    color: #2d5016;
}

.systems-list li.coming-soon {
    color: #856404;
}

.file-list {
    margin: 2rem 0;
}

.file-item {
    background: rgba(255, 255, 255, 0.9);
    padding: 1rem;
    margin: 0.5rem 0;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-icon {
    font-size: 1.5rem;
}

.file-name {
    font-weight: 500;
}

.file-size {
    color: #666;
    font-size: 0.9rem;
}

.file-status {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.file-status.ready {
    background: #e8f5e8;
    color: #2d5016;
}

.file-status.processed {
    background: #d1ecf1;
    color: #0c5460;
}

.file-status.processing {
    background: #fff3cd;
    color: #856404;
}

.file-status.error {
    background: #f8d7da;
    color: #721c24;
}

.analyze-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 1rem 3rem;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.analyze-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.analyze-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: white;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    padding: 2rem;
    display: none;
    flex-direction: column;
    overflow-y: auto;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 1000;
}

.sidebar.active {
    display: flex;
}

.sidebar-logo {
    text-align: center;
    margin-bottom: 0rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.crown-logo {
    max-width: 120px;
    height: auto;
    display: block;
    margin: 0 auto;
}

.sidebar-upload-section {
    margin-top: auto;
    padding-top: 2rem;
    border-top: 1px solid #eee;
}

.sidebar-header h3 {
    margin-bottom: 1.5rem;
    color: #333;
}

.drop-zone-small {
    background: #f8f9ff;
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 2rem 1rem;
    text-align: center;
    margin-bottom: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.drop-zone-small:hover,
.drop-zone-small.dragover {
    border-color: #667eea;
    background: #f0f2ff;
}

.upload-icon-small {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.drop-zone-small p {
    color: #666;
    font-size: 0.9rem;
}

.file-list-small {
    margin-bottom: 1rem;
    max-height: 200px;
    overflow-y: auto;
}

.file-item-small {
    background: #f8f9fa;
    padding: 0.75rem;
    margin: 0.25rem 0;
    border-radius: 6px;
    font-size: 0.9rem;
}

.file-status-small {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    margin-top: 0.25rem;
    display: inline-block;
    font-weight: 500;
}

.file-status-small.ready {
    background: #e8f5e8;
    color: #2d5016;
}

.file-status-small.processed {
    background: #d1ecf1;
    color: #0c5460;
}

.file-status-small.processing {
    background: #fff3cd;
    color: #856404;
}

.file-status-small.error {
    background: #f8d7da;
    color: #721c24;
}

.analyze-btn-small {
    background: #667eea;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    width: 100%;
    margin-bottom: 2rem;
}

.analyze-btn-small:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.clear-workspace-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    width: 100%;
    margin-top: 1rem;
    font-family: 'Titillium Web', sans-serif;
    font-weight: 500;
    transition: background 0.3s ease;
}

.clear-workspace-btn:hover {
    background: #c82333;
}

.data-info {
    padding-top: 0.2rem;
    margin-bottom: 0rem;
}

.data-info h4 {
    margin-bottom: 0rem;
    color: #333;
    font-weight: 600;
}

#dataStats {
    font-size: 0.9rem;
    color: #666;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

/* Filters Section */
.filters-section {
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.filters-header h4 {
    margin: 0;
    color: #333;
    font-weight: 600;
}

.reset-filters-icon {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.reset-filters-icon:hover {
    background: #f0f0f0;
    transform: rotate(45deg);
}

.filter-group {
    margin-bottom: 1rem;
}

.filter-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
    color: #333;
    font-size: 0.9rem;
}

.checkbox-group {
    max-height: 120px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 0.25rem;
    background: #fafafa;
}

.filter-checkbox {
    display: flex;
    align-items: center;
    margin-bottom: 0.15rem;
    padding: 0.15rem 0.25rem;
    border-radius: 3px;
    transition: background 0.2s ease;
    font-size: 0.8rem;
}

.filter-checkbox:hover {
    background: #f0f0f0;
}

.filter-checkbox:last-child {
    margin-bottom: 0;
}

.filter-checkbox input[type="checkbox"] {
    margin-right: 0.4rem;
    cursor: pointer;
    transform: scale(0.9);
}

.filter-checkbox label {
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 400;
    margin: 0;
    flex: 1;
    line-height: 1.2;
}

.filter-button-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.clear-filters-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 0.6rem 1rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    width: 50%;
    transition: background 0.3s ease;
    font-family: 'Titillium Web', sans-serif;
    font-weight: 500;
    line-height: 1.2;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clear-filters-btn:hover {
    background: #c82333;
}

.edit-tags-btn {
    background: #007bff !important;
    color: white !important;
    border: none;
    padding: 0.6rem 1rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    width: 50%;
    transition: background 0.3s ease;
    font-family: 'Titillium Web', sans-serif;
    font-weight: 500;
    line-height: 1.2;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.edit-tags-btn:hover {
    background: #0056b3 !important;
}

.download-btn-sidebar {
    background: #28a745;
    color: white;
    border: none;
    padding: 0.6rem 1rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    width: 100%;
    transition: background 0.3s ease;
    margin-top: 0.5rem;
    font-family: 'Titillium Web', sans-serif;
    font-weight: 500;
    line-height: 1.2;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    background: #f8f9fa;
    display: none;
    margin-left: 0;
    width: calc(100% - 320px);
    box-sizing: border-box;
}

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

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.content-header h2 {
    color: #333;
    font-weight: 400;
}

.controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

#clubFilter {
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    font-size: 0.9rem;
}

.download-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.3s ease;
}

.download-btn:hover {
    background: #218838;
}

.chart-container {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.chart-container canvas {
    max-width: 100% !important;
    height: 500px !important;
    max-height: 500px !important;
}

.chart-legend-controls {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
    gap: 20px; /* Increased gap to prevent overlap */
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    flex: 1;
    min-height: 40px; /* Maintain minimum height for stability */
    overflow: hidden; /* Prevent legend from overflowing into ellipse controls */
    margin-right: 10px; /* Add margin to prevent legend items from getting too close to ellipse controls */
}

.legend-item {
    display: inline-flex !important;
    align-items: center !important;
    margin-right: 15px !important;
    margin-bottom: 5px !important;
    cursor: pointer !important;
    max-width: calc(100% - 20px); /* Ensure legend items don't overflow */
    flex-shrink: 1;
}

.ellipse-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    flex-shrink: 0;
    width: 180px; /* Reduced width since we're stacking */
    justify-content: flex-start; /* Align to top */
}

.ellipse-controls-row {
    display: flex;
    flex-direction: column; /* Stack vertically instead of horizontally */
    align-items: flex-end;
    gap: 0.5rem;
    width: 100%;
}

.ellipse-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem; /* Reduced gap */
    font-size: 0.85rem; /* Slightly smaller font */
    color: #555;
    cursor: pointer;
    user-select: none;
    padding: 6px 10px; /* Reduced padding */
    border-radius: 4px;
    border: 1px solid #ddd;
    background: white;
    white-space: nowrap;
    flex-shrink: 0;
    width: 100%; /* Full width to match dropdown */
    justify-content: flex-start; /* Align content to the left */
}

.ellipse-toggle input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.ellipse-toggle span {
    font-family: 'Titillium Web', sans-serif;
    font-weight: 400;
}

.ellipse-type-select {
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    font-family: 'Titillium Web', sans-serif;
    font-size: 0.8rem; /* Slightly smaller font */
    color: #555;
    cursor: pointer;
    width: 100%; /* Full width since we're stacking */
    min-width: 160px; /* Ensure minimum width for text readability */
}

.ellipse-warning {
    font-size: 0.75rem;
    color: #856404;
    font-style: italic;
    line-height: 1.2;
    text-align: right;
    margin-top: 2px;
    width: 100%;
}

.data-table-container {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    width: 100%;
    overflow: hidden;
    order: 3; /* Move to bottom */
}

.data-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    cursor: pointer;
    user-select: none;
}

.data-table-header h3 {
    margin: 0;
    color: #333;
    font-weight: 600;
}

.collapse-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.collapse-btn:hover {
    background: #f0f0f0;
}

.collapse-icon {
    font-size: 1rem;
    transition: transform 0.3s ease;
}

.data-table-content {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.data-table-content.collapsed {
    max-height: 0;
}

.data-table-content.expanded {
    max-height: 400px;
    overflow: visible;
}

.summary-table-container {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    width: 100%;
    overflow: hidden;
    margin-bottom: 2rem;
    order: 2; /* Keep above data table */
}

.summary-table-container h3 {
    margin-bottom: 1rem;
    color: #333;
    font-weight: 600;
}

.summary-table-wrapper {
    max-height: 400px;
    overflow: auto;
    border: 1px solid #ddd;
    border-radius: 6px;
}

.summary-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    align-items: center;
}

.summary-view-btn {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #ddd;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Titillium Web', sans-serif;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.summary-view-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.summary-view-btn.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.summary-view-btn.active:hover {
    background: #0056b3;
    border-color: #0056b3;
}

#dataTable {
    max-width: 100%;
}

#summaryTable {
    max-width: 100%;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    min-width: 800px; /* Minimum width to prevent squishing */
}

.data-table th,
.data-table td {
    padding: 0.75rem;
    text-align: center;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

/* Special styling for Club Type and Tags columns */
.data-table th.club-type-header,
.data-table td.club-type-cell,
.data-table th.tags-header,
.data-table td.tags-cell {
    text-align: left;
    min-width: 120px;
    max-width: 180px;
}

.data-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-with-units {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    align-items: center;
    text-align: center;
}

.header-name {
    font-weight: 600;
    margin-bottom: 2px;
}

.header-units {
    font-size: 0.8em;
    font-weight: 400;
    color: #666;
}

.sortable-header {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
}

.sortable-header:hover {
    background-color: #e9ecef !important;
}

.data-table tr:hover {
    background: #f8f9fa;
}

.std-dev {
    color: #666;
    font-weight: normal;
}

/* Responsive Design */
@media (max-width: 768px) {
    .upload-content {
        max-width: 100%;
        padding: 1rem;
    }
    
    .upload-main-section {
        flex-direction: column;
        gap: 2rem;
        align-items: center;
        min-height: auto;
    }
    
    .drop-zone {
        width: 100%;
        max-width: 400px;
        padding: 2rem 1rem;
    }
    
    .supported-systems {
        width: 100%;
        max-width: 400px;
        text-align: center;
    }
    
    .systems-list {
        text-align: left;
    }
    
    .sidebar {
        width: 100%;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        padding-top: 0.5rem;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        width: 100%;
        margin-left: 0;
        padding: 1rem;
    }
    
    .content-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .controls {
        justify-content: space-between;
    }
    
    .chart-container {
        padding: 1rem;
    }
    
    .chart-legend-controls {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .ellipse-controls {
        width: 100%;
        align-items: center;
    }
    
    .ellipse-controls-row {
        align-items: center;
        gap: 0.5rem;
        width: 100%;
    }
    
    .ellipse-type-select {
        width: 100%;
        min-width: 200px;
    }
    
    .ellipse-warning {
        text-align: center;
    }
    
    .chart-legend {
        justify-content: center;
    }
    
    .data-table th,
    .data-table td {
        max-width: 100px;
        font-size: 0.8rem;
    }
    
    .data-table-content.expanded,
    .summary-table-wrapper {
        max-height: 300px;
    }
}

@media (min-width: 769px) {
    .main-content.active {
        margin-left: 320px;
        width: calc(100% - 320px);
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 2s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 8px;
    width: 80%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

.modal-header h2 {
    margin: 0;
    color: #333;
    font-family: 'Titillium Web', sans-serif;
    font-weight: 600;
}

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover,
.close:focus {
    color: #000;
}

.modal-body {
    padding: 2rem;
    max-height: 50vh;
    overflow-y: auto;
}

.modal-body p {
    margin-bottom: 1.5rem;
    color: #666;
    font-family: 'Titillium Web', sans-serif;
}

.tag-edit-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tag-edit-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f9f9f9;
}

.tag-edit-item label {
    min-width: 120px;
    font-weight: 500;
    color: #333;
    font-family: 'Titillium Web', sans-serif;
}

.tag-edit-item input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: 'Titillium Web', sans-serif;
}

.tag-edit-item input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1.5rem 2rem;
    border-top: 1px solid #eee;
    background: #f8f9fa;
}

.cancel-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Titillium Web', sans-serif;
    font-weight: 500;
    transition: background 0.3s ease;
}

.cancel-btn:hover {
    background: #545b62;
}

.submit-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Titillium Web', sans-serif;
    font-weight: 500;
    transition: background 0.3s ease;
}

.submit-btn:hover {
    background: #218838;
}
