/**
 * CQM Quantum Simulator - SDK Executor Styles
 * Monaco Editor + Pyodide Execution UI
 */

/* ==========================================
   Modal Container
   ========================================== */
.sdk-executor-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sdk-executor-modal.show {
    opacity: 1;
    visibility: visible;
}

.sdk-executor-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
}

.sdk-executor-container {
    position: relative;
    width: 95vw;
    max-width: 1400px;
    height: 90vh;
    max-height: 900px;
    background: linear-gradient(135deg, #0d1117 0%, #161b22 100%);
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5), 0 0 40px rgba(0, 212, 255, 0.1);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.sdk-executor-modal.show .sdk-executor-container {
    transform: translateY(0);
}

/* ==========================================
   Header
   ========================================== */
.sdk-executor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid rgba(0, 212, 255, 0.2);
}

.sdk-executor-title {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #00d4ff;
    font-size: 1.25rem;
    font-weight: 600;
}

.sdk-executor-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ==========================================
   SDK Tabs
   ========================================== */
.sdk-tabs {
    display: flex;
    gap: 4px;
    padding: 12px 24px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    overflow-x: auto;
}

.sdk-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.sdk-tab:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.sdk-tab.active {
    background: linear-gradient(135deg, var(--sdk-color, #00d4ff) 0%, transparent 100%);
    background-size: 200% 100%;
    background-position: left;
    border-color: var(--sdk-color, #00d4ff);
    color: white;
}

.sdk-tab-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.75rem;
}

.sdk-tab.active .sdk-tab-icon {
    background: var(--sdk-color, #00d4ff);
    color: white;
}

.sdk-tab-badge {
    padding: 2px 6px;
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid rgba(16, 185, 129, 0.4);
    border-radius: 4px;
    color: #10b981;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
}

/* ==========================================
   Main Content
   ========================================== */
.sdk-executor-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 1px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

@media (max-width: 1024px) {
    .sdk-executor-content {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 300px;
    }
}

/* ==========================================
   Editor Panel
   ========================================== */
.sdk-editor-panel {
    display: flex;
    flex-direction: column;
    background: #0d1117;
}

.sdk-editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sdk-editor-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sdk-file-icon {
    font-size: 1rem;
}

.sdk-file-name {
    color: #e6edf3;
    font-size: 0.875rem;
    font-weight: 500;
}

.sdk-lang-badge {
    padding: 2px 8px;
    background: rgba(139, 92, 246, 0.2);
    border-radius: 4px;
    color: #a78bfa;
    font-size: 0.75rem;
    font-weight: 500;
}

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

.sdk-monaco-container {
    flex: 1;
    min-height: 300px;
}

/* ==========================================
   Output Panel
   ========================================== */
.sdk-output-panel {
    display: flex;
    flex-direction: column;
    background: #0d1117;
}

.sdk-output-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sdk-output-tab {
    padding: 6px 16px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sdk-output-tab:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.sdk-output-tab.active {
    background: rgba(0, 212, 255, 0.2);
    color: #00d4ff;
}

.sdk-output-content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Console */
.sdk-console {
    height: 100%;
    padding: 16px;
    overflow-y: auto;
    font-family: 'Fira Code', 'Monaco', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
}

.sdk-console-welcome {
    text-align: center;
    padding: 40px;
    color: rgba(255, 255, 255, 0.5);
}

.sdk-console-welcome p:first-child {
    font-size: 1.5rem;
    margin-bottom: 12px;
}

.sdk-console-hint {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.4);
}

.sdk-console-line {
    padding: 4px 0;
    word-break: break-all;
}

.sdk-console-time {
    color: rgba(255, 255, 255, 0.4);
    margin-right: 8px;
}

.sdk-console-info { color: #58a6ff; }
.sdk-console-output { color: #e6edf3; }
.sdk-console-success { color: #3fb950; }
.sdk-console-error { color: #f85149; }
.sdk-console-warning { color: #d29922; }

/* Histogram */
.sdk-histogram {
    height: 100%;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.histogram-title {
    color: #00d4ff;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    text-align: center;
}

.histogram-chart {
    flex: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 16px;
    padding-bottom: 60px;
}

.histogram-bar-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    min-width: 60px;
}

.histogram-bar {
    width: 40px;
    background: linear-gradient(to top, #00d4ff, #8b5cf6);
    border-radius: 4px 4px 0 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 8px;
    transition: height 0.5s ease;
    position: relative;
}

.histogram-value {
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
}

.histogram-label {
    margin-top: 8px;
    color: #00d4ff;
    font-family: 'Fira Code', monospace;
    font-size: 0.875rem;
    font-weight: 600;
}

.histogram-prob {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
}

/* State Vector */
.sdk-statevector {
    height: 100%;
    padding: 16px;
    overflow-y: auto;
    font-family: 'Fira Code', monospace;
    font-size: 0.875rem;
}

/* ==========================================
   Footer / Run Bar
   ========================================== */
.sdk-executor-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: rgba(0, 0, 0, 0.4);
    border-top: 1px solid rgba(0, 212, 255, 0.2);
}

.sdk-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sdk-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3fb950;
}

.sdk-status-dot.sdk-status-loading {
    background: #d29922;
    animation: pulse 1s infinite;
}

.sdk-status-dot.sdk-status-error {
    background: #f85149;
}

.sdk-status-dot.sdk-status-success {
    background: #3fb950;
}

.sdk-status-text {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
}

.sdk-run-actions {
    display: flex;
    gap: 12px;
}

/* ==========================================
   Buttons
   ========================================== */
.sdk-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sdk-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
}

.sdk-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sdk-btn-sm {
    padding: 6px 12px;
    font-size: 0.75rem;
}

.sdk-btn-icon {
    padding: 8px;
    border-radius: 6px;
}

.sdk-btn-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
}

.sdk-btn-close:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.sdk-btn-primary {
    background: linear-gradient(135deg, #00d4ff 0%, #0066ff 100%);
    border-color: #00d4ff;
}

.sdk-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #00e5ff 0%, #0077ff 100%);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.4);
}

.sdk-btn-secondary {
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.4);
}

.sdk-btn-secondary:hover:not(:disabled) {
    background: rgba(139, 92, 246, 0.3);
}

/* Spinner */
.sdk-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ==========================================
   API Settings Modal
   ========================================== */
.api-settings-modal {
    position: fixed;
    inset: 0;
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.api-settings-modal.show {
    opacity: 1;
    visibility: visible;
}

.api-settings-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.api-settings-container {
    position: relative;
    width: 90vw;
    max-width: 600px;
    max-height: 80vh;
    background: #161b22;
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 12px;
    overflow: hidden;
}

.api-settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.api-settings-header h3 {
    color: #00d4ff;
    font-size: 1.125rem;
    font-weight: 600;
}

.api-settings-content {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(80vh - 80px);
}

.api-notice {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: rgba(217, 70, 239, 0.1);
    border: 1px solid rgba(217, 70, 239, 0.3);
    border-radius: 8px;
    margin-bottom: 24px;
}

.api-notice svg {
    flex-shrink: 0;
    color: #d946ef;
}

.api-notice p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.875rem;
    line-height: 1.5;
}

.api-provider-card {
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    margin-bottom: 16px;
}

.api-provider-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.api-provider-name {
    color: white;
    font-weight: 600;
}

.api-provider-status {
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.api-provider-status.enabled {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.api-provider-status.disabled {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
}

.api-provider-fields {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.api-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.api-field label {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
    font-weight: 500;
}

.api-field input,
.api-field select {
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: white;
    font-size: 0.875rem;
}

.api-field input:disabled,
.api-field select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.api-field input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

/* ==========================================
   Responsive
   ========================================== */
@media (max-width: 768px) {
    .sdk-executor-container {
        width: 100vw;
        height: 100vh;
        max-height: none;
        border-radius: 0;
    }

    .sdk-tabs {
        padding: 8px 12px;
    }

    .sdk-tab {
        padding: 8px 12px;
    }

    .sdk-tab-name {
        display: none;
    }

    .sdk-executor-footer {
        flex-direction: column;
        gap: 12px;
    }

    .sdk-run-actions {
        width: 100%;
        justify-content: stretch;
    }

    .sdk-run-actions .sdk-btn {
        flex: 1;
        justify-content: center;
    }
}
