:root { --primary: #9146ff; --primary-hover: #772ce8; --bg: #121212; --card-bg: #1e1e1e; --text: #ffffff; --text-dim: #aaa; --success: #00c853; --error: #ff4d4d; --border: #333; }
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: var(--bg); color: var(--text); margin: 0; display: flex; height: 100vh; overflow: hidden; }
* { box-sizing: border-box; }

/* Connection Status Indicator */
#connection-status { position: fixed; top: 10px; right: 10px; font-size: 0.7rem; padding: 2px 8px; border-radius: 10px; z-index: 1000; transition: 0.3s; opacity: 0.6; }
.status-online { background: var(--success); color: white; }
.status-offline { background: var(--error); color: white; }

/* Sidebar */
.sidebar { width: 260px; background: #0a0a0a; display: flex; flex-direction: column; padding: 20px; border-right: 1px solid var(--border); transition: width 0.3s ease; position: relative; }
.sidebar.collapsed { width: 80px; padding: 20px 10px; }
.sidebar.collapsed h1 { display: none; }
.sidebar.collapsed .nav-item span { display: none; }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 30px; }
.sidebar h1 { font-size: 1.5rem; margin: 0; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.sidebar-toggle { background: none; color: var(--text-dim); border: 1px solid var(--border); border-radius: 4px; cursor: pointer; padding: 4px 8px; font-size: 0.8rem; transition: 0.2s; }
.sidebar-toggle:hover { color: white; border-color: var(--primary); }
.nav-item { padding: 12px 15px; margin: 5px 0; cursor: pointer; border-radius: 6px; transition: 0.2s; color: var(--text-dim); text-decoration: none; display: flex; align-items: center; gap: 12px; font-weight: 500; position: relative; }
.nav-item:hover { background: #222; color: white; }
.nav-item.active { background: var(--primary); color: white; }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: white; }
.logout-btn { margin-top: auto; color: var(--error); text-align: center; display: flex; align-items: center; gap: 12px; justify-content: center; }

.nav-submenu { margin-left: 20px; display: none; flex-direction: column; gap: 5px; padding-left: 10px; border-left: 1px solid var(--border); }
.nav-submenu.active { display: flex; }
.submenu-item { padding: 8px 15px; font-size: 0.85rem; color: var(--text-dim); text-decoration: none; border-radius: 4px; transition: 0.2s; display: flex; align-items: center; gap: 10px; }
.submenu-item:hover { color: white; background: #222; }
.submenu-item.active { color: white; font-weight: bold; background: rgba(145, 70, 255, 0.1); }

.fav-dropdown-container { position: relative; display: inline-block; }
.fav-dropdown { 
    display: none; 
    position: absolute; 
    top: 100%; 
    left: 0; 
    background: #1e1e1e; 
    border: 1px solid var(--border); 
    border-radius: 6px; 
    z-index: 1000; 
    width: 200px; 
    max-height: 300px; 
    overflow-y: auto; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.5); 
}
.fav-dropdown.active { display: block; }
.fav-dropdown-item { 
    padding: 10px; 
    cursor: pointer; 
    color: var(--text-dim); 
    transition: 0.2s; 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    font-size: 0.9rem; 
    border-bottom: 1px solid var(--border); 
}
.fav-dropdown-item:hover { background: #333; color: white; }
.fav-dropdown-item img { width: 24px; height: 24px; border-radius: 50%; }

.fav-automation-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); 
    gap: 12px; 
    margin-bottom: 25px; 
}
.fav-mini-card { 
    background: var(--card-bg); 
    padding: 12px 15px; 
    border-radius: 8px; 
    border: 1px solid var(--border); 
    display: flex; 
    align-items: center; 
    gap: 12px; 
    cursor: pointer; 
    transition: 0.2s; 
}
.fav-mini-card:hover { background: #2a2a2a; border-color: var(--primary); transform: translateY(-2px); }
.fav-mini-card img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; border: 2px solid transparent; transition: 0.2s; }
.fav-mini-card:hover img { border-color: var(--primary); }
.fav-mini-card span { font-size: 0.85rem; font-weight: 500; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; }
.fav-mini-card:hover span { color: white; }

