/* ===== MODERN ANALYSIS PAGE STYLES ===== */

/* Container Styles */
.analysis-container {
    padding: 20px;
    max-width: 100%;
    background: #f8f9fa;
    min-height: calc(100vh - 40px);
}

/* Header Section */
.analysis-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 24px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.3);
}

.header-content h1 {
    font-size: 2.2rem;
    margin: 0 0 8px 0;
    font-weight: 700;
}

.header-content i {
    margin-right: 12px;
    color: #ffd700;
}

.header-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin: 0;
}

.quick-stats {
    display: flex;
    gap: 32px;
}

.stat-item {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: #ffd700;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Main Layout */
.analysis-main {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 24px;
    min-height: calc(100vh - 200px);
    height: auto;
}

/* Left Sidebar */
.analysis-sidebar {
    background: white;
    border-radius: 16px;
    padding: 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    overflow-y: auto;
    height: fit-content;
    max-height: 100%;
}

.tool-section {
    padding: 20px;
    border-bottom: 1px solid #f0f0f0;
}

.tool-section:last-child {
    border-bottom: none;
}

.tool-section h3 {
    margin: 0 0 16px 0;
    color: #2c3e50;
    font-size: 1.1rem;
    font-weight: 600;
}

.tool-section h3 i {
    margin-right: 8px;
    color: #667eea;
}

/* Project Selector */
.analysis-select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    background: white;
    color: #2c3e50;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.analysis-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Variable Tabs */
.variable-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}

.var-tab {
    padding: 10px 8px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    background: white;
    color: #6c757d;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    font-weight: 500;
}

.var-tab:hover {
    border-color: #667eea;
    color: #667eea;
}

.var-tab.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-color: #667eea;
    color: white;
}

/* Variable Items */
.variables-container {
    position: relative;
}

.variable-group {
    display: none;
}

.variable-group.active {
    display: block;
}

.variable-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 8px;
    background: #f8f9fa;
    border-radius: 10px;
    cursor: grab;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    user-select: none;
}

.variable-item:hover {
    background: #e3f2fd;
    border-color: #2196f3;
    transform: translateX(4px);
}

.variable-item:active {
    cursor: grabbing;
}

.variable-item i {
    width: 20px;
    color: #667eea;
    font-size: 1.1rem;
}

.variable-item span {
    flex: 1;
    font-weight: 500;
    color: #2c3e50;
}

.variable-item small {
    color: #6c757d;
    font-size: 0.8rem;
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 4px;
}

.variable-item.disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

.variable-item.disabled:hover {
    background: #f8f9fa;
    border-color: transparent;
    transform: none;
}

/* Project Info Styles */
.project-info {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f0f0f0;
}

.selected-project-info {
    margin-top: 12px;
}

/* Hole Selector Grid */
.hole-selector-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 12px;
}

.hole-btn {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 60px;
    justify-content: center;
}

.hole-btn:hover {
    border-color: #667eea;
    background: #e3f2fd;
}

.hole-btn.active {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.hole-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f1f1f1;
}

.hole-number {
    font-weight: bold;
    font-size: 1.1rem;
}

.hole-btn small {
    font-size: 0.7rem;
    margin-top: 2px;
    opacity: 0.8;
}

/* Plant Type Filters */
.plant-type-filters {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-top: 12px;
}

.plant-filter-btn {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.8rem;
}

.plant-filter-btn:hover {
    border-color: #28a745;
    background: #d4edda;
}

.plant-filter-btn.active {
    background: #28a745;
    border-color: #28a745;
    color: white;
}

.plant-filter-btn i {
    font-size: 0.9rem;
}

/* Chart Templates */
.chart-templates {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.template-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 12px;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    background: white;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.85rem;
}

.template-btn:hover {
    border-color: #667eea;
    color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}

.template-btn i {
    font-size: 1.5rem;
}

/* Right Workspace */
.analysis-workspace {
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow: visible;
    min-height: 600px;
    height: auto;
    padding: 10px;
}

/* Section Headers */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.2rem;
    font-weight: 600;
}

.section-header h3 i {
    margin-right: 8px;
    color: #667eea;
}

/* Pinned Charts */
.pinned-section {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    margin-bottom: 15px;
}

.pinned-charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    min-height: 100px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px dashed #dee2e6;
}

.pinned-charts-grid .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 30px 20px;
    grid-column: 1 / -1;
}

/* Chart Builder */
.chart-builder {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    overflow: hidden;
    margin: 10px 0;
}

.builder-header {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #dee2e6;
}

.builder-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.2rem;
    font-weight: 600;
}

.builder-header h3 i {
    margin-right: 8px;
    color: #ffd700;
}

.builder-controls {
    display: flex;
    gap: 12px;
}

.builder-content {
    padding: 24px;
}

.builder-section {
    margin-bottom: 24px;
}

