/* Simulation Editor Styles — matches main dashboard design system */
/* Uses CSS variables from styles.css :root and patterns from dialog.css */

/* Layout */
.simulation-editor {
    max-width: var(--spacing-3xl, 64px) * 18.75;  /* 1200px via container max */
    max-width: 1200px;
    margin: 0 auto;
}

/* Title Ribbon — matches dashboard navbar exactly */
.sim-title-ribbon {
    background: var(--primary, #800020);
    padding: var(--spacing-md) var(--spacing-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

/* Ribbon action buttons — outlined style matching Generate Now */
.sim-ribbon-btn {
    background-color: white;
    color: var(--primary);
    border: 2px solid var(--primary);
    border-radius: var(--border-radius);
    padding: var(--spacing-xs) var(--spacing-md);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.sim-ribbon-btn:hover {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Secondary ribbon buttons — match Login/Logout style */
.sim-ribbon-btn-secondary {
    background: var(--primary);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 4px;
    padding: 4px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sim-ribbon-btn-secondary:hover {
    background: var(--primary-dark);
    border-color: rgba(255, 255, 255, 0.7);
}

.sim-ribbon-brand {
    text-decoration: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sim-ribbon-title {
    color: white;
    font-size: var(--font-size-xl, 20px);
    font-weight: 600;
    letter-spacing: -0.5px;
}

.sim-patient-name {
    color: white;
    font-size: var(--font-size-xl, 20px);
    font-weight: 600;
}

.sim-patient-id {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.8);
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
}

/* Panel titles — match .section-title from components.css */
.sim-panel-content h3,
.sim-panel-content .sim-panel-title {
    font-size: var(--font-size-2xl, 24px);
    font-weight: 600;
    color: var(--primary);
    margin-bottom: var(--spacing-md);
}

.sim-panel-content h4 {
    color: var(--primary);
    font-weight: 600;
}

.sim-panel-content p {
    color: var(--text-primary);
}

.sim-ribbon-subtitle {
    color: rgba(255, 255, 255, 0.75);
    font-size: var(--font-size-sm, 14px);
    font-weight: 400;
}

/* Header — mirrors dialog-header pattern */
.sim-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--surface);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    border: var(--border-width) solid var(--divider);
    border-bottom: none;
}

.sim-patient-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

/* Header variant — only inside .sim-header */
.sim-header .sim-patient-name {
    font-size: var(--font-size-2xl, 24px);
    font-weight: 700;
    color: var(--primary);
}

.sim-header .sim-patient-id {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    background: var(--surface);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    border: var(--border-width) solid var(--divider);
}

/* Tabs — mirrors dialog-tabs pattern */
.sim-tabs {
    display: flex;
    gap: var(--spacing-xs);
    background: var(--surface);
    border: var(--border-width) solid var(--divider);
    border-top: none;
    padding: var(--spacing-xs) var(--spacing-sm) 0;
}

.sim-tab {
    padding: var(--spacing-sm) var(--spacing-lg);
    background: transparent;
    border: var(--border-width) solid transparent;
    border-bottom: none;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    cursor: pointer;
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    outline: none;
}

.sim-tab:hover {
    background: var(--surface-alt);
    color: var(--text-primary);
}

.sim-tab.active {
    background: var(--background);
    color: var(--primary);
    border-color: var(--divider);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

/* Content area — mirrors dialog-body pattern */
.sim-content {
    background: var(--background);
    border: var(--border-width) solid var(--divider);
    border-top: none;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    padding: var(--spacing-lg);
    min-height: 400px;
    box-shadow: var(--shadow-medical);
}

.sim-panel-content {
    max-width: 900px;
}

/* Form groups — uses forms.css patterns */
.sim-panel-content .form-group {
    margin-bottom: var(--spacing-md);
}

.sim-panel-content .form-label {
    display: block;
    font-family: var(--font-family);
    font-weight: 500;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
}

.sim-panel-content .form-control {
    width: 100%;
    padding: var(--spacing-xs) var(--spacing-sm);
    border: var(--border-width) solid var(--divider);
    border-radius: var(--border-radius);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.sim-panel-content .form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(128, 0, 32, 0.1);
}

.sim-panel-content textarea.form-control {
    resize: vertical;
    font-family: var(--font-family);
}

.sim-panel-content .font-monospace {
    font-family: 'Courier New', Courier, monospace;
}

/* Generate Now button — matches .btn-primary from styles.css */
.simulation-editor .generate-btn {
    padding: var(--spacing-sm) var(--spacing-lg);
    background-color: var(--primary);
    color: white;
    border: var(--border-width-thick) solid var(--primary);
    border-radius: var(--border-radius);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.simulation-editor .generate-btn:hover:not(:disabled) {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.simulation-editor .generate-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.simulation-editor .generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* V2 variant — left border accent distinguishes from V1 */
.simulation-editor .generate-btn-v2 {
    border-left: 4px solid var(--info);
}

/* Generation status — reuses dialog.css generation-status pattern */
.generation-status {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 20px;
    background: var(--surface);
    font-size: var(--font-size-sm);
    margin-top: var(--spacing-md);
    width: 100%;
    max-width: 900px;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

.status-generated {
    background: var(--primary);
    animation: none;
}

.status-pending {
    background: var(--text-secondary);
    animation: none;
}

.status-text {
    color: var(--text-primary);
    font-weight: 500;
}

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

/* Accordion (details/summary) — native HTML, no Bootstrap */
.sim-chunk-accordion details {
    border: var(--border-width) solid var(--divider);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-sm);
    overflow: hidden;
}

.sim-chunk-accordion details[open] summary {
    border-bottom: var(--border-width) solid var(--divider);
    background: var(--primary);
    color: white;
}

.sim-chunk-accordion summary {
    padding: var(--spacing-sm) var(--spacing-lg);
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 500;
    background: var(--surface);
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sim-chunk-accordion summary::-webkit-details-marker {
    display: none;
}

.sim-chunk-accordion details[open] .chunk-body {
    padding: var(--spacing-md) var(--spacing-lg);
}

/* Chunk body */
.chunk-body .form-group {
    margin-bottom: var(--spacing-sm);
}

.chunk-body .form-select {
    padding: var(--spacing-xs) var(--spacing-sm);
    border: var(--border-width) solid var(--divider);
    border-radius: var(--border-radius);
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
}

.chunk-body textarea {
    width: 100%;
    padding: var(--spacing-xs) var(--spacing-sm);
    border: var(--border-width) solid var(--divider);
    border-radius: var(--border-radius);
    font-family: 'Courier New', Courier, monospace;
    font-size: var(--font-size-sm);
    resize: vertical;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.chunk-body textarea:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(128, 0, 32, 0.1);
}

/* Badges — medical theme */
.badge {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 500;
}

.bg-success {
    background: #d4edda;
    color: #155724;
}

.bg-secondary {
    background: var(--surface);
    color: var(--text-secondary);
}

.bg-danger {
    background: #f8d7da;
    color: #721c24;
}

.bg-info {
    background: #d1ecf1;
    color: #0c5460;
}

/* Download list — matches dialog.css downloadables-content */
.download-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.download-item {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--surface);
    border-radius: var(--border-radius);
    border: var(--border-width) solid var(--divider);
    transition: all 0.2s ease;
}

.download-item:hover {
    background: #e9ecef;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.download-item-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin: 0 0 var(--spacing-xs) 0;
    color: var(--text-primary);
}

.download-item-desc {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin: 0;
}

.download-item-content {
    flex: 1;
    min-width: 280px;
}

/* Download button — matches .btn-primary from styles.css */
.download-btn {
    flex-shrink: 0;
    min-width: 90px;
    text-align: center;
    padding: var(--spacing-sm) var(--spacing-lg);
    background-color: var(--primary);
    color: white;
    border: var(--border-width-thick) solid var(--primary);
    border-radius: var(--border-radius);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.download-btn:hover:not(:disabled) {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.download-btn:disabled {
    background-color: var(--surface-alt, #f0f0f0);
    color: var(--text-secondary);
    border: 2px dashed var(--border-medium, #ccc);
    box-shadow: none;
    cursor: not-allowed;
    opacity: 1.0;
}

.download-btn:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Progress bar — matches dialog.css progress pattern */
.progress-bar-track {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    margin-bottom: var(--spacing-sm);
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-maroon) 0%, #8B0000 100%);
    border-radius: var(--border-radius-sm);
    transition: width 0.3s ease;
}

.progress-text {
    margin: var(--spacing-sm) 0 0 0;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    text-align: center;
}

.progress-container {
    width: 100%;
    margin-top: var(--spacing-sm);
    padding: var(--spacing-xs) 0;
}

/* Action buttons — matches .btn-primary from design system */
.sim-action-btn {
    padding: var(--spacing-sm) var(--spacing-lg);
    background-color: var(--primary);
    color: white;
    border: var(--border-width-thick) solid var(--primary);
    border-radius: var(--border-radius);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    display: inline-block;
}

.sim-action-btn:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.sim-action-btn-danger {
    background-color: #8B0000;
    border-color: #8B0000;
}

.sim-action-btn-danger:hover {
    background-color: #5C0012;
    border-color: #5C0012;
}

/* Video Creator — Chunk cards */
.vm-chunks-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
}

.vm-chunk-card {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    border: var(--border-width) solid var(--divider);
    border-radius: var(--border-radius);
    background: var(--background);
    transition: all 0.2s ease;
}

.vm-chunk-card:hover {
    box-shadow: var(--shadow-sm);
}

.vm-chunk-text {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-top: var(--spacing-xs);
    line-height: 1.5;
}

.vm-video-panel {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--spacing-xs);
    min-width: 200px;
}

/* Video status badges */
.vm-status {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
}

.vm-status-none { background: var(--surface); color: var(--text-secondary); }
.vm-status-completed { background: #d4edda; color: #155724; }
.vm-status-processing, .vm-status-thinking, .vm-status-generating { background: #fff3cd; color: #856404; }
.vm-status-failed { background: #f8d7da; color: #721c24; }

/* Video action buttons — matches .btn pattern */
.vm-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    align-items: center;
}

.vm-btn {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-md);
    border: var(--border-width-thick) solid var(--divider);
    border-radius: var(--border-radius);
    font-family: var(--font-family);
    font-size: var(--font-size-xs);
    font-weight: 500;
    cursor: pointer;
    background: var(--background);
    transition: all 0.2s ease;
}

.vm-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.vm-btn-play { border-color: var(--success); color: var(--success); }
.vm-btn-play:hover { background: var(--success); color: white; }
.vm-btn-download { border-color: var(--info); color: var(--info); }
.vm-btn-download:hover { background: var(--info); color: white; }
.vm-btn-retry { border-color: var(--warning); color: var(--warning); }
.vm-btn-retry:hover { background: var(--warning); color: white; }
.vm-btn-create { border-color: var(--primary); color: var(--primary); }
.vm-btn-create:hover { background: var(--primary); color: white; }

/* Video modal — z-index from design system */
.vm-video-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: var(--z-modal-backdrop);
    justify-content: center;
    align-items: center;
}

.vm-modal-body {
    background: var(--background);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-lg);
    max-width: 800px;
    width: 90%;
    position: relative;
    box-shadow: var(--shadow-xl);
}

.vm-modal-close {
    position: absolute;
    top: var(--spacing-xs); right: var(--spacing-sm);
    border: none;
    background: transparent;
    font-size: var(--font-size-2xl);
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.vm-modal-close:hover { color: var(--text-primary); }

/* Loading indicator — smaller version for inline use */
.simulation-editor .spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--divider);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    padding: var(--spacing-xl);
}

.loading-container .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--divider);
    border-top-color: var(--primary);
}

.loading-container .loading-text {
    margin-top: var(--spacing-md);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

/* HTMX indicator states */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-request.htmx-indicator {
    display: inline-block;
}

/* Empty state — matches dialog-empty from dialog.css */
.sim-empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.sim-empty-state h3 {
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
    font-size: 1.5rem;
}

/* Patient actions — library card buttons */
.patient-actions {
    display: flex;
    gap: var(--spacing-sm);
}

/* Responsive — matches dialog.css responsive pattern */
@media (max-width: 768px) {
    .sim-header {
        flex-direction: column;
        gap: var(--spacing-sm);
        align-items: flex-start;
    }

    .sim-tabs {
        flex-direction: column;
        padding: 0;
    }

    .sim-tab {
        border-radius: 0;
        border-bottom: var(--border-width) solid var(--divider);
    }

    .sim-tab.active {
        border-bottom-color: var(--primary);
    }

    .vm-chunk-card {
        flex-direction: column;
    }

    .vm-video-panel {
        align-items: flex-start;
        min-width: 100%;
    }

    .download-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .download-btn {
        width: 100%;
        text-align: center;
    }
}
