/* RegEngine theme (matches landing) */
:root {
    --bg: #0a0a0c;
    --bg-card: #111113;
    --text: #fafafa;
    --text-muted: #a1a1aa;
    --accent: #ea580c;
    --accent-light: #f97316;
    --accent-glow: rgba(249, 115, 22, 0.25);
    --border: #27272a;
    --success: #22c55e;
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
}

.demo-wrap {
    position: relative;
    z-index: 1;
    padding-bottom: 20px;
}

.demo-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.demo-nav-logo {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--text);
    text-decoration: none;
}

.demo-nav-logo span {
    color: var(--accent-light);
}

.demo-nav-right {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-muted);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.demo-header {
    padding: 16px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
}

.logo h1 {
    font-size: 20px;
    margin-bottom: 4px;
    color: var(--text);
}

.logo p {
    font-size: 13px;
    color: var(--text-muted);
}

.status-bar {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 14px;
    flex-wrap: wrap;
}

.enforcement-mode-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.enforcement-mode-selector label {
    font-weight: 500;
    white-space: nowrap;
    color: var(--text-muted);
}

.enforcement-select {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
    min-width: 120px;
}

.enforcement-select:hover {
    border-color: var(--accent-light);
}

.enforcement-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.enforcement-select option {
    background: var(--bg-card);
    color: var(--text);
}

.enforcement-description {
    background: var(--bg-card);
    color: var(--text-muted);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.5;
    max-width: 500px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse 2s infinite;
}

#statusText {
    color: var(--text-muted);
}

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

/* Scenario section */
.scenario-section {
    padding: 20px 0;
    margin-bottom: 8px;
}

.scenario-heading {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-light);
    margin-bottom: 14px;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.scenario-heading::before {
    content: '// ';
    opacity: 0.8;
}

.scenario-cards {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.scenario-card {
    flex: 1;
    min-width: 200px;
    max-width: 320px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.scenario-card:hover {
    border-color: var(--accent-light);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.scenario-card.selected {
    border-color: var(--accent);
    background: rgba(249, 115, 22, 0.08);
    box-shadow: 0 0 0 1px var(--accent);
}

.scenario-card-coming {
    cursor: default;
    opacity: 0.6;
}

.scenario-card-coming:hover {
    border-color: var(--border);
    box-shadow: none;
}

.scenario-icon {
    font-size: 24px;
}

.scenario-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.scenario-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
}

.scenario-instructions {
    margin-top: 18px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    border-left: 4px solid var(--accent);
}

.scenario-instructions h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 10px;
}

.scenario-instructions ol,
.scenario-instructions p {
    margin: 0;
    padding-left: 0;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.7;
}

.scenario-instructions li {
    margin-bottom: 6px;
    padding-left: 20px;
}

.demo-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 20px 0;
    height: 500px;
    max-height: 500px;
}

.code-editor-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 500px;
    max-height: 500px;
}

.editor-header {
    background: rgba(0,0,0,0.2);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.file-name {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font-mono);
}

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

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-sans);
}

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

