/**
 * Components CSS - Buttons, Cards, Forms, Badges, Modals
 * Reusable UI components for Atella Simulation Lab
 */

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--bg-card);
    border-radius: 14px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

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

.card-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    font-family: 'DM Mono', monospace;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    padding: 12px 24px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    border: none;
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(196, 112, 75, 0.25);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
}

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

.btn-ghost {
    background: transparent;
    border: none;
    color: var(--accent);
    padding: 8px 12px;
}

.btn-ghost:hover {
    background: var(--accent-light);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 12px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 15px;
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

.form-input,
.form-select,
.form-textarea {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
    transition: border-color 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.form-select {
    cursor: pointer;
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.6;
}

/* Config styles (used in wizard) */
.config-section {
    background: var(--bg-cream);
    border-radius: 12px;
    padding: 20px;
}

.config-section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-family: 'DM Mono', monospace;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.config-section-title .icon {
    width: 20px;
    height: 20px;
    background: var(--accent);
    border-radius: 4px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
}

.config-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.config-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.config-label {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

.config-select {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.2s;
}

.config-select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Search input */
.search-input {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    font-family: inherit;
    font-size: 12px;
    width: 200px;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Filter select */
.filter-select {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    font-family: inherit;
    font-size: 12px;
    color: var(--text);
    cursor: pointer;
}

/* ============================================
   SLIDERS
   ============================================ */
.slider-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slider-label {
    font-size: 12px;
    color: var(--text-muted);
}

.slider-value {
    font-size: 11px;
    font-family: 'DM Mono', monospace;
    color: var(--accent);
    background: var(--accent-light);
    padding: 2px 6px;
    border-radius: 4px;
}

.slider {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(196, 112, 75, 0.3);
}

.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(196, 112, 75, 0.3);
}

/* ============================================
   BADGES & TAGS
   ============================================ */
.tag {
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 10px;
    background: var(--bg-warm);
    color: var(--text-muted);
    font-family: 'DM Mono', monospace;
    display: inline-block;
}

.tag.severe { background: var(--accent-light); color: var(--accent); }
.tag.moderate { background: var(--gold-light); color: var(--gold); }
.tag.mild { background: var(--sage-light); color: var(--sage); }

.badge {
    font-size: 9px;
    padding: 3px 8px;
    border-radius: 10px;
    background: var(--bg-warm);
    color: var(--text-muted);
    font-family: 'DM Mono', monospace;
    text-transform: uppercase;
}

.badge.custom {
    background: var(--accent-light);
    color: var(--accent);
}

/* ============================================
   STATUS INDICATORS
   ============================================ */
.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-indicator.success { background: var(--sage); }
.status-indicator.warning { background: var(--gold); }
.status-indicator.running { background: var(--gold); animation: pulse 1s infinite; }
.status-indicator.failed { background: var(--accent); }

/* ============================================
   TABS
   ============================================ */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
}

.tab {
    padding: 10px 20px;
    border: none;
    background: var(--bg-warm);
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.tab.active {
    background: var(--accent);
    color: white;
}

.tab:hover:not(.active) {
    background: var(--bg-cream);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ============================================
   MODAL
   ============================================ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(45, 42, 38, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 32px;
    max-width: 520px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-title {
    font-size: 22px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: var(--transition);
}

.modal-close:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Help modal specific */
.help-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(45, 42, 38, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.help-modal.active {
    display: flex;
}

.help-content {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 32px;
    max-width: 520px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.help-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.help-title {
    font-size: 22px;
    font-weight: 600;
}

.help-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.help-close:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.help-section {
    margin-bottom: 20px;
}

.help-section-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--accent);
}

.help-section p {
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-muted);
}

/* Modal body and footer */
.modal-body {
    margin-bottom: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.modal-info {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 20px;
    line-height: 1.5;
}

/* Scenario detail rows */
.scenario-detail-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px;
}

.scenario-detail-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.scenario-detail-value {
    font-size: 14px;
    color: var(--text);
    line-height: 1.5;
}

.scenario-detail-description {
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: 8px;
    white-space: pre-wrap;
}

/* Prompt Preview Modal */
.prompt-preview-modal {
    max-width: 900px;
    width: 95%;
    max-height: 85vh;
}

.prompt-preview-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 20px;
}

.preview-info-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.preview-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.preview-value {
    font-size: 14px;
    color: var(--text);
}

.prompt-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
}

.prompt-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: var(--transition);
}

.prompt-tab:hover {
    background: var(--bg-tertiary);
    color: var(--text);
}

.prompt-tab.active {
    background: var(--accent);
    color: white;
}

.prompt-content {
    position: relative;
}

.prompt-panel {
    display: none;
}

.prompt-panel.active {
    display: block;
}

.prompt-description {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
    font-style: italic;
}

.prompt-text {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Monaco', monospace;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 400px;
    overflow-y: auto;
    color: var(--text);
}

.scenario-detail-id {
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    color: var(--text-muted);
}

/* Form elements for modals */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

/* ============================================
   ADVANCED TOGGLE / ACCORDION
   ============================================ */
.advanced-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px 0;
    font-family: 'DM Mono', monospace;
    background: transparent;
    border: none;
}

.advanced-toggle .arrow {
    transition: transform 0.2s;
}

.advanced-toggle.open .arrow {
    transform: rotate(90deg);
}

.advanced-content {
    display: none;
    padding-top: 16px;
}

.advanced-content.open {
    display: block;
}

/* ============================================
   LOADING STATES
   ============================================ */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner.large {
    width: 48px;
    height: 48px;
    border-width: 4px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-cream);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-overlay.active {
    display: flex;
}

.loading-content {
    text-align: center;
}

.loading-content p {
    margin-top: 20px;
    font-size: 14px;
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
}

.loading-error {
    text-align: center;
    padding: 40px;
}

.loading-error h2 {
    font-family: 'Inter', sans-serif;
    font-size: 24px;
    margin-bottom: 12px;
    color: var(--accent);
}

.loading-error p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

/* ============================================
   EMPTY STATES
   ============================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text);
}

.empty-state-description {
    font-size: 13px;
    font-family: 'DM Mono', monospace;
    max-width: 300px;
    margin: 0 auto;
}
