/* Core Variables & Design System */
:root {
    --bg-dark: #07070a;
    --bg-panel: rgba(18, 18, 26, 0.7);
    --border-glass: rgba(255, 255, 255, 0.08);
    
    --text-primary: #f0f0f5;
    --text-secondary: #9aa0b5;
    --text-muted: #5e6375;
    
    --accent-blue: #33b3ff;
    --accent-blue-glow: rgba(51, 179, 255, 0.3);
    
    --accent-violet: #ab7eff;
    --accent-violet-glow: rgba(171, 126, 255, 0.25);
    
    --accent-green: #24e381;
    --accent-green-glow: rgba(36, 227, 129, 0.25);
    
    --accent-red: #ff3b5c;
    --accent-red-glow: rgba(255, 59, 92, 0.25);
    
    --font-sans: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --shadow-premium: 0 12px 40px rgba(0, 0, 0, 0.6);
}

/* Reset & Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    position: relative;
    height: 100vh;
    width: 100vw;
    -webkit-font-smoothing: antialiased;
}

/* Elegant Animated Background */
.glass-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 10% 20%, rgba(33, 150, 243, 0.08) 0%, transparent 40%),
                radial-gradient(circle at 90% 80%, rgba(156, 39, 176, 0.08) 0%, transparent 40%),
                radial-gradient(circle at 50% 50%, rgba(7, 7, 10, 1) 0%, rgba(12, 12, 18, 1) 100%);
    z-index: -1;
}

/* Main Container Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 600px;
    margin: 0 auto;
    border-left: 1px solid var(--border-glass);
    border-right: 1px solid var(--border-glass);
    background: rgba(10, 10, 15, 0.4);
    backdrop-filter: blur(20px);
}

/* Header Component */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-glass);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #ffffff 30%, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: all 0.4s ease;
}

.status-indicator.idle {
    background-color: var(--text-muted);
    box-shadow: 0 0 8px var(--text-muted);
}

.status-indicator.listening {
    background-color: var(--accent-blue);
    box-shadow: 0 0 12px var(--accent-blue);
}

.status-indicator.processing {
    background-color: var(--accent-violet);
    box-shadow: 0 0 12px var(--accent-violet);
    animation: pulse-indicator 1.5s infinite;
}

.status-indicator.waiting {
    background-color: var(--accent-red);
    box-shadow: 0 0 12px var(--accent-red);
    animation: pulse-indicator 1s infinite;
}

@keyframes pulse-indicator {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Project Selector */
.project-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.project-selector-wrapper label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.project-dropdown {
    background: var(--bg-panel);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    padding: 0.4rem 1.5rem 0.4rem 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: var(--font-sans);
    cursor: pointer;
    outline: none;
    transition: border-color 0.3s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239aa0b5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 12px;
}

.project-dropdown:focus {
    border-color: var(--accent-blue);
}

/* Mic and Center Section */
.console-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    overflow-y: auto;
    gap: 1.5rem;
}

.mic-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 0;
    position: relative;
}

.pulse-ring {
    position: absolute;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 1px solid var(--accent-blue-glow);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s;
}

.mic-section.recording #pulse-ring-1 {
    animation: ring-pulse 2s infinite ease-out;
}

.mic-section.recording #pulse-ring-2 {
    animation: ring-pulse 2s infinite ease-out 1s;
}

@keyframes ring-pulse {
    0% {
        transform: scale(0.85);
        opacity: 0.8;
    }
    100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

.mic-button {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: radial-gradient(135deg, rgba(26, 26, 36, 0.95), rgba(18, 18, 26, 0.95));
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    z-index: 10;
    outline: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.mic-button::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-violet));
    z-index: -1;
    opacity: 0.15;
    transition: opacity 0.3s;
}

/* Hover & Active States */
.mic-button:hover {
    color: var(--text-primary);
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.15);
}

.mic-section.recording .mic-button {
    color: var(--accent-blue);
    border-color: var(--accent-blue);
    box-shadow: 0 0 35px var(--accent-blue-glow);
}

.mic-section.recording .mic-button::after {
    opacity: 0.6;
}

.mic-section.processing-mic .mic-button {
    color: var(--accent-violet);
    border-color: var(--accent-violet);
    box-shadow: 0 0 35px var(--accent-violet-glow);
    animation: pulse-mic-btn 1.5s infinite alternate;
}

@keyframes pulse-mic-btn {
    0% { transform: scale(1); }
    100% { transform: scale(1.04); }
}

.mic-icon {
    width: 36px;
    height: 36px;
    transition: transform 0.3s;
}

.mic-button:active {
    transform: scale(0.95);
}

.status-text-wrapper {
    margin-top: 1.5rem;
    text-align: center;
}

.status-text-wrapper h2 {
    font-size: 1.35rem;
    font-weight: 500;
    letter-spacing: -0.01em;
}

