/* ============================================
   MODALS - Dialog and Overlay Styling
   ============================================ */

/* Modal overlay */
.modal-overlay,
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: var(--z-modal-backdrop);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Modal dialog */
.modal,
.modal-dialog {
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    z-index: var(--z-modal);
    color: var(--text-primary);
}

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

.modal-title {
    font-size: 1.2rem;
    font-weight: 600;
    font-family: var(--font-display);
    color: var(--clr-primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

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

.modal-body {
    padding: 20px;
}

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

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-left: 3px solid var(--clr-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-tooltip);
    color: var(--text-primary);
    font-size: 0.85rem;
    max-width: 400px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-med), transform var(--transition-med);
}

.toast.show {
    opacity: 1;
    pointer-events: auto;
    animation: slideInRight 0.3s ease;
}

.toast.loading::after {
    content: ' …';
    animation: toastPulse 1s ease-in-out infinite;
}

@keyframes toastPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.toast.success {
    border-left-color: var(--energy-green);
}

.toast.error {
    border-left-color: var(--energy-red);
}

.toast.warning {
    border-left-color: var(--energy-amber);
}

.toast.info {
    border-left-color: var(--energy-blue);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================
   HINT POPUP - Mission Control Style
   ============================================ */
.hint-popup {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--space-800);
    border: 1px solid var(--clr-primary);
    border-radius: var(--radius-lg);
    padding: 16px 32px;
    max-width: 700px;
    min-width: 500px;
    z-index: 10000;
    animation: slideUp 0.3s ease;
    pointer-events: auto;
    visibility: visible;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(34, 211, 238, 0.15);
}

.hint-popup.hidden {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    opacity: 0 !important;
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.hint-popup h3 {
    font-family: var(--font-display);
    margin: 0 0 10px 0;
    color: var(--clr-primary);
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.hint-popup p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
}

.hint-popup .hint-buttons {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.hint-popup button {
    font-family: var(--font-display);
    padding: 10px 20px;
    border: 1px solid;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    pointer-events: auto;
    flex: 1;
    min-width: 90px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all var(--transition-fast);
}

.hint-popup #hintDismiss {
    background: var(--gradient-primary);
    border-color: var(--clr-primary);
    color: var(--space-900);
    box-shadow: var(--glow-primary);
}

.hint-popup #hintDismiss:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(34, 211, 238, 0.4);
}

.hint-popup #hintNext {
    background: rgba(var(--clr-success-rgb), 0.2);
    border-color: var(--status-nominal);
    color: var(--status-nominal);
}

.hint-popup #hintNext:hover {
    background: rgba(var(--clr-success-rgb), 0.3);
    box-shadow: var(--glow-green);
}

.hint-popup #hintHide {
    background: rgba(var(--clr-danger-rgb), 0.2);
    border-color: var(--status-warning);
    color: var(--status-warning);
}

.hint-popup #hintHide:hover {
    background: rgba(var(--clr-danger-rgb), 0.3);
    box-shadow: var(--glow-red);
}

/* ============================================
   ACHIEVEMENT OVERLAY - Mission Control Style
   ============================================ */
.achievement-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 14, 26, 0.95);
    z-index: 10001;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.5s ease;
    backdrop-filter: blur(4px);
}

.achievement-overlay.visible {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.achievement-content {
    background: var(--space-700);
    border: 2px solid var(--status-nominal);
    border-radius: 16px;
    padding: 32px 48px;
    max-width: 600px;
    text-align: center;
    box-shadow: 
        0 0 60px rgba(16, 185, 129, 0.3),
        0 20px 50px rgba(0, 0, 0, 0.5);
}

.achievement-content h1 {
    font-family: var(--font-display);
    color: var(--status-nominal);
    font-size: 26px;
    font-weight: 700;
    margin: 0 0 24px 0;
    text-shadow: var(--glow-green);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.achievement-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin: 24px 0;
}

.achievement-stat {
    background: var(--space-800);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--space-500);
}

.achievement-stat .label {
    font-family: var(--font-display);
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.achievement-stat .value {
    font-family: var(--font-mono);
    font-size: 22px;
    font-weight: 700;
    color: var(--text-data);
    margin-top: 6px;
    text-shadow: var(--glow-cyan);
}

.achievement-stat .value.system-review-stat-disabled {
    color: var(--text-dim);
    opacity: 0.5;
}

.system-review-cost-section {
    background: var(--space-800);
    border: 1px solid var(--space-500);
    border-radius: 8px;
    padding: 14px 16px;
    margin-top: 4px;
}

.system-review-cost-title {
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 10px;
}

.system-review-cost-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
    color: var(--text-primary);
    padding: 4px 0;
}

.system-review-cost-row.system-review-cost-total {
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--space-500);
    font-weight: 700;
    color: var(--text-data);
}

/* ============================================
   INCIDENT REPORT MODAL - Enhanced Failure Feedback
   ============================================ */
.incident-report-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 14, 26, 0.9);
    z-index: 100001;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease;
}

.incident-report-overlay.visible {
    display: flex;
}