.fav-card { 
    background: var(--card-bg); 
    padding: 20px; 
    border-radius: 12px; 
    border: 1px solid var(--border); 
    display: flex; 
    align-items: flex-start; 
    gap: 20px; 
    cursor: pointer; 
    transition: 0.2s; 
    position: relative;
}
.fav-card:hover { background: #2a2a2a; border-color: var(--primary); transform: translateY(-2px); }
.fav-card img { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }
.fav-card-info { flex: 1; display: flex; flex-direction: column; gap: 5px; padding-right: 30px; }
.fav-card-name { font-weight: bold; font-size: 1.2rem; color: white; }
.fav-card-description { 
    font-size: 0.85rem; 
    color: var(--text-dim); 
    margin: 0; 
    line-height: 1.4; 
    display: -webkit-box; 
    -webkit-line-clamp: 3; 
    -webkit-box-orient: vertical; 
    overflow: hidden; 
    text-overflow: ellipsis;
}
.fav-card-link { 
    font-size: 0.85rem; 
    color: #bbb; 
    text-decoration: none; 
    margin-top: 8px; 
    display: inline-flex; 
    align-items: center; 
    gap: 5px;
    font-weight: 500;
    transition: 0.2s;
}
.fav-card-link:hover { 
    color: var(--primary);
    text-decoration: underline; 
}
.fav-card-remove { 
    position: absolute; 
    top: 10px; 
    right: 10px; 
    background: rgba(0,0,0,0.3); 
    border: none; 
    color: var(--text-dim); 
    cursor: pointer; 
    font-size: 1rem; 
    transition: 0.2s; 
    padding: 4px 8px; 
    border-radius: 4px;
}
.fav-card-remove:hover { color: var(--error); background: rgba(255,0,0,0.1); }

/* Main Content */
.main-content { flex: 1; display: flex; flex-direction: column; overflow-y: auto; padding: 0 40px 40px 40px; position: relative; text-align: left; box-sizing: border-box; width: 100%; }
.sticky-header { position: sticky; top: 0; z-index: 100; background: var(--bg); padding: 40px 0 20px 0; margin-bottom: 20px; text-align: left; }
.tab-content { display: none; text-align: left; width: 100%; }
.tab-content.active { display: block; }

/* Components */
.search-section { 
    display: flex; 
    gap: 10px; 
    margin-bottom: 30px; 
    justify-content: flex-start;
    width: 100%;
}
input { padding: 12px; border-radius: 6px; border: 1px solid #444; background: #333; color: white; flex-grow: 1; font-size: 1rem; }
button { padding: 10px 20px; background: var(--primary); color: white; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; transition: 0.2s; }
button:hover { background: var(--primary-hover); }

.channel-card { 
    background: var(--card-bg); 
    padding: 20px; 
    border-radius: 8px; 
    border: 1px solid var(--border); 
    display: flex; 
    align-items: center; 
    gap: 20px; 
    margin-bottom: 30px; 
    position: relative; 
}
.channel-card img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; }
.channel-card h2 { margin: 0; font-size: 1.5rem; }
.video-card { background: var(--card-bg); border-radius: 8px; overflow: hidden; border: 1px solid var(--border); transition: 0.2s ease; position: relative; box-shadow: 0 2px 4px rgba(0,0,0,0.3); }
.video-card:hover { transform: translateY(-4px); border-color: var(--primary); box-shadow: 0 8px 16px rgba(0,0,0,0.5); }
.video-card img { width: 100%; height: 160px; object-fit: cover; }
.duration-badge { position: absolute; bottom: 165px; right: 10px; background: rgba(0,0,0,0.8); color: white; padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; font-weight: bold; }
.video-card-body { padding: 15px; }
.video-card-body h3 { margin: 0 0 10px 0; font-size: 1rem; line-height: 1.4; }
.video-card-body p { font-size: 0.85rem; color: var(--text-dim); margin-bottom: 15px; }

/* Preview Modal */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); z-index: 2000; align-items: center; justify-content: center; }
.modal.active { display: flex; }
.modal-content { 
    background: var(--card-bg); 
    padding: 20px; 
    border-radius: 8px; 
    width: 90%; 
    max-width: 1000px; 
    position: relative; 
    border: 1px solid var(--border); 
    display: flex; 
    flex-direction: column; 
    max-height: 95vh; 
    overflow-y: auto;
}
.modal-close { position: absolute; top: -40px; right: 0; color: white; font-size: 2rem; cursor: pointer; background: none; border: none; }
.preview-container { 
    position: relative; 
    width: 100%;
    aspect-ratio: 16 / 9; 
    overflow: hidden; 
    background: #000;
}
.preview-container iframe, .preview-container video { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    border: none; 
}

/* Log Viewer Styles */
.log-container { 
    background: #000; 
    color: #0f0; 
    padding: 15px; 
    border-radius: 4px; 
    flex: 1; 
    overflow-y: auto; 
    font-family: 'Consolas', 'Monaco', monospace; 
    font-size: 0.85rem; 
    line-height: 1.4; 
    white-space: pre-wrap; 
    border: 1px solid #333;
}
.log-command { color: #fff; font-weight: bold; background: #222; display: block; padding: 2px 5px; border-radius: 2px; margin-bottom: 5px; border-left: 3px solid var(--primary); }
.log-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }

