/* Online Assembler & Disassembler - Token Architecture & Systematic Design System */

:root {
    /* 1. PRIMITIVE TOKENS */
    --primitive-slate-50: #f8fafc;
    --primitive-slate-100: #f1f5f9;
    --primitive-slate-200: #e2e8f0;
    --primitive-slate-300: #cbd5e1;
    --primitive-slate-400: #94a3b8;
    --primitive-slate-500: #64748b;
    --primitive-slate-600: #475569;
    --primitive-slate-700: #334155;
    --primitive-slate-800: #1e293b;
    --primitive-slate-900: #0f172a;
    --primitive-slate-950: #090d16;

    --primitive-blue-500: #3b82f6;
    --primitive-blue-600: #2563eb;
    --primitive-blue-700: #1d4ed8;

    --primitive-purple-500: #a855f7;
    --primitive-purple-600: #9333ea;

    --primitive-emerald-500: #10b981;
    --primitive-emerald-600: #059669;

    --primitive-amber-500: #f59e0b;
    --primitive-red-500: #ef4444;

    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-code: 'Inconsolata', 'JetBrains Mono', 'Fira Code', monospace;

    /* 2. SEMANTIC TOKENS (Dark Theme Default) */
    --bg-app: var(--primitive-slate-950);
    --bg-surface: #111827;
    --bg-card: #131b2e;
    --bg-card-hover: #1c2942;
    --bg-input: #0b1120;
    --border-color: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(59, 130, 246, 0.4);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-primary: var(--primitive-blue-600);
    --accent-blue: var(--primitive-blue-500);
    --accent-purple: var(--primitive-purple-500);
    --accent-emerald: var(--primitive-emerald-500);
    --accent-amber: var(--primitive-amber-500);
    --accent-red: var(--primitive-red-500);

    --code-bg: #0b1120;
    --code-text: #f8fafc;
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.35);

    /* 3. COMPONENT METRICS (Strict Uniformity) */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;

    --header-btn-height: 38px;
    --editor-header-height: 48px;
    --editor-box-height: 300px;
    --action-btn-height: 48px;
    --action-btn-min-width: 220px;
}

/* Light Theme Overrides */
[data-theme="light"] {
    --bg-app: #f8fafc;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --bg-input: #f1f5f9;
    --border-color: #cbd5e1;
    --border-hover: #2563eb;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --accent-primary: var(--primitive-blue-600);
    --accent-blue: var(--primitive-blue-600);
    --accent-purple: var(--primitive-purple-600);
    --accent-emerald: var(--primitive-emerald-600);

    --code-bg: #f8fafc;
    --code-text: #0f172a;
    --shadow-card: 0 4px 15px rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --bg-app: #f8fafc;
        --bg-surface: #ffffff;
        --bg-card: #ffffff;
        --bg-card-hover: #f1f5f9;
        --bg-input: #f1f5f9;
        --border-color: #cbd5e1;
        --border-hover: #2563eb;

        --text-primary: #0f172a;
        --text-secondary: #475569;
        --text-muted: #94a3b8;

        --accent-primary: var(--primitive-blue-600);
        --accent-blue: var(--primitive-blue-600);
        --accent-purple: var(--primitive-purple-600);
        --accent-emerald: var(--primitive-emerald-600);

        --code-bg: #f8fafc;
        --code-text: #0f172a;
        --shadow-card: 0 4px 15px rgba(0, 0, 0, 0.05);
    }
}

body {
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font-ui);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    line-height: 1.5;
    transition: background-color 0.25s ease, color 0.25s ease;
}

/* Header Container & Badges Layout (Fixes Overlapping Badges Issue) */
.cyber-header {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 0;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-card);
}

.brand-title {
    font-weight: 800;
    font-size: 1.75rem;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
}

.brand-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.header-badges-group {
    display: flex;
    align-items: center;
    gap: 0.75rem; /* Proper spacing between badges */
    flex-wrap: wrap;
}

.engine-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: var(--header-btn-height);
    padding: 0 0.85rem;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: var(--font-code);
    background: rgba(37, 99, 235, 0.1);
    color: var(--accent-blue);
    border: 1px solid rgba(37, 99, 235, 0.3);
    white-space: nowrap;
    box-sizing: border-box;
}

.engine-badge.capstone {
    background: rgba(168, 85, 247, 0.1);
    color: var(--accent-purple);
    border-color: rgba(168, 85, 247, 0.3);
}

.theme-toggle-btn {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    height: var(--header-btn-height);
    padding: 0 1rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: all 0.2s ease;
    white-space: nowrap;
    box-sizing: border-box;
}

.theme-toggle-btn:hover {
    border-color: var(--accent-blue);
    background: var(--bg-card-hover);
}

