/* =========================================
   1. VARIABLES & THEME SETUP
   ========================================= */
:root {
    /* Core Colors */
    --editor-bg: #ffffff;
    --editor-bg-secondary: #f8fafc;
    --editor-border: #e2e8f0;
    --editor-text: #334155;
    --accent-color: #3b82f6; /* Blue */
    --accent-hover: #2563eb;
    
    /* Syntax Colors */
    --code-font: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
    --ui-font: 'Inter', system-ui, -apple-system, sans-serif;
    
    /* Dimensions */
    --app-height: 650px; /* Fixed height for the "IDE" feel */
    --toolbar-height: 60px;
}

/* Dark Mode Overrides */
[data-theme="dark"] {
    --editor-bg: #1e293b;
    --editor-bg-secondary: #0f172a;
    --editor-border: #334155;
    --editor-text: #e2e8f0;
    --accent-color: #60a5fa;
}

/* =========================================
   2. MAIN CONTAINER
   ========================================= */
.tool-container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1.5rem;
    font-family: var(--ui-font);
}

.tool-head-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.tool-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-header, #1e293b);
    display: inline-block;
    margin-right: 1rem;
}

.tool-badge {
    background: #ecfccb;
    color: #4d7c0f;
    padding: 0.2rem 0.6rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* =========================================
   3. APP CARD (The IDE Window)
   ========================================= */
.app-card {
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--editor-border);
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
    overflow: hidden; 
    display: flex;
    flex-direction: column;
    height: var(--app-height);
}

/* =========================================
   4. TOOLBAR
   ========================================= */
.toolbar {
    height: var(--toolbar-height);
    background: var(--editor-bg-secondary);
    border-bottom: 1px solid var(--editor-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    flex-shrink: 0; 
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Input Styles */
.input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted, #64748b);
}

/* FIXED INPUT STYLE: clearly editable now */
.stealth-input {
    background: var(--editor-bg); /* White background */
    border: 1px solid var(--editor-border); /* Visible border */
    border-radius: 6px;
    padding: 0.4rem 0.8rem;
    font-family: var(--code-font);
    font-size: 0.9rem;
    color: var(--accent-color); /* Keep the blue text */
    width: 160px;
    transition: all 0.2s ease;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05); /* Slight inner shadow */
}

.stealth-input:focus {
    outline: none;
    border-color: var(--accent-color); /* Blue border on focus */
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); /* Blue glow ring */
}

.input-wrapper:hover .stealth-input {
    border-color: #cbd5e1;
}

/* Toggle Pills (Checkboxes) */
.toggle-pill {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted, #64748b);
    user-select: none;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    transition: background 0.2s;
}

.toggle-pill:hover {
    background: rgba(0,0,0,0.05);
}

.toggle-pill input {
    accent-color: var(--accent-color);
    width: 14px;
    height: 14px;
}

/* Buttons */
.tool-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.tool-btn.secondary {
    background: transparent;
    color: var(--text-muted, #64748b);
    border-color: var(--editor-border);
}

.tool-btn.secondary:hover {
    background: var(--editor-bg);
    color: var(--editor-text);
}

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

.tool-btn.primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

/* Fix for "How it works" button */
.btn-text {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted, #64748b);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.btn-text:hover {
    background-color: var(--editor-bg-secondary);
    color: var(--accent-color);
    border-color: var(--editor-border);
}

/* =========================================
   5. WORKSPACE (Split View)
   ========================================= */
.workspace {
    flex: 1; /* Fills remaining height */
    display: flex;
    position: relative;
    overflow: hidden;
}

.pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevents flex items from overflowing */
    position: relative;
}

/* Input Area (Left) */
.input-pane {
    background: var(--editor-bg);
}

.code-editor {
    flex: 1;
    width: 100%;
    height: 100%;
    border: none;
    resize: none;
    padding: 1.5rem;
    font-family: var(--code-font);
    font-size: 14px;
    line-height: 1.6;
    color: var(--editor-text);
    background: transparent;
    outline: none;
}

/* Output Area (Right) */
.output-pane {
    background: #282c34; /* Always dark for code output contrast */
}

/* Override Prism/Pre styles to fit height and wrap text */
.code-editor-wrapper {
    flex: 1;
    overflow: auto;
    position: relative;
}

.output-pane pre {
    margin: 0 !important;
    padding: 1.5rem !important;
    height: 100%;
    background: transparent !important;
    border-radius: 0 !important;
    text-shadow: none !important;
    white-space: pre-wrap !important; /* Fix: Wrap long lines */
    word-break: break-all !important; /* Fix: Break long words if needed */
}

.output-pane code {
    font-family: var(--code-font) !important;
    font-size: 14px !important;
}

/* Divider Arrow */
.divider {
    width: 1px;
    background: var(--editor-border);
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.divider-icon {
    background: var(--editor-bg-secondary);
    border: 1px solid var(--editor-border);
    color: var(--text-muted);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    position: absolute;
}

/* =========================================
   6. UTILITIES & MODAL
   ========================================= */
.status-indicator {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    background: #fee2e2;
    color: #ef4444;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid #fecaca;
    animation: popIn 0.2s ease-out;
}

@keyframes popIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* FIXED MODAL POSITIONING */
dialog.info-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0; 
    border: none;
    border-radius: 16px;
    padding: 0;
    width: 90%;
    max-width: 480px;
    background: var(--bg-card, #fff);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    z-index: 1000;
    opacity: 0;
    animation: fadeIn 0.2s forwards;
}

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

dialog.info-modal::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.modal-box {
    padding: 2rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--editor-border);
    padding-bottom: 1rem;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--tool-text, #333);
}

.close-icon {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.2rem;
    border-radius: 4px;
}

.close-icon:hover {
    background: #fee2e2;
    color: #ef4444;
}

.modal-body ul {
    padding-left: 1.2rem;
    line-height: 1.8;
    color: var(--text-muted);
}

/* =========================================
   7. RESPONSIVE DESIGN
   ========================================= */
@media (max-width: 900px) {
    .app-card {
        height: auto; 
        min-height: 800px;
    }

    .toolbar {
        height: auto;
        flex-direction: column;
        padding: 1rem;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .toolbar-group {
        width: 100%;
        justify-content: space-between;
    }
    
    .toolbar-group.center {
        flex-wrap: wrap;
    }

    .workspace {
        flex-direction: column;
    }

    .pane {
        height: 400px; 
        flex: none;
    }

    .divider {
        width: 100%;
        height: 1px;
    }
    
    .divider-icon {
        transform: rotate(90deg);
    }
}