.metrics-container { display: flex; gap: 15px; align-items: center; font-size: 0.75rem; color: var(--text-dim); }
.metric-box { display: flex; flex-direction: column; gap: 3px; width: 80px; }
.metric-bar-bg { background: #333; height: 4px; border-radius: 2px; overflow: hidden; }
.metric-bar-fill { height: 100%; width: 0%; transition: width 0.5s ease, background 0.5s ease; }

.badge { padding: 2px 6px; border-radius: 4px; font-size: 0.7rem; font-weight: bold; text-transform: uppercase; vertical-align: middle; margin-left: 5px; }
.badge-hw { background: var(--success); color: white; }
.badge-sw { background: #555; color: white; }
.badge-live { background: var(--error); color: white; animation: pulse 1.5s infinite; }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }

.fav-btn { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,0.6); border: none; color: white; cursor: pointer; border-radius: 50%; width: 35px; height: 35px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; transition: 0.2s; }
.fav-btn.active { color: #ff4d4d; }
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; margin-top: 20px; }

.task-list { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.task-item { background: var(--card-bg); padding: 12px 20px; border-radius: 6px; border: 1px solid var(--border); display: flex; align-items: center; gap: 20px; width: 100%; box-sizing: border-box; }
.task-info { flex: 1; display: flex; align-items: center; gap: 15px; }

/* Empty States */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 80px 20px; text-align: center; color: var(--text-dim); }
.empty-state .icon { font-size: 3rem; margin-bottom: 15px; opacity: 0.4; }
.empty-state h3 { margin: 0 0 10px 0; color: white; font-weight: 500; }
.empty-state p { max-width: 400px; margin: 0 auto; line-height: 1.6; }