/* View Navigation Tabs */
.view-tabs {
    display: flex;
    gap: 0.5rem;
    background-color: var(--bg-surface);
    padding: 0.35rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.view-tab-btn {
    flex: 1;
    min-width: 140px;
    text-align: center;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.view-tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-input);
}

.view-tab-btn.active {
    color: #ffffff;
    background-color: var(--accent-blue);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* Configuration Cards & Unified Grid */
.config-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-card);
}

.config-card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.config-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.config-col {
    flex: 1 1 180px;
    min-width: 150px;
}

@media (max-width: 576px) {
    .config-col {
        flex: 1 1 100%;
        min-width: 100%;
    }
}

.form-label-cyber {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    display: block;
}

.form-control-cyber {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: var(--font-code);
    font-size: 0.9rem;
    border-radius: var(--radius-md);
    padding: 0.55rem 0.85rem;
    width: 100%;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control-cyber:hover {
    border-color: var(--accent-blue);
}

.form-control-cyber:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

/* Editor Wrapper & Strict Header Height Uniformity (Fixes Unequal Cards) */
.editor-wrapper {
    position: relative;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-card);
}

.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--editor-header-height);
    min-height: var(--editor-header-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 0 1rem;
    box-sizing: border-box;
}

.editor-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.editor-arch-badge {
    font-size: 0.72rem;
    font-family: var(--font-code);
    padding: 0.15rem 0.5rem;
    background: rgba(37, 99, 235, 0.12);
    border: 1px solid rgba(37, 99, 235, 0.3);
    color: var(--accent-blue);
    border-radius: 0.35rem;
    font-weight: 700;
    white-space: nowrap;
}

.editor-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

.btn-icon-cyber {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.3rem 0.7rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn-icon-cyber:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--accent-blue);
}

#asm_editor, #disasm_editor {
    height: var(--editor-box-height);
    width: 100%;
    font-size: 15px;
    font-family: var(--font-code) !important;
}

@media (max-width: 768px) {
    #asm_editor, #disasm_editor {
        height: 240px;
    }
}

/* Action Trigger Buttons Container (Strict Uniformity) */
.btn-action-container {
    text-align: center;
    margin: 1.5rem 0 2rem 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.btn-cyber-primary {
    background-color: var(--accent-blue);
    color: #ffffff;
    font-weight: 700;
    font-size: 1rem;
    height: var(--action-btn-height);
    min-width: var(--action-btn-min-width);
    padding: 0 1.75rem;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    letter-spacing: 0.025em;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

@media (max-width: 576px) {
    .btn-cyber-primary {
        width: 100%;
        min-width: 100%;
    }
}

.btn-cyber-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45);
    background-color: var(--primitive-blue-700);
}

.btn-cyber-primary:active {
    transform: translateY(1px);
}

.shortcut-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

kbd {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    color: var(--accent-blue);
    display: inline-block;
    font-family: var(--font-code);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    padding: 0.2rem 0.4rem;
}

/* Stats Banner & Shellcode Auditor */
.stats-banner {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 0.85rem 1.25rem;
    margin-bottom: 1.25rem;
    align-items: center;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
}

.stat-value {
    font-family: var(--font-code);
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-blue);
}

.shellcode-badge {
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 700;
}

.shellcode-badge.safe {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.shellcode-badge.warn {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-amber);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Export Cards System */
.export-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.export-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 0.55rem 1rem;
}

.export-card-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
}

.export-card-body {
    padding: 1rem;
    font-family: var(--font-code);
    font-size: 0.9rem;
    color: var(--code-text);
    word-break: break-all;
    white-space: pre-wrap;
    background: var(--code-bg);
    margin: 0;
}

.hex-zero {
    color: var(--accent-red);
    font-weight: 800;
    background: rgba(239, 68, 68, 0.15);
    padding: 0.05rem 0.25rem;
    border-radius: 0.2rem;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.hex-byte {
    color: var(--accent-blue);
    margin-right: 0.35rem;
}

/* Disassembly View Table - Responsive Scroll Container */
.disasm-table-wrapper {
    overflow-x: auto;
    width: 100%;
}

.disasm-output-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-code);
    font-size: 0.9rem;
}

.disasm-output-table th {
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-weight: 600;
    text-align: left;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8rem;
    text-transform: uppercase;
}

.disasm-output-table td {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.disasm-output-table tr:hover td {
    background: var(--bg-card-hover);
}

.disasm-addr {
    color: var(--accent-blue);
    font-weight: 600;
}

.disasm-bytes {
    color: var(--accent-purple);
}

.disasm-inst {
    color: var(--accent-emerald);
    font-weight: 600;
}

/* Toast Notifications */
#toast_notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--accent-blue);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 9999;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    pointer-events: none;
}

#toast_notification.show {
    opacity: 1;
    transform: translateY(0);
}

/* Alert Styling */
.alert-cyber-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--accent-red);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    font-family: var(--font-code);
    font-size: 0.9rem;
}