.builder-label {
    display: block;
    margin-bottom: 12px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.95rem;
}

/* Chart Type Selector */
.chart-type-selector {
    display: flex;
    gap: 12px;
}

.type-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 20px;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    background: white;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    flex: 1;
}

.type-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.type-btn.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-color: #667eea;
    color: white;
}

.type-btn i {
    font-size: 1.8rem;
}

/* Data Dropzones */
.data-dropzones {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.dropzone {
    border: 3px dashed #dee2e6;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    background: #f8f9fa;
    transition: all 0.3s ease;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.dropzone:hover {
    border-color: #667eea;
    background: #e3f2fd;
}

.dropzone.active {
    border-color: #28a745;
    background: #d4edda;
    border-style: solid;
}

.dropzone.drag-over {
    border-color: #667eea;
    background: #e3f2fd;
    border-style: solid;
    transform: scale(1.02);
}

.variable-item.dragging {
    opacity: 0.7;
    transform: rotate(2deg);
}

.dropzone-label {
    font-size: 0.85rem;
    color: #6c757d;
    margin-bottom: 8px;
    font-weight: 500;
}

.dropzone-content {
    color: #adb5bd;
}

.dropzone-content i {
    font-size: 1.5rem;
    margin-bottom: 8px;
    display: block;
}

.remove-variable {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-top: 8px;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.remove-variable:hover {
    background: #c82333;
    transform: scale(1.1);
}

/* Builder Input */
.builder-input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    background: white;
    height: 40px;
}

.builder-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Created Charts Section */
.created-charts-section {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    flex: 1;
}

.view-controls {
    display: flex;
    gap: 4px;
    background: #f8f9fa;
    padding: 4px;
    border-radius: 8px;
}

.view-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.2s ease;
}

.view-btn:hover {
    color: #495057;
}

.view-btn.active {
    background: white;
    color: #667eea;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Charts Container */
.charts-container {
    margin-top: 16px;
    min-height: 300px;
}

.charts-container.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 20px;
}

.charts-container.list-view {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Empty States */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
    min-height: 200px;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 1.1rem;
    margin: 0 0 8px 0;
    font-weight: 500;
}

.empty-state small {
    font-size: 0.9rem;
    opacity: 0.8;
    max-width: 300px;
    line-height: 1.4;
}

/* Buttons */
.btn-primary, .btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: #f8f9fa;
    color: #6c757d;
    border: 2px solid #e9ecef;
}

.btn-secondary:hover {
    background: #e9ecef;
    border-color: #dee2e6;
}

/* Chart Cards */
.chart-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    border: 2px solid transparent;
    transition: all 0.3s ease;
    position: relative;
}

.chart-card:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0,0,0,0.12);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.chart-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.chart-actions {
    display: flex;
    gap: 8px;
}

.chart-action-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: #f8f9fa;
    color: #6c757d;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chart-action-btn:hover {
    background: #e9ecef;
    color: #495057;
}

.chart-action-btn.pin-btn.pinned {
    background: #ffd700;
    color: #fff;
}

.chart-canvas-container {
    width: 100%;
    height: 250px;
    position: relative;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 0;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease;
}

.modal-content.large {
    max-width: 900px;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.3rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: #f8f9fa;
    color: #6c757d;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #e9ecef;
    color: #495057;
}

.modal-body {
    padding: 24px;
}

/* AI Analysis Styles */
.ai-analysis-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

.analysis-chart-preview {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    min-height: 300px;
}

.ai-insights h4 {
    margin: 0 0 16px 0;
    color: #2c3e50;
    font-size: 1.1rem;
}

.insights-content {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    color: #495057;
    line-height: 1.6;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .analysis-main {
        grid-template-columns: 280px 1fr;
    }
    
    .quick-stats {
        gap: 20px;
    }
    
    .stat-number {
        font-size: 1.6rem;
    }
}

@media (max-width: 968px) {
    .analysis-main {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .analysis-header {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
    
    .header-content h1 {
        font-size: 1.8rem;
    }
    
    .quick-stats {
        justify-content: center;
    }
    
    .charts-container.grid-view {
        grid-template-columns: 1fr;
    }
    
    .data-dropzones {
        grid-template-columns: 1fr;
    }
    
    .chart-type-selector {
        flex-wrap: wrap;
    }
    
    .variable-tabs {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    
    .chart-templates {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .ai-analysis-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 576px) {
    .analysis-container {
        padding: 12px;
    }
    
    .analysis-header {
        padding: 20px;
        margin-bottom: 16px;
    }
    
    .header-content h1 {
        font-size: 1.5rem;
    }
    
    .header-subtitle {
        font-size: 1rem;
    }
    
    .quick-stats {
        flex-direction: column;
        gap: 16px;
    }
    
    .tool-section {
        padding: 16px;
    }
    
    .pinned-section,
    .chart-builder,
    .created-charts-section {
        padding: 16px;
    }
}