/* Static IR Drop Visualizer Styles */

/* CSS Variables */
:root {
    --primary-color: #38bdf8; /* Light Blue */
    --secondary-color: #67e8f9; /* Cyan */
    --accent-color: #22d3ee;
    --warning-color: #facc15; /* Yellow */
    --error-color: #f472b6; /* Pink */
    --text-primary: #e0e5f0;
    --text-secondary: #94a3b8;
    --text-light: #9ca3af;
    --bg-primary: #0a0f1f;
    --bg-secondary: #10162b;
    --bg-tertiary: #1a2138;
    --border-color: #2a3352;
    --border-light: #f3f4f6;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 2px 4px var(--shadow-color);
    --shadow-md: 0 4px 8px var(--shadow-color);
    --shadow-lg: 0 10px 20px var(--shadow-color);
    --domain-colors: #38bdf8, #67e8f9, #a78bfa, #f472b6, #facc15, #4ade80;
}

/* Reset and Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.back-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.3s ease;
}

.back-link:hover {
    background: var(--primary-color);
    color: var(--bg-primary);
    transform: translateX(-2px);
}

.back-icon {
    font-size: 1.2rem;
    font-weight: bold;
}

.logo-icon {
    font-size: 2rem;
    color: var(--primary-color);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.header-controls {
    display: flex;
    gap: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 1px solid transparent;
    cursor: pointer;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--bg-primary);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--border-color);
}

.btn-accent {
    background: var(--accent-color);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-accent:hover {
    background: #059669;
    transform: translateY(-2px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 2rem;
    padding: 2rem;
    max-width: 1800px;
    margin: 0 auto;
    flex-grow: 1;
}

/* Control Panel */
.control-panel {
    width: 320px;
    background: var(--bg-primary);
    border-radius: 1rem;
    padding: 1.5rem;
    height: fit-content;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.controls-sidebar {
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(100vh - 120px); /* Adjust based on header height */
}

.panel-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.panel-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.panel-section h3 {
    font-family: 'Roboto Mono', monospace;
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.control-group:last-child {
    margin-bottom: 0;
}

.control-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.control-group input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    margin-bottom: 0.5rem;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: var(--shadow-md);
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    box-shadow: var(--shadow-md);
}

.control-group span {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--primary-color);
}

.control-group select {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.control-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.control-group input[type="checkbox"] {
    margin-right: 0.5rem;
}

.control-group label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    cursor: pointer;
}

/* Info Display */
.info-group {
    background: var(--bg-tertiary);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.info-item:last-child {
    margin-bottom: 0;
}

.info-item strong {
    color: var(--text-primary);
}

/* System Configuration Display */
.system-config {
    background: var(--bg-tertiary);
    border-radius: 0.5rem;
    padding: 1rem;
    font-size: 0.875rem;
    line-height: 1.5;
}

.config-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.375rem 0;
    border-bottom: 1px solid var(--border-color);
}

.config-item:last-child {
    border-bottom: none;
}

.config-label {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.config-value {
    font-weight: 600;
    color: var(--accent-color);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
}

/* Results Display */
.results-display {
    background: var(--bg-tertiary);
    border-radius: 0.5rem;
    padding: 1rem;
    font-size: 0.875rem;
    line-height: 1.5;
}

.results-display p {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.results-display .result-value {
    font-weight: 600;
    color: var(--primary-color);
}

.results-display .result-item {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--border-color);
}

.results-display .result-item:last-child {
    border-bottom: none;
}

.results-display .result-label {
    font-weight: 500;
    color: var(--text-primary);
}

/* Multi-source results display */
.multi-source-results {
    margin-top: 0.5rem;
}

.results-summary {
    background: var(--bg-tertiary);
    padding: 0.75rem;
    border-radius: 6px;
    margin-bottom: 0.75rem;
}

.results-summary h4 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.results-summary p {
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

.individual-sources {
    background: var(--bg-tertiary);
    padding: 0.75rem;
    border-radius: 6px;
}

.individual-sources h4 {
    color: var(--secondary-color);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.individual-sources p {
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

/* Visualization Area */
.visualization-area {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.canvas-container {
    position: relative;
    background: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    flex-grow: 1;
    min-height: 500px;
}

.js-plotly-plot .plotly,
.js-plotly-plot .plotly-graph-div {
    background-color: transparent !important;
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
    white-space: nowrap;
}

.tooltip.visible {
    opacity: 1;
}

/* Color Scale */
.color-scale {
    margin-top: 1rem;
}

.scale-bar {
    height: 20px;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.scale-gradient {
    height: 100%;
    background: linear-gradient(to right, #0066cc, #ffcc00, #ff3300);
}

.scale-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Legend */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-primary);
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 2px;
    border: 1px solid var(--border-color);
}

.legend-color.network {
    background: var(--border-color);
}

.legend-color.bump {
    background: var(--primary-color);
}

.legend-color.virtual {
    background: var(--warning-color);
}

.legend-color.path {
    background: var(--accent-color);
}

.legend-color.current {
    background: var(--error-color);
}

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

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

.modal-content {
    background: var(--bg-primary);
    border-radius: 1rem;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-body h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    margin-top: 1.5rem;
}

.modal-body h3:first-child {
    margin-top: 0;
}

.modal-body p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.6;
}

.modal-body ol,
.modal-body ul {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.modal-body li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.modal-body strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* Multi-source selection styles */
.multi-source-container {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-tertiary);
    padding: 0.75rem;
}

.source-item {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    background: var(--bg-secondary);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.source-item:last-child {
    margin-bottom: 0;
}

.source-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.1);
}

.source-header {
    display: flex;
    align-items: center;
}

.source-header label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0;
}

.source-checkbox {
    margin-right: 0.5rem;
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
}

.source-controls {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.source-controls label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.current-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    margin-bottom: 0.5rem;
}

.current-slider::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: var(--shadow-md);
}

.current-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    box-shadow: var(--shadow-md);
}

.current-display {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--primary-color);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 300px 1fr;
    }
}

@media (max-width: 992px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    .controls-sidebar {
        max-height: none;
    }
}

@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
        padding: 1rem;
    }
    
    .control-panel {
        width: 100%;
        order: 2;
    }
    
    .visualization-area {
        order: 1;
    }
    
    .header-content {
        padding: 1rem;
    }
    
    .logo h1 {
        font-size: 1.2rem;
    }
}

@media (max-width: 768px) {
    .main-content {
        gap: 1rem;
    }
    
    .header-controls {
        gap: 0.5rem;
    }
    
    .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
    
    .legend {
        gap: 0.5rem;
    }
    
    .legend-item {
        font-size: 0.8rem;
    }
    
    .modal-content {
        width: 95%;
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.5s ease-out;
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

.pulse {
    animation: pulse 1s ease-in-out infinite;
}

.glow {
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes glow {
    from { box-shadow: 0 0 5px rgba(79, 70, 229, 0.5); }
    to { box-shadow: 0 0 20px rgba(79, 70, 229, 0.8); }
}
