/**
 * Visualize Page Styles
 * Designed to work within the Unity theme framework
 */

/* Suppress Plotly's "Taking snapshot..." toast on PNG export */
.plotly-notifier { display: none !important; }

/* ============================================================================
   Mode Toggle Bar
   ========================================================================== */

.viz-mode-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    background: #f0f4f8;
    border-top-right-radius: 8px;
    border-top-left-radius: 8px;
}

.viz-mode-btn {
    padding: 8px 24px;
    border: none;
    border-radius: 6px !important; /* override Unity button { border-radius: 0 } */
    background: transparent;
    color: #6b7280;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.viz-mode-btn:hover {
    color: #333;
    background: rgba(255,255,255,0.5);
}

.viz-mode-btn.active {
    background: #fff;
    color: #198754;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.viz-mode-btn.btn-reset {
    color: #ff1f1f;
}

/* ============================================================================
   Filter Panel (shared)
   ========================================================================== */

.viz-filters {
    padding: 16px 20px;
    border-top-left-radius: 0px !important;
    border-top-right-radius: 0px !important;
    border-bottom-left-radius: 8px !important;
    border-bottom-right-radius: 8px !important;
}

.viz-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 16px;
    align-items: flex-start;
}

.viz-filter-group {
    display: flex;
    flex-direction: column;
}

.viz-filter-garden {
    flex: 1 1 100%; /* own row */
}

.viz-filter-plants {
    flex: 1 1 0;
    min-width: 200px;
}

.viz-filter-years {
    flex: 1 1 0;
    min-width: 200px;
}

.viz-filter-label {
    font-weight: 600;
    color: #555;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.viz-filters .form-select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
}

.viz-filters .form-select:focus {
    border-color: #198754;
    box-shadow: 0 0 0 2px rgba(25,135,84,0.15);
}

/* ============================================================================
   Pills (plant type & year selectors)
   ========================================================================== */

.viz-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.viz-pill {
    padding: 5px 14px;
    border: 1.5px solid #dee2e6;
    border-radius: 20px !important; /* override Unity button { border-radius: 0 } */
    background: #fff;
    color: #555;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.viz-pill:hover {
    border-color: #198754;
    color: #198754;
    background: #f0fdf4;
}

.viz-pill.active {
    border-color: #198754;
    background: #198754;
    color: #fff;
}

/* Multi-select pills (comparison mode) */
.viz-pills-multi .viz-pill.active {
    background: #0d6efd;
    border-color: #0d6efd;
}

.viz-pills-multi .viz-pill:hover {
    border-color: #0d6efd;
    color: #0d6efd;
    background: #eff6ff;
}

/* Plant type icons */
.viz-pill-icon {
    margin-right: 4px;
}

/* Date range toggle */
.viz-date-toggle {
    color: #6b7280;
    text-decoration: none;
    font-size: 0.8rem;
}

.viz-date-toggle:hover {
    color: #198754;
}

/* Empty state message for pills with no data */
.viz-empty-msg {
    font-size: 0.85rem;
    color: #9ca3af;
    font-style: italic;
    padding: 4px 0;
}

.viz-date-range {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.viz-date-range .form-control {
    max-width: 160px;
    padding: 8px 14px;
}

/* ============================================================================
   Compare Mode
   ========================================================================== */

.viz-compare-types {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.viz-compare-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 16px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 10px !important; /* override Unity */
    background: #fff;
    cursor: pointer;
    transition: all 0.2s;
}

.viz-compare-card:hover {
    border-color: #0d6efd;
    background: #f8faff;
    transform: translateY(-1px);
}

.viz-compare-card.active {
    border-color: #0d6efd;
    background: #eff6ff;
}

.viz-compare-icon {
    font-size: 1.5rem;
    color: #6b7280;
    margin-bottom: 6px;
}

.viz-compare-card.active .viz-compare-icon {
    color: #0d6efd;
}

.viz-compare-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: #333;
}

.viz-compare-desc {
    font-size: 0.78rem;
    color: #9ca3af;
    margin-top: 2px;
}

/* Compare filters area */
.viz-compare-filters {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

.viz-compare-select {
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

/* Checkbox list for garden multi-select */
.viz-checkbox-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fafafa;
}

.viz-checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
}

.viz-checkbox-item:hover {
    background: #eff6ff;
}

.viz-checkbox-item input[type="checkbox"] {
    accent-color: #0d6efd;
}

.viz-checkbox-count {
    color: #6b7280;
    font-size: 0.78rem;
    margin-left: auto;
    padding-left: 6px;
}