.status-text-wrapper p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Logs and Tabs Section */
.logs-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    min-height: 200px;
    overflow: hidden;
}

.tabs-header {
    display: flex;
    border-bottom: 1px solid var(--border-glass);
    background: rgba(0, 0, 0, 0.2);
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.85rem;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    outline: none;
    position: relative;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--text-primary);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-violet));
}

.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

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

/* Custom Scrollbars */
.tab-content::-webkit-scrollbar,
.diff-body::-webkit-scrollbar {
    width: 6px;
}

.tab-content::-webkit-scrollbar-thumb,
.diff-body::-webkit-scrollbar-thumb {
    background: var(--border-glass);
    border-radius: 3px;
}

/* Thoughts Styling */
.thoughts-box {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

.thought-line {
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    border-left: 3px solid var(--accent-violet);
}

.thought-line.system-thought {
    border-left-color: var(--text-muted);
    color: var(--text-secondary);
    font-style: italic;
    background: transparent;
}

.thought-line.agent-message {
    border-left-color: var(--accent-blue);
    background: rgba(51, 179, 255, 0.04);
}

/* Terminal Logs Styling */
.terminal-box {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.4;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.terminal-line {
    color: #a8b2c2;
    word-break: break-all;
}

.terminal-line.system-line {
    color: var(--text-secondary);
}

/* Collapsible Diff / Visual Review Section */
.diff-section {
    background: var(--bg-panel);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.diff-header-btn {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.15);
    border: none;
    color: var(--text-primary);
    padding: 1rem;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: background 0.3s;
}

.diff-header-btn:hover {
    background: rgba(255, 255, 255, 0.02);
}

.chevron-icon {
    width: 20px;
    height: 20px;
    transition: transform 0.3s;
}

.diff-section.collapsed .chevron-icon {
    transform: rotate(-90deg);
}

.diff-count-badge {
    background: var(--accent-blue);
    color: #ffffff;
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    font-weight: 600;
    margin-left: 0.5rem;
}

.diff-container-wrapper {
    display: flex;
    flex-direction: column;
    max-height: 350px;
    overflow: hidden;
    border-top: 1px solid var(--border-glass);
}

.diff-section.collapsed .diff-container-wrapper {
    display: none;
}

.diff-toolbar {
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: flex-end;
}

.action-btn-secondary {
    background: transparent;
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    padding: 0.3rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: all 0.3s;
}

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

.diff-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #0d0e12;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    white-space: pre-wrap;
}

.diff-placeholder {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 1.5rem 0;
}

/* Diff formatting */
.diff-added {
    color: #4dfa96;
    background: rgba(77, 250, 150, 0.05);
}

.diff-removed {
    color: #ff5572;
    background: rgba(255, 85, 114, 0.05);
}

.diff-header-line {
    color: var(--accent-blue);
    font-weight: 500;
}

/* Interception Approval Overlay & Card */
.approval-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(5, 5, 8, 0.85);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.approval-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.approval-card {
    background: #14141e;
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    width: 100%;
    max-width: 480px;
    padding: 1.5rem;
    box-shadow: var(--shadow-premium);
    transform: translateY(20px);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.approval-overlay.active .approval-card {
    transform: translateY(0);
}

.approval-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.warning-icon {
    width: 24px;
    height: 24px;
    color: var(--accent-red);
}

.approval-header h3 {
    font-size: 1.15rem;
    font-weight: 600;
}

.approval-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.spoken-prompt-preview {
    font-size: 0.95rem;
    line-height: 1.4;
    color: var(--text-primary);
    font-weight: 500;
}

.command-box {
    background: #09090d;
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    padding: 0.85rem;
    max-height: 150px;
    overflow-y: auto;
}

.command-box code {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: #a8b2c2;
    white-space: pre-wrap;
    word-break: break-all;
}

.feedback-input-wrapper input {
    width: 100%;
    background: #09090d;
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.3s;
}

.feedback-input-wrapper input:focus {
    border-color: var(--accent-blue);
}

.approval-actions {
    display: flex;
    gap: 1rem;
}

.action-btn {
    flex: 1;
    padding: 0.85rem;
    border-radius: 10px;
    border: none;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.reject-btn {
    background: var(--accent-red-glow);
    border: 1px solid var(--accent-red);
    color: #ffcbd3;
}

.reject-btn:hover {
    background: var(--accent-red);
    color: #ffffff;
    box-shadow: 0 0 15px var(--accent-red-glow);
}

.approve-btn {
    background: var(--accent-green-glow);
    border: 1px solid var(--accent-green);
    color: #ccffd8;
}

.approve-btn:hover {
    background: var(--accent-green);
    color: #ffffff;
    box-shadow: 0 0 15px var(--accent-green-glow);
}

.voice-help-text {
    margin-top: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}