.btn-primary:hover {
    background: var(--accent-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-success {
    background: var(--accent);
    color: white;
}

.btn-success:hover {
    background: var(--accent-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px var(--accent-glow);
}

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

.realtime-badge {
    background: rgba(249, 115, 22, 0.2);
    color: var(--accent-light);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(249, 115, 22, 0.4);
}

.editor-container {
    display: flex;
    flex: 1;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

.editor-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.diff-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}


.diff-highlight {
    border-left: 3px solid;
    opacity: 0.3;
}

.diff-highlight.diff-added {
    background: rgba(46, 160, 67, 0.15);
    border-left-color: #4ec9b0;
}

.diff-highlight.diff-modified {
    background: rgba(255, 193, 7, 0.15);
    border-left-color: #ffc107;
}

.diff-highlight.diff-removed {
    background: rgba(244, 67, 54, 0.15);
    border-left-color: #f48771;
}

.line-numbers {
    background: rgba(0,0,0,0.2);
    color: var(--text-muted);
    padding: 16px 8px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.6;
    text-align: right;
    user-select: none;
    min-width: 50px;
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.line-numbers::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.line-number {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    padding-right: 4px;
}

.diff-indicator {
    font-weight: bold;
    font-size: 12px;
    width: 12px;
    text-align: center;
    flex-shrink: 0;
}

.line-num {
    min-width: 30px;
    text-align: right;
}

.line-added {
    background: rgba(46, 160, 67, 0.2);
    color: #4ec9b0;
}

.line-added .diff-indicator {
    color: #4ec9b0;
}

.line-removed {
    background: rgba(244, 67, 54, 0.2);
    color: #f48771;
    text-decoration: line-through;
    opacity: 0.7;
}

.line-removed .diff-indicator {
    color: #f48771;
}

.line-modified {
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
}

.line-modified .diff-indicator {
    color: #ffc107;
}

.line-modified-new {
    background: rgba(46, 160, 67, 0.15);
}

.line-unchanged {
    color: #858585;
}

.line-unchanged .diff-indicator {
    color: #858585;
}

.code-editor {
    flex: 1;
    background: var(--bg-card);
    color: var(--text);
    border: none;
    padding: 16px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    outline: none;
    tab-size: 2;
    transition: opacity 0.2s;
    overflow-y: auto;
    overflow-x: auto;
    min-height: 0;
    white-space: pre;
    word-wrap: normal;
    overflow-wrap: normal;
}

.code-editor:disabled {
    opacity: 0.8;
    cursor: wait;
}

.line-highlight {
    animation: highlightPulse 1.5s ease-out;
}

@keyframes highlightPulse {
    0% {
        opacity: 0;
        transform: scaleX(0);
    }
    50% {
        opacity: 1;
        transform: scaleX(1);
    }
    100% {
        opacity: 0;
        transform: scaleX(1);
    }
}

.code-editor::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.results-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    height: 500px;
    max-height: 500px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border);
}

.results-header h3 {
    color: var(--text);
    font-size: 18px;
}

.btn-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.btn-close:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text);
}

.compliance-status {
    margin-bottom: 20px;
    padding: 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 16px;
}

.compliance-status[style*="display: none"] {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
}

.compliance-status.compliant {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
}

.compliance-status.non-compliant {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

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

.violations-section > div[style*="28a745"] {
    color: var(--success) !important;
}

.violations-section h4 {
    color: var(--text) !important;
}

.violation-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left-width: 4px;
    border-left-color: #dc3545;
    padding: 16px;
    margin-bottom: 12px;
    border-radius: 6px;
    transition: all 0.2s;
    display: block;
    visibility: visible;
    width: 100%;
}

/* Risk level border colors */
.violation-item.risk-critical {
    border-left-color: #dc2626;
}

.violation-item.risk-high {
    border-left-color: #ea580c;
}

.violation-item.risk-medium {
    border-left-color: #d97706;
}

.violation-item.risk-low {
    border-left-color: #2563eb;
}

/* Risk badge styling */
.risk-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: white;
    white-space: nowrap;
    flex-shrink: 0;
}

.risk-badge.risk-critical {
    background: #dc2626;
}

.risk-badge.risk-high {
    background: #ea580c;
}

.risk-badge.risk-medium {
    background: #d97706;
}

.risk-badge.risk-low {
    background: #2563eb;
}

.violation-item:hover {
    border-color: var(--accent-light);
    box-shadow: 0 0 0 1px var(--accent-glow);
}

.violation-item h4 {
    color: #fca5a5;
    margin-bottom: 8px;
    font-size: 16px;
}

.violation-item .rule-id {
    font-family: var(--font-mono);
    background: rgba(0,0,0,0.3);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    display: inline-block;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.violation-item .regulation {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 8px;
}

.violation-item .message {
    color: var(--text);
    line-height: 1.6;
}

.violation-item.fixed {
    border-left-color: var(--success);
    background: rgba(34, 197, 94, 0.08);
}

.violation-actions {
    margin-top: 12px;
}

.btn-fix-violation {
    background: var(--accent);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-fix-violation:hover {
    background: var(--accent-light);
    transform: translateY(-1px);
    box-shadow: 0 2px 10px var(--accent-glow);
}

.btn-fix-violation:disabled {
    opacity: 0.6;
    cursor: wait;
}

.fixed-badge {
    background: var(--success);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    display: inline-block;
}

.explanation-section {
    background: rgba(0,0,0,0.2);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.explanation-section h4 {
    color: var(--text);
    margin-bottom: 12px;
    font-size: 16px;
}

.explanation-section p {
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 12px;
}

.explanation-section code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--accent-light);
}

.resolved-section {
    background: rgba(34, 197, 94, 0.08);
    border-radius: 10px;
    padding: 20px 30px;
    border: 1px solid rgba(34, 197, 94, 0.3);
    margin-top: 40px;
    margin-bottom: 20px;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 1 !important;
}

.resolved-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(34, 197, 94, 0.3);
}