/* Chips (active filters & comparison selections) */
.viz-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.viz-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: #e3f2fd;
    color: #1565c0;
    border-radius: 16px;
    font-size: 0.82rem;
    font-weight: 500;
}

.viz-chip-close {
    cursor: pointer;
    font-weight: bold;
    opacity: 0.6;
    font-size: 0.9rem;
}

.viz-chip-close:hover {
    opacity: 1;
}


/* ============================================================================
   Chart Type Toggle
   ========================================================================== */

.viz-chart-type-bar {
    display: flex;
    align-items: center;
}

.viz-chart-toggle {
    display: inline-flex;
    gap: 2px;
    padding: 2px;
    background: #f0f4f8;
    border-radius: 6px;
}

.viz-chart-type-btn {
    padding: 4px 14px;
    border: none;
    border-radius: 4px !important; /* override Unity */
    background: transparent;
    color: #6b7280;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.viz-chart-type-btn:hover {
    color: #333;
}

.viz-chart-type-btn.active {
    background: #fff;
    color: #198754;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

/* ============================================================================
   Chart Interaction Tips
   ========================================================================== */

.viz-chart-tips {
    padding: 8px 12px;
    background: #fff8e1;
    border-left: 3px solid #f59e0b;
    border-radius: 4px;
    color: #555;
    line-height: 1.5;
}

.viz-chart-tips .fa-lightbulb {
    color: #f59e0b;
}

/* ============================================================================
   Statistics Badges
   ========================================================================== */

.stats-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #f0f4f8;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    font-size: 0.82rem;
    white-space: nowrap;
    max-width: 100%;
}

.stat-badge-label {
    color: #6b7280;
    font-weight: 500;
}

.stat-badge-value {
    color: #333;
    font-weight: 600;
}

.compare-stats-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.compare-stat-card {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background: #f0f4f8;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    font-size: 0.82rem;
    white-space: nowrap;
    max-width: 100%;
}

.compare-stat-swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.compare-stat-name {
    color: #333;
    font-weight: 600;
}

.compare-stat-meta {
    color: #6b7280;
    font-weight: 500;
}

.compare-stat-meta .compare-stat-value {
    color: #333;
    font-weight: 600;
}

/* ============================================================================
   Chart Container
   ========================================================================== */

.chart-container {
    padding: 16px;
    min-height: 400px;
    position: relative;
}

.plotly-chart {
    width: 100%;
    min-height: 450px;
}

/* Loading Indicator */
.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 450px;
    color: #999;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #198754;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

/* Placeholder */
.chart-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 450px;
}

.placeholder-content {
    text-align: center;
    color: #999;
}

.placeholder-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.4;
}

.placeholder-content h3 {
    margin: 0 0 8px 0;
    color: #666;
    font-size: 1.1rem;
}

.placeholder-content p {
    margin: 0;
    color: #999;
    font-size: 0.9rem;
}

/* No Data Message */
.no-data-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 450px;
    color: #999;
}

.no-data-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.4;
}

.no-data-message h3 {
    margin: 0 0 8px 0;
    color: #666;
    font-size: 1.1rem;
}

.no-data-message p {
    margin: 0;
    color: #999;
}

/* ============================================================================
   Error Toast
   ========================================================================== */

.error-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(400px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.error-toast-content {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #ef4444;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    min-width: 280px;
    font-size: 0.9rem;
}

.error-toast-icon {
    font-size: 1.3rem;
}

.error-toast-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0;
    margin-left: auto;
    opacity: 0.8;
}

.error-toast-close:hover {
    opacity: 1;
}

/* ============================================================================
   Ozone Concentration Section
   ========================================================================== */

.ozone-section h2 {
    color: #333;
}

.ozone-date-override {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

/* Unity override: restore checked state for switches (Unity sets background-color: transparent) */
.ozone-section .form-switch .form-check-input:checked {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

.ozone-custom-dates {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* ============================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    .viz-filter-row {
        flex-direction: column;
    }

    .viz-filter-garden {
        width: 100%;
    }

    .viz-compare-types {
        grid-template-columns: 1fr;
    }

    .chart-container {
        padding: 12px;
    }

    .viz-date-range {
        flex-wrap: wrap;
    }

    .viz-date-range .form-control {
        max-width: 100%;
    }

    .ozone-custom-dates {
        flex-wrap: wrap;
        width: 100%;
    }

    .ozone-custom-dates input[type="date"] {
        flex: 1;
    }
}
