/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #1e293b;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* Header */
.header {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    color: white;
    padding: 40px;
    text-align: center;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
    font-weight: 300;
}

/* Dashboard Layout */
.dashboard-layout {
    display: grid;
    grid-template-columns: 40% 60%;
    gap: 0;
    min-height: calc(100vh - 180px);
    overflow: hidden;
}

/* Parameters Panel */
.parameters-panel {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 30px;
    overflow-y: auto;
    max-height: calc(100vh - 180px);
    border-right: 2px solid #e2e8f0;
}

.parameters-panel h2 {
    margin-top: 0;
    font-size: 1.5rem;
    color: #1e293b;
    margin-bottom: 20px;
}

/* Preset Section */
.preset-section {
    background: white;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.preset-controls {
    display: flex;
    gap: 8px;
}

.preset-selector {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.95rem;
    background: white;
    font-family: inherit;
}

/* Parameter Groups (Collapsible) */
.parameter-group {
    background: white;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.parameter-group summary {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #475569;
    list-style: none;
    user-select: none;
}

.parameter-group summary::-webkit-details-marker {
    display: none;
}

.parameter-group summary:hover {
    color: #2563eb;
}

.group-icon {
    font-size: 1.2rem;
}

.parameter-group h3 {
    font-size: 1.1rem;
    margin: 0;
    font-weight: 600;
}

.parameter-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 12px;
}

.input-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.input-field label {
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 500;
}

.input-field input {
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: all 0.2s;
    font-family: inherit;
}

.input-field input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-field input:invalid {
    border-color: #ef4444;
}

/* Action Controls */
.action-controls {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 2px solid #e2e8f0;
}

.auto-calculate-control {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.auto-calculate-control label {
    font-size: 0.95rem;
    color: #475569;
    font-weight: 500;
    cursor: pointer;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.btn {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

.btn-primary:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-primary.pending {
    background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.btn-secondary {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
    color: white;
    margin-top: 10px;
}

.btn-secondary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-small {
    padding: 10px 16px;
    font-size: 0.9rem;
    width: auto;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-left: 4px solid;
    animation: toast-slide-in 0.3s ease-out;
    min-width: 250px;
    font-weight: 500;
    transition: opacity 0.3s, transform 0.3s;
}

.toast-success {
    border-left-color: #10b981;
    background: #ecfdf5;
    color: #065f46;
}

.toast-error {
    border-left-color: #ef4444;
    background: #fef2f2;
    color: #991b1b;
}

.toast-info {
    border-left-color: #3b82f6;
    background: #eff6ff;
    color: #1e40af;
}

.toast-warning {
    border-left-color: #f59e0b;
    background: #fffbeb;
    color: #92400e;
}

@keyframes toast-slide-in {
    from { transform: translateX(400px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Results Panel */
.results-panel {
    background: white;
    padding: 30px;
    overflow-y: auto;
    max-height: calc(100vh - 180px);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 400px;
    color: #94a3b8;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.empty-state h3 {
    font-size: 1.5rem;
    color: #475569;
    margin-bottom: 10px;
}

.empty-state p {
    font-size: 1rem;
    color: #94a3b8;
}

/* Results Content */
.results-content h2 {
    font-size: 1.8rem;
    margin-bottom: 25px;
    color: #1e293b;
    margin-top: 0;
}

/* Metrics Bar */
.metrics-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.metric-card {
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

.metric-card.metric-value {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.metric-card.metric-time {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.metric-card.metric-nodes {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: white;
}

.metric-card.metric-reduced {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    color: white;
}

.metric-card .value {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.metric-card .label {
    font-size: 0.85rem;
    opacity: 0.9;
}

/* Chart Section */
.chart-section {
    background: #f8fafc;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.chart-section h3 {
    font-size: 1.3rem;
    margin-bottom: 15px;
    margin-top: 0;
    color: #1e293b;
}

.chart-legend {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #475569;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: inline-block;
}

.chart-container {
    position: relative;
    width: 100%;
    height: auto;
}

#probability-chart {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    max-height: 500px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Footer */
.footer {
    background: #1e293b;
    color: white;
    padding: 20px;
    text-align: center;
    font-size: 0.9rem;
}

/* Modal Dialog */
.modal {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: modal-fade-in 0.3s ease-out;
}

@keyframes modal-fade-in {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    padding: 20px;
    border-bottom: 2px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #64748b;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #1e293b;
}

.modal-body {
    padding: 20px;
}

.modal-body label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #475569;
}

.modal-body input,
.modal-body textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.95rem;
    margin-bottom: 15px;
    font-family: inherit;
    box-sizing: border-box;
}

.modal-body input:focus,
.modal-body textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.modal-footer {
    padding: 20px;
    border-top: 2px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-footer .btn {
    width: auto;
    min-width: 100px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
    }

    .parameters-panel {
        max-height: none;
        border-right: none;
        border-bottom: 2px solid #e2e8f0;
    }

    .results-panel {
        max-height: none;
    }

    .parameter-grid {
        grid-template-columns: 1fr;
    }

    .metrics-bar {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    .parameters-panel,
    .results-panel {
        padding: 20px;
    }

    .metrics-bar {
        grid-template-columns: 1fr;
    }

    .metric-card .value {
        font-size: 1.5rem;
    }

    #probability-chart {
        aspect-ratio: 1 / 1;
        max-height: 400px;
    }

    .toast-container {
        top: 60px;
        right: 10px;
        left: 10px;
    }

    .toast {
        min-width: auto;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