.incident-report {
    background: linear-gradient(180deg, var(--space-700) 0%, var(--space-800) 100%);
    border: 2px solid var(--status-warning);
    border-radius: 12px;
    max-width: 440px;
    width: 92%;
    max-height: min(85vh, 480px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 
        0 0 60px rgba(239, 68, 68, 0.25),
        0 20px 40px rgba(0, 0, 0, 0.55);
    animation: incidentSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.incident-report.warning-level {
    border-color: var(--status-caution);
    box-shadow: 
        0 0 80px rgba(245, 158, 11, 0.3),
        0 25px 50px rgba(0, 0, 0, 0.6);
}

.incident-report.info-level {
    border-color: var(--energy-cyan);
    box-shadow: 
        0 0 80px rgba(6, 182, 212, 0.3),
        0 25px 50px rgba(0, 0, 0, 0.6);
}

.incident-report.success-level {
    border-color: var(--status-nominal);
    box-shadow: 
        0 0 80px rgba(16, 185, 129, 0.3),
        0 25px 50px rgba(0, 0, 0, 0.6);
}

.incident-report.explanation-level {
    border-color: var(--energy-cyan);
    box-shadow: 
        0 0 80px rgba(6, 182, 212, 0.4),
        0 25px 50px rgba(0, 0, 0, 0.6);
}

@keyframes incidentSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.incident-header {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2) 0%, rgba(239, 68, 68, 0.05) 100%);
    padding: 12px 16px;
    border-bottom: 1px solid rgba(239, 68, 68, 0.3);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.incident-report.warning-level .incident-header {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(245, 158, 11, 0.05) 100%);
    border-color: rgba(245, 158, 11, 0.3);
}

.incident-report.info-level .incident-header {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.2) 0%, rgba(6, 182, 212, 0.05) 100%);
    border-color: rgba(6, 182, 212, 0.3);
}

.incident-report.success-level .incident-header {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2) 0%, rgba(16, 185, 129, 0.05) 100%);
    border-color: rgba(16, 185, 129, 0.3);
}

.incident-report.explanation-level .incident-header {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.25) 0%, rgba(6, 182, 212, 0.1) 100%);
    border-color: rgba(6, 182, 212, 0.4);
}

.incident-icon {
    font-size: 32px;
    line-height: 1;
    flex-shrink: 0;
}

.incident-title-group {
    flex: 1;
}

.incident-type {
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--status-warning);
    margin-bottom: 2px;
}

.incident-report.warning-level .incident-type {
    color: var(--status-caution);
}

.incident-report.info-level .incident-type {
    color: var(--energy-cyan);
}

.incident-report.success-level .incident-type {
    color: var(--status-nominal);
}

.incident-report.explanation-level .incident-type {
    color: var(--energy-cyan);
}

.incident-title {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.25;
}

.incident-body {
    padding: 12px 16px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

.incident-section {
    margin-bottom: 12px;
}

.incident-section:last-child {
    margin-bottom: 0;
}

.incident-section-title {
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.incident-section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--space-500);
}

.incident-description {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.45;
    margin: 0;
}

.incident-math {
    background: var(--space-800);
    border: 1px solid var(--space-500);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}

.incident-math-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}

.incident-math-row:not(:last-child) {
    border-bottom: 1px dashed var(--space-500);
}

.incident-math-label {
    color: var(--text-tertiary);
}

.incident-math-value {
    color: var(--text-primary);
    font-weight: 600;
}

.incident-math-value.danger {
    color: var(--status-warning);
}

.incident-math-value.warning {
    color: var(--status-caution);
}

.incident-math-value.good {
    color: var(--status-nominal);
}

.incident-realworld {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, transparent 100%);
    border-left: 3px solid var(--status-warning);
    padding: 8px 10px;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.incident-report.warning-level .incident-realworld {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, transparent 100%);
    border-left-color: var(--status-caution);
}

.incident-realworld-title {
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 600;
    color: var(--status-warning);
    margin-bottom: 2px;
}

.incident-report.warning-level .incident-realworld-title {
    color: var(--status-caution);
}

.incident-realworld-text {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.4;
    margin: 0;
}

.incident-solution {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, transparent 100%);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-md);
    padding: 10px 12px;
}

.incident-solution-title {
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 600;
    color: var(--status-nominal);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.incident-solution-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.incident-solution-list li {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.4;
    padding: 2px 0 2px 18px;
    position: relative;
}

.incident-solution-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--status-nominal);
    font-weight: bold;
}

.incident-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--space-500);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-shrink: 0;
    background: var(--space-800);
}

.incident-btn {
    font-family: var(--font-display);
    padding: 8px 18px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid;
}

.incident-btn-primary {
    background: var(--gradient-primary);
    border-color: var(--clr-primary);
    color: var(--space-900);
}

.incident-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(34, 211, 238, 0.4);
}

.incident-btn-secondary {
    background: var(--space-700);
    border-color: var(--space-400);
    color: var(--text-secondary);
}

.incident-btn-secondary:hover {
    background: var(--space-600);
    color: var(--text-primary);
}