.resolved-header h3 {
    color: var(--success);
    font-size: 18px;
    margin: 0;
}

.resolved-hint {
    color: var(--text-muted);
    font-size: 13px;
    margin: 6px 0 0 0;
}

/* Audit trail modal */
.audit-trail-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.audit-trail-modal[aria-hidden="false"] {
    display: flex;
}

.audit-trail-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
}

.audit-trail-modal-content {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    max-width: 520px;
    width: 100%;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.audit-trail-modal-header h2 {
    margin: 0;
    font-size: 18px;
    color: var(--text);
}

.audit-trail-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
}

.audit-trail-modal-close:hover {
    color: var(--text);
}

.audit-trail-modal-body {
    padding: 20px;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
}

.audit-trail-row {
    margin-bottom: 14px;
}

.audit-trail-row:last-child {
    margin-bottom: 0;
}

.audit-trail-label {
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.audit-trail-value {
    color: var(--text);
    padding: 8px 12px;
    background: var(--bg);
    border-radius: 6px;
    border-left: 3px solid var(--success);
}

.audit-trail-value.rule-id {
    font-family: monospace;
    font-size: 13px;
}

.audit-trail-diff {
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.5;
    max-height: 240px;
    overflow-y: auto;
    border-radius: 6px;
    border: 1px solid var(--border);
    padding: 10px;
    background: var(--bg);
}

.audit-diff-line {
    white-space: pre;
    padding: 2px 8px;
    margin: 2px 0;
    border-radius: 4px;
}

.audit-diff-num {
    display: inline-block;
    min-width: 2em;
    color: var(--text-muted);
    margin-right: 8px;
}

.audit-diff-removed {
    background: #fee2e2;
    border-left: 3px solid #dc2626;
    color: #991b1b;
}

.audit-diff-added {
    background: #dcfce7;
    border-left: 3px solid #16a34a;
    color: #166534;
}

.audit-diff-modified,
.audit-diff-modified-to {
    padding: 2px 8px;
    margin: 2px 0;
    border-radius: 4px;
}

.audit-diff-old {
    background: #fee2e2;
    color: #991b1b;
    padding: 0 4px;
}

.audit-diff-new {
    background: #dcfce7;
    color: #166534;
    padding: 0 4px;
}

.audit-diff-modified-to {
    margin-top: 0;
    margin-bottom: 8px;
}

.resolved-violations {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    min-height: 100px;
    visibility: visible !important;
}

.resolved-violations .violation-item {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    cursor: pointer;
}

.resolved-violations .violation-item:hover {
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.2) !important;
}

.resolved-violations:empty::after {
    content: "No violations resolved yet. Fix violations to see them here.";
    color: var(--text-muted);
    font-style: italic;
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    display: block;
}

.violation-item.resolved {
    background: rgba(34, 197, 94, 0.08) !important;
    border-left: 4px solid var(--success) !important;
    opacity: 1 !important;
    margin: 0 !important;
    display: block !important;
    visibility: visible !important;
    position: relative !important;
    width: 100% !important;
    min-height: 100px !important;
    /* Keep same structure as violation card */
    padding: 16px !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

.violation-item.resolved h4 {
    color: var(--success) !important;
    margin-bottom: 8px;
    font-size: 16px;
}

.violation-item.resolved .rule-id {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
    font-family: monospace;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    display: inline-block;
    margin-bottom: 8px;
}

.violation-item.resolved .regulation {
    color: var(--success);
    font-size: 14px;
    margin-bottom: 8px;
}

.violation-item.resolved .message {
    color: var(--text-muted);
    line-height: 1.6;
}

.info-panel {
    background: var(--bg-card);
    padding: 20px 30px;
    border-top: 1px solid var(--border);
}

.info-panel h3 {
    color: var(--text);
    margin-bottom: 15px;
    font-size: 18px;
}

.info-panel ol {
    color: var(--text-muted);
    line-height: 1.8;
    padding-left: 20px;
}

.info-panel li {
    margin-bottom: 8px;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.spinner {
    border: 3px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (max-width: 1024px) {
    .demo-panel {
        grid-template-columns: 1fr;
    }
}
