:root {
    --primary: #CC0000;         /* YouTube Red */
    --primary-dark: #990000;
    --accent: #065FD4;          /* YouTube Blue */
    --bg-app: #F1F1F1;
    --bg-panel: #FFFFFF;
    --text-main: #0F0F0F;
    --text-muted: #606060;
    --border: #E0E0E0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --terminal-bg: #1E1E1E;
    --terminal-text: #00FF9C;
    --anim-speed: 0.3s;
}

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

body {
    font-family: 'Roboto', sans-serif;
    background: var(--bg-app);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* App-like behavior */
}

/* === HEADER === */
.app-header {
    height: 60px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    z-index: 100;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-text { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.5px; }
.highlight { color: var(--text-muted); font-weight: 400; }

.status-badge {
    background: #f0f0f0;
    padding: 6px 12px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    border: 1px solid #ddd;
    transition: all 0.3s ease;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
}

.status-badge.processing {
    background: #E8F5E9;
    color: #2E7D32;
    border-color: #C8E6C9;
}

.status-badge.processing .pulse-dot {
    background: #4CAF50;
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
    animation: pulse-green 1.5s infinite;
}

@keyframes pulse-green {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(76, 175, 80, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(76, 175, 80, 0); }
}

/* === LAYOUT === */
.app-container {
    display: flex;
    flex: 1;
    height: calc(100vh - 60px);
}

.workspace {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    justify-content: center;
}

.workspace-inner {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.sidebar {
    width: 400px;
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 10px rgba(0,0,0,0.02);
}

@media (max-width: 1000px) {
    .app-container { flex-direction: column; overflow-y: auto; }
    .sidebar { width: 100%; height: 500px; border-left: none; border-top: 1px solid var(--border); }
    .workspace { height: auto; }
}

/* === PANELS === */
.panel {
    background: var(--bg-panel);
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.panel:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.panel-header {
    padding: 16px 24px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.panel-header h2, .panel-header h3 { font-size: 1rem; font-weight: 600; color: var(--text-main); display: flex; align-items: center; gap: 10px; }

.panel-body { padding: 24px; }

/* === CONTROLS === */
.form-group { margin-bottom: 24px; }
.form-group label { display: block; font-size: 0.9rem; font-weight: 500; margin-bottom: 8px; color: var(--text-muted); }

.input-wrapper { position: relative; }
input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
    background: #fafafa;
    transition: all 0.2s;
}
input[type="text"]:focus { outline: none; background: #fff; border-color: var(--accent); }

/* SLIDER */
.slider-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.value-tag { background: var(--bg-app); padding: 2px 8px; border-radius: 4px; font-weight: 700; font-size: 0.9rem; color: var(--primary); }

input[type=range] {
    width: 100%;
    -webkit-appearance: none;
    height: 6px;
    background: #e0e0e0;
    border-radius: 5px;
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.1s;
}
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.1); }

.preset-chips { display: flex; gap: 10px; margin-top: 15px; }
.chip {
    padding: 6px 14px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 16px;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}
.chip:hover { background: #f5f5f5; }
.chip.active { background: #e3f2fd; color: var(--accent); border-color: #90caf9; }

.action-buttons { display: flex; gap: 15px; margin-top: 10px; }
.btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: white; box-shadow: 0 4px 6px rgba(204,0,0,0.2); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-1px); }
.btn-danger { background: white; border: 1px solid #ffcdd2; color: #d32f2f; }
.btn:disabled { background: #e0e0e0; color: #9e9e9e; cursor: not-allowed; box-shadow: none; border-color: transparent; }

/* === TERMINAL === */
.terminal-panel { display: flex; flex-direction: column; flex: 1; min-height: 300px; }
.terminal-header { background: #2b2b2b; border-bottom: none; }
.terminal-header h3 { color: #fff; }
.traffic-lights span { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #555; margin-left: 6px; }
.traffic-lights span:nth-child(1) { background: #FF5F56; }
.traffic-lights span:nth-child(2) { background: #FFBD2E; }
.traffic-lights span:nth-child(3) { background: #27C93F; }

.terminal-window {
    background: var(--terminal-bg);
    padding: 20px;
    flex: 1;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    overflow-y: auto;
    color: #eee;
}
.log-line { margin-bottom: 6px; word-wrap: break-word; line-height: 1.5; border-left: 2px solid transparent; padding-left: 10px; }
.log-line.system { color: #666; }
.log-line.info { border-left-color: var(--accent); color: #fff; }
.log-line.success { border-left-color: #27C93F; color: #27C93F; }
.log-line.error { border-left-color: #FF5F56; color: #FF5F56; background: rgba(255, 95, 86, 0.1); }

/* === CHAT === */
.chat-interface { display: flex; flex-direction: column; height: 100%; background: #fff; }
.chat-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.online-status { font-size: 0.75rem; color: #27C93F; display: flex; align-items: center; gap: 4px; }
.online-status::before { content: ''; display: block; width: 6px; height: 6px; background: #27C93F; border-radius: 50%; }

.chat-messages-area {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f9f9f9;
}

.message { display: flex; gap: 12px; margin-bottom: 16px; animation: slideUp 0.3s ease forwards; }
.message.user { flex-direction: row-reverse; }

.message .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.message .avatar svg { width: 18px; height: 18px; }
.message.user .avatar { background: var(--accent); }

.message .bubble {
    background: white;
    padding: 12px 16px;
    border-radius: 0 12px 12px 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-main);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    max-width: 85%;
}
.message.user .bubble {
    background: #E3F2FD;
    border-radius: 12px 0 12px 12px;
    color: #0D47A1;
}

.chat-input-area {
    padding: 16px;
    border-top: 1px solid var(--border);
    background: white;
}
.input-box {
    display: flex;
    align-items: center;
    background: #f0f0f0;
    border-radius: 24px;
    padding: 6px 6px 6px 20px;
    border: 1px solid transparent;
    transition: all 0.2s;
}
.input-box:focus-within { background: white; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(6, 95, 212, 0.1); }
.input-box input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.95rem;
    color: var(--text-main);
}
.input-box button {
    background: var(--accent);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}
.input-box button:hover:not(:disabled) { transform: scale(1.1); background: #0056b3; }
.input-box button:disabled { background: #ccc; cursor: default; }

/* === UTILS & ANIMATION === */
.animate-entry { opacity: 0; animation: fadeInUp 0.5s ease forwards; animation-delay: var(--delay, 0s); }

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

@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #bbb; }

/* === NEW: INFO BOX (Chunk Size) === */
.info-box {
    margin-top: 15px;
    background: #EBF5FF; /* Light Blue BG */
    border: 1px solid #D1E9FF;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    gap: 12px;
    font-size: 0.85rem;
    color: #444;
}

.info-icon { font-size: 1.2rem; }
.info-content ul { margin: 4px 0 0 20px; padding: 0; }
.info-content li { margin-bottom: 2px; }
.highlight-txt { color: #0056b3; font-weight: 600; }

/* === NEW: VIDEO PLAYER CARD === */
.video-preview-card {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    padding: 0;
}

.video-frame {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
    background: #000;
}

.video-frame iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    display: none; /* Hidden until loaded */
}

/* Placeholder State */
.video-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    color: #888;
    z-index: 1;
}

.ph-icon { font-size: 32px; margin-bottom: 8px; opacity: 0.5; }

/* Video Metadata */
.video-meta {
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.badge-live {
    background: #cc0000;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 6px;
    border-radius: 3px;
    letter-spacing: 0.5px;
}

/* Adjust Sidebar to accommodate video player */
/* === FIXED SIDEBAR LAYOUT (Prevents Overflow) === */

.sidebar {
    background: #fff;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column; /* Stack Video on top of Chat */
    height: 100%;           /* Force full height of parent */
    overflow: hidden;       /* specific: Cut off anything that sticks out */
}

/* 1. Video Card: Don't grow, don't shrink, just fit content */
.video-preview-card {
    flex: 0 0 auto;
    width: 100%;
    z-index: 10; /* Keep above chat */
}

/* 2. Chat Interface: Fill EXACTLY the remaining space */
.chat-interface {
    display: flex;
    flex-direction: column;
    flex: 1;            /* Grow to fill remaining space */
    min-height: 0;      /* CRITICAL: Allows scrollbar to work inside flex item */
    height: auto;       /* Reset any fixed height */
    overflow: hidden;
}

/* 3. Messages Area: Scrollable middle section */
.chat-messages-area {
    flex: 1;            /* Grow to push input to bottom */
    overflow-y: auto;   /* Scroll ONLY this area */
    padding: 20px;
    background: #f9f9f9;
}

/* 4. Input Area: Fixed at bottom */
.chat-input-area {
    flex: 0 0 auto;     /* Fixed height */
    padding: 16px;
    background: white;
    border-top: 1px solid var(--border);
    z-index: 20;
}

/* Add this to style.css to make extraction logs light green */
.log-line.info .log-msg {
    color: #98C379; /* Professional Light Green */
    font-weight: 500;
}