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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #1976d2 0%, #0d47a1 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(135deg, #1976d2 0%, #0d47a1 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.95;
}

/* Main Content */
main {
    padding: 30px;
}

/* Controls Section */
.controls-section {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.control-panel {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.control-panel h2 {
    font-size: 1.4em;
    color: #1976d2;
    margin-bottom: 10px;
}

.hint {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 15px;
}

/* Button Styles */
.btn {
    padding: 12px 24px;
    font-size: 1em;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.btn-primary {
    background: linear-gradient(135deg, #1976d2 0%, #0d47a1 100%);
    color: white;
    width: 100%;
    font-size: 1.1em;
    padding: 15px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(25, 118, 210, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: white;
    color: #1976d2;
    border: 2px solid #1976d2;
    padding: 8px 16px;
    font-size: 0.9em;
}

.btn-secondary:hover {
    background: #1976d2;
    color: white;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

/* Strategy List — group card grid */
.strategy-list {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 15px;
}

.strategy-group {
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 10px 12px;
}

.strategy-group-header {
    font-weight: 700;
    font-size: 0.8em;
    letter-spacing: 0.05em;
    color: #333;
    margin-bottom: 8px;
}

.strategy-group-items {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
}

.strategy-group-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.9em;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.strategy-group-item input[type="checkbox"] {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: #1976d2;
    flex-shrink: 0;
}

/* Time Period Input */
.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

.input-group input[type="number"] {
    width: 100%;
    padding: 12px;
    font-size: 1em;
    border: 2px solid #ddd;
    border-radius: 6px;
    transition: border-color 0.3s ease;
}

.input-group input[type="number"]:focus {
    outline: none;
    border-color: #1976d2;
}

/* Presets */
.presets {
    margin-top: 15px;
}

.preset-label {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 10px;
}

.preset-btn {
    display: inline-block;
    padding: 8px 12px;
    margin: 4px;
    background: white;
    border: 1px solid #1976d2;
    color: #1976d2;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.2s ease;
}

.preset-btn:hover {
    background: #1976d2;
    color: white;
}

/* Mode Toggle Buttons */
.mode-toggle-group {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border: 2px solid #1976d2;
    border-radius: 6px;
    overflow: hidden;
}

.mode-btn {
    flex: 1;
    padding: 12px;
    background: white;
    color: #1976d2;
    border: none;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s ease;
}

.mode-btn.active {
    background: #1976d2;
    color: white;
}

.mode-btn:hover:not(.active) {
    background: #e3f2fd;
}

/* Mode Controls */
.mode-controls {
    transition: opacity 0.3s ease;
}

/* Date Input Styling */
.date-input {
    width: 100%;
    padding: 12px;
    font-size: 1em;
    border: 2px solid #ddd;
    border-radius: 6px;
    transition: border-color 0.3s ease;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.date-input:focus {
    outline: none;
    border-color: #1976d2;
}

.date-range-hint {
    margin-top: 15px;
    font-style: italic;
}

/* Date Presets */
.date-presets {
    margin-top: 15px;
}

.date-preset-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    margin: 4px;
    background: white;
    border: 1px solid #1976d2;
    color: #1976d2;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.date-preset-btn:hover {
    background: #1976d2;
    color: white;
}

.preset-title {
    font-weight: 600;
    font-size: 0.9em;
}

.preset-dates {
    font-size: 0.8em;
    opacity: 0.9;
}

/* Action Panel */
.action-panel {
    grid-column: 1 / -1;
}

/* Error Display */
.error-message {
    background: #ffe0e0;
    color: #d32f2f;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #d32f2f;
    margin-bottom: 20px;
    font-weight: 500;
    white-space: pre-wrap;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
}

/* Loading Spinner */
.loading-spinner {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #1976d2;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.loading-spinner p {
    color: #666;
    font-size: 1.1em;
}

/* Results Section */
.results-section {
    margin-top: 30px;
}

.results-section h2 {
    font-size: 1.8em;
    color: #1976d2;
    margin-bottom: 20px;
}

.results-info {
    background: #e3f2fd;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #2196f3;
}

.results-info p {
    margin: 5px 0;
    font-size: 0.95em;
}

.results-info strong {
    color: #1976d2;
}

/* Chart Container */
.chart-container {
    position: relative;
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    margin-bottom: 30px;
    min-height: 700px;
    overflow: auto;
}

/* Correlation Heatmap Table */
.correlation-heatmap {
    display: inline-block;
    font-family: Arial, sans-serif;
}

.correlation-heatmap table {
    border-collapse: collapse;
    margin: 0 auto;
}

.correlation-heatmap th,
.correlation-heatmap td {
    border: 1px solid rgba(200, 200, 200, 0.5);
    min-width: 70px;
    min-height: 70px;
    width: 70px;
    height: 70px;
    text-align: center;
    vertical-align: middle;
    font-size: 13px;
    font-weight: bold;
    position: relative;
}

.correlation-heatmap th {
    background: #f5f5f5;
    font-size: 11px;
    padding: 5px;
    max-width: 150px;
    word-wrap: break-word;
}

.correlation-heatmap th.row-header {
    text-align: right;
    padding-right: 10px;
    font-weight: 600;
}

.correlation-heatmap th.col-header {
    writing-mode: vertical-lr;
    white-space: nowrap;
    height: 150px;
    text-orientation: mixed;
}

.correlation-heatmap td.corr-cell {
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.correlation-heatmap td.corr-cell:hover {
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

/* Legend */
.legend {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.legend h3 {
    font-size: 1.2em;
    margin-bottom: 15px;
    color: #333;
}

.legend-gradient {
    margin-top: 15px;
}

.gradient-bar {
    height: 30px;
    background: linear-gradient(to right,
        #b71c1c 0%,
        #ef5350 25%,
        #ffffff 50%,
        #64b5f6 75%,
        #1a237e 100%
    );
    border-radius: 4px;
    margin-bottom: 10px;
}

.gradient-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.85em;
    color: #666;
}

/* Footer */
footer {
    background: #f8f9fa;
    padding: 20px;
    text-align: center;
    color: #666;
    border-top: 1px solid #e0e0e0;
}

/* Responsive Design */
@media (max-width: 968px) {
    .controls-section {
        grid-template-columns: 1fr;
    }

    .strategy-list {
        grid-template-columns: repeat(2, 1fr);
    }


    header h1 {
        font-size: 2em;
    }

    .gradient-labels {
        flex-direction: column;
        gap: 5px;
    }
}

@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    main {
        padding: 15px;
    }

    header {
        padding: 20px;
    }

    header h1 {
        font-size: 1.5em;
    }

    .control-panel {
        padding: 15px;
    }

    .strategy-list {
        grid-template-columns: repeat(2, 1fr);
    }

    .preset-btn {
        display: block;
        width: 100%;
        margin: 5px 0;
    }
}

/* Upload Section */
.upload-section {
    margin-bottom: 20px;
}

.file-upload-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

#fileName {
    font-size: 0.9em;
    color: #666;
    font-style: italic;
}

.drop-zone {
    border: 2px dashed #1976d2;
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    background: #f8f9fa;
    margin-bottom: 15px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.drop-zone.drag-over {
    background: #e3f2fd;
    border-color: #2196f3;
    transform: scale(1.02);
}

.drop-zone p {
    margin: 5px 0;
}

.drop-zone .hint {
    font-size: 0.85em;
}

.storage-info {
    font-size: 0.85em;
    color: #666;
    padding: 10px;
    background: #e3f2fd;
    border-radius: 4px;
    text-align: center;
    margin-top: 10px;
}

.storage-info.warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
}

/* Custom Strategies Section */
.strategy-sections {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.strategy-section h3 {
    font-size: 1.2em;
    color: #1976d2;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.strategy-section h3 {
    word-spacing: normal;
    letter-spacing: normal;
}

.strategy-section h3 span {
    padding: 0;
    margin: 0;
    display: inline;
    font-size: inherit;
    letter-spacing: inherit;
}

.strategy-section.custom-section {
    background: #fff8e1;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #ffd54f;
}

.custom-strategy-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    background: white;
    border-radius: 6px;
    border: 1px solid #ddd;
    margin-bottom: 8px;
    transition: all 0.2s ease;
}

.custom-strategy-item:hover {
    border-color: #1976d2;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.custom-strategy-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.custom-strategy-meta {
    font-size: 0.8em;
    color: #666;
    margin-left: 10px;
}

.delete-btn {
    background: #ef5350;
    color: white;
    border: none;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 600;
    transition: all 0.2s ease;
}

.delete-btn:hover {
    background: #d32f2f;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(211, 47, 47, 0.3);
}

.delete-btn:active {
    transform: translateY(0);
}

/* Success Message */
.success-message {
    background: #d4edda;
    color: #155724;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #28a745;
    margin-bottom: 20px;
    font-weight: 500;
    display: none;
}

.warning-display {
    background: #fff3cd;
    color: #856404;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #ffc107;
    margin-bottom: 20px;
    font-weight: 500;
    display: none;
}

.warning-display ul {
    margin: 10px 0 0 20px;
}

/* Responsive adjustments for upload section */
@media (max-width: 600px) {
    .file-upload-wrapper {
        flex-direction: column;
        align-items: stretch;
    }

    #fileName {
        text-align: center;
    }

    .drop-zone {
        padding: 20px;
    }

    .custom-strategy-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .custom-strategy-info {
        width: 100%;
    }

    .delete-btn {
        width: 100%;
    }
}