/* Loading Indicators */
.skeleton {
    background: linear-gradient(90deg, var(--card-bg) 25%, #2a2a2a 50%, var(--card-bg) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    border: 1px solid var(--border);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-row {
    background: var(--card-bg);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 10px;
    width: 100%;
    box-sizing: border-box;
}

.skeleton-thumb { width: 80px; height: 45px; flex-shrink: 0; }
.skeleton-text { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.skeleton-line { height: 12px; width: 100%; }
.skeleton-line.short { width: 60%; }
.skeleton-btn { width: 80px; height: 30px; flex-shrink: 0; }

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

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


.favorites-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(450px, 1fr)); gap: 20px; max-width: 1600px; margin: 0 auto; }
.fav-card { background: var(--card-bg); padding: 20px; border-radius: 12px; border: 1px solid var(--border); display: flex; align-items: flex-start; gap: 20px; cursor: pointer; transition: 0.2s; position: relative; min-width: 400px; }
.fav-card:hover { background: #2a2a2a; border-color: var(--primary); transform: translateY(-2px); }

.library-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.bulk-actions { display: none; gap: 12px; align-items: center; background: #1a1a1a; padding: 8px 16px; border-radius: 6px; border: 1px solid var(--primary); }
.bulk-actions.active { display: flex; }

.compress-section { display: flex; flex-direction: column; gap: 12px; }
.file-item { 
    background: var(--card-bg); 
    padding: 15px; 
    border-radius: 8px; 
    border: 1px solid var(--border); 
    display: flex; 
    align-items: center; 
    gap: 20px; 
    transition: 0.2s;
    width: 100%;
    box-sizing: border-box;
}
.file-item:hover { background: #252525; border-color: #444; }
.file-item.selected { border-color: var(--primary); background: #2a2a2a; box-shadow: inset 0 0 10px rgba(145, 70, 255, 0.1); }

.checkbox-wrapper { width: 30px; display: flex; justify-content: center; align-items: center; flex-shrink: 0; }
.file-checkbox { width: 16px; height: 16px; cursor: pointer; }

.thumb-preview { 
    width: 80px; 
    height: 45px; 
    border-radius: 4px; 
    object-fit: cover; 
    background: #222; 
    border: 1px solid var(--border); 
    flex-shrink: 0;
    position: relative;
    display: block;
}
.thumb-preview.error {
    opacity: 0;
}
.thumb-preview::after {
    content: '🎬';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2rem;
    opacity: 0.3;
}

.file-details { flex: 1; display: flex; flex-direction: column; gap: 4px; overflow: hidden; }
.file-name { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; }
.file-meta { font-size: 0.8rem; color: var(--text-dim); display: flex; gap: 10px; align-items: center; }
.meta-item { display: flex; align-items: center; gap: 4px; }

.btn-download { 
    background: var(--success); 
    color: #000; 
    text-decoration: none; 
    padding: 6px 12px; 
    border-radius: 6px; 
    font-size: 0.8rem; 
    font-weight: 800; 
    transition: 0.2s; 
    white-space: nowrap;
    flex-shrink: 0;
}
.btn-download:hover { 
    filter: brightness(1.2); 
    transform: translateY(-1px); 
    color: #000;
}

.compress-controls { display: flex; gap: 10px; align-items: center; }
select { padding: 6px; border-radius: 4px; background: #121212; color: white; border: 1px solid var(--border); font-size: 0.85rem; }

/* Automation Menu Styles */
.automation-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-left: 4px solid var(--border);
    border-radius: 12px;
    padding: 0;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    transition: 0.2s;
    box-sizing: border-box;
    overflow: hidden;
}
.automation-card:hover { border-color: var(--primary); background: #252525; transform: translateY(-2px); }
.automation-card.enabled { border-left-color: var(--primary); }

.automation-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 15px 20px;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid var(--border);
}
.automation-header h4 { margin: 0; font-size: 1.2rem; color: white; font-weight: 600; }

.automation-body { padding: 20px; display: flex; flex-direction: column; gap: 20px; }

.automation-section { display: flex; flex-direction: column; gap: 12px; }
.automation-section-title { 
    font-size: 0.75rem; 
    text-transform: uppercase; 
    color: var(--text-dim); 
    font-weight: bold; 
    letter-spacing: 0.05em; 
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
}

.automation-settings { display: flex; flex-direction: column; gap: 12px; font-size: 0.85rem; color: var(--text-dim); }
.settings-group { 
    display: flex; 
    align-items: center; 
    gap: 20px; 
    flex-wrap: wrap; 
    padding: 10px; 
    border-radius: 8px; 
    background: rgba(0,0,0,0.2); 
    transition: 0.2s;
}
.settings-group:hover { background: rgba(0,0,0,0.3); }
.settings-group.toggles { background: transparent; padding: 0; }

.setting-item { display: flex; align-items: center; gap: 6px; }
.setting-item input[type="checkbox"] { width: auto; height: auto; margin: 0; cursor: pointer; flex-shrink: 0; }
.setting-item label, .setting-item span { cursor: pointer; display: flex; align-items: center; gap: 6px; font-weight: 500; }
.setting-item select { padding: 4px 8px; border-radius: 4px; background: #121212; color: white; border: 1px solid var(--border); font-size: 0.8rem; }
.setting-item input { width: auto; }

.channel-description { font-size: 0.9rem; color: var(--text-dim); margin: 5px 0; line-height: 1.4; }

/* Tooltip System */
[data-tooltip] { position: relative; cursor: pointer; }
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
    border: 1px solid var(--border);
    pointer-events: none;
}
[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.fav-card-add {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    cursor: pointer;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}
.fav-card-add:hover {
    background: var(--primary);
    color: white;
}

.recommendations-container { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    flex-wrap: wrap; 
    margin-bottom: 20px; 
    font-size: 0.85rem; 
    color: var(--text-dim); 
}

.recommendations-container { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    flex-wrap: wrap; 
    margin-bottom: 20px; 
    font-size: 0.85rem; 
    color: var(--text-dim); 
}

.rec-tag { 
    background: #2a2a2a; 
    color: white; 
    padding: 4px 10px; 
    border-radius: 12px; 
    cursor: pointer; 
    border: 1px solid var(--border); 
    transition: 0.2s; 
    font-weight: 500; 
    font-size: 0.8rem;
    display: inline-block;
}
.rec-tag:hover { 
    background: #333; 
    border-color: var(--primary); 
    color: white; 
    transform: translateY(-1px); 
}

/* Toast Notifications */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; }
.toast { background: #222; color: white; padding: 12px 20px; border-radius: 6px; border-left: 4px solid var(--primary); box-shadow: 0 4px 12px rgba(0,0,0,0.5); min-width: 250px; animation: slideIn 0.3s ease-out; cursor: pointer; transition: 0.2s; }
.toast:hover { background: #2a2a2a; }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--error); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.compress-modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 3000; align-items: center; justify-content: center; }

.compress-modal.active { display: flex; }
.compress-modal-content { background: var(--card-bg); padding: 25px; border-radius: 8px; width: 400px; border: 1px solid var(--border); display: flex; flex-direction: column; gap: 20px; }
.compress-modal-content h3 { margin: 0; font-size: 1.2rem; }
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group label { font-size: 0.9rem; color: var(--text-dim); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }
.btn-secondary { background: #444; color: white; border: none; border-radius: 6px; cursor: pointer; padding: 10px 20px; font-weight: bold; transition: 0.2s; }
.btn-secondary:hover { background: #555; }