:root {
    --bg-dark: #0a0a0f;
    --glass-bg: rgba(20, 20, 30, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --accent: #8b5cf6;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Dynamic Background Orbs */
.glass-bg {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    backdrop-filter: blur(80px);
    z-index: -1;
}

.orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -2;
    animation: float 20s infinite ease-in-out alternate;
}

.orb1 { width: 40vw; height: 40vw; background: rgba(99, 102, 241, 0.2); top: -10%; left: -10%; }
.orb2 { width: 35vw; height: 35vw; background: rgba(139, 92, 246, 0.15); bottom: -10%; right: -5%; animation-delay: -5s; }
.orb3 { width: 25vw; height: 25vw; background: rgba(16, 185, 129, 0.1); top: 40%; left: 40%; animation-delay: -10s; }

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 50px) scale(1.1); }
}

/* Layout */
.app-container {
    display: grid;
    grid-template-areas: 
        "header header"
        "sidebar main";
    grid-template-columns: 240px 1fr;
    grid-template-rows: 70px 1fr;
    height: 100vh;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .app-container {
        grid-template-areas: 
            "header"
            "main"
            "sidebar";
        grid-template-columns: 1fr;
        grid-template-rows: 60px 1fr 64px;
        height: 100vh;
        height: 100dvh;
    }
    
    .sidebar {
        flex-direction: row !important;
        justify-content: space-around;
        padding: 6px 8px !important;
        border-right: none !important;
        border-top: 1px solid var(--glass-border);
        z-index: 50;
        background: rgba(13, 13, 20, 0.95) !important;
        backdrop-filter: blur(20px);
        position: relative;
    }
    
    .nav-btn {
        flex: 1;
        flex-direction: column !important;
        align-items: center;
        justify-content: center;
        padding: 6px 2px !important;
        font-size: 0.72rem !important;
        border-radius: 8px !important;
        gap: 2px !important;
        white-space: nowrap;
        text-align: center;
    }
    
    .nav-btn .icon {
        font-size: 1.15rem !important;
    }
    
    .nav-btn.active {
        border-left: none !important;
        border-bottom: 3px solid var(--primary);
        background: linear-gradient(0deg, rgba(99, 102, 241, 0.2), transparent) !important;
    }
    
    .resource-monitor {
        display: none !important; /* Hide resource monitor on mobile to save space */
    }
    
    .header {
        padding: 0 16px !important;
        height: 60px;
    }

    .logo {
        font-size: 1.25rem !important;
    }
    
    .main-content {
        padding: 14px 12px 30px 12px !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .header-with-controls {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .controls {
        flex-wrap: wrap !important;
        gap: 6px !important;
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .stat-card {
        padding: 14px !important;
    }

    .tree-header {
        flex-wrap: wrap !important;
        gap: 6px !important;
        padding: 6px 8px !important;
    }

    .tree-label {
        min-width: 0;
        flex: 1 1 auto;
    }

    .tree-title {
        font-size: 0.85rem !important;
        max-width: 180px;
    }

    .tree-badges {
        margin-left: 0 !important;
        flex-wrap: wrap;
        width: 100%;
        padding-left: 28px;
    }

    .tree-children {
        padding-left: 12px !important;
        margin-left: 4px !important;
    }

    .modal-content {
        width: 94% !important;
        max-width: 380px !important;
        padding: 24px 16px !important;
    }
}

/* Header */
.header {
    grid-area: header;
    background: var(--glass-bg);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
    backdrop-filter: blur(20px);
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: 1px;
}

.highlight {
    color: var(--primary);
    background: linear-gradient(to right, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.resource-monitor {
    display: flex;
    gap: 20px;
}

.monitor-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    font-weight: 600;
}

.monitor-label { color: var(--text-muted); }
.monitor-value { width: 40px; text-align: right; }

.monitor-bar-container {
    width: 60px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.monitor-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--warning));
    width: 0%;
    transition: width 0.5s ease;
}

/* Sidebar */
.sidebar {
    grid-area: sidebar;
    background: rgba(15, 15, 20, 0.4);
    border-right: 1px solid var(--glass-border);
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    backdrop-filter: blur(10px);
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 12px 20px;
    border-radius: 12px;
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-btn.active {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.15), transparent);
    color: var(--primary);
    border-left: 3px solid var(--primary);
}

/* Main Content */
.main-content {
    grid-area: main;
    padding: 40px;
    overflow-y: auto;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

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

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

.module-header {
    margin-bottom: 30px;
}

.module-header h2 {
    font-family: var(--font-heading);
    font-size: 2rem;
    margin-bottom: 5px;
}

.module-header p {
    color: var(--text-muted);
}

/* Cards & Glass Elements */
.glass-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    backdrop-filter: blur(20px);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    transition: transform 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.05);
}

.stat-card h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    font-weight: 400;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Inputs & Buttons */
.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

input[type="text"] {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 15px 20px;
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

input[type="text"]:focus {
    border-color: var(--primary);
}

.action-btn {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border: none;
    border-radius: 12px;
    padding: 12px 30px;
    color: white;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.action-btn:hover { opacity: 0.5; }

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: relative;
    width: 40px;
    height: 20px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    transition: .4s;
    margin-right: 10px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-main);
    border-radius: 50%;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.toggle-label {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Folder Checkbox List */
.folder-checkbox-list {
    max-height: 250px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 10px;
    border: 1px solid var(--glass-border);
    margin-bottom: 10px;
}

.action-btn:active { transform: scale(0.98); }

.action-btn.sm-btn {
    padding: 10px 20px;
    font-size: 0.9rem;
}

.action-btn.full-width {
    width: 100%;
}

.action-btn.warning {
    background: linear-gradient(135deg, var(--warning), #d97706);
}

.action-btn.success {
    background: linear-gradient(135deg, var(--success), #059669);
}

/* Settings and Logs UI */
.header-with-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.folder-list {
    list-style: none;
    margin: 10px 0;
    max-height: 200px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 10px;
}

.folder-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.folder-item button {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.8rem;
}

.logs-container {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 15px;
    height: 200px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 0.85rem;
    color: #a3a3a3;
}

.log-entry {
    margin-bottom: 4px;
    border-bottom: 1px solid rgba(255,255,255,0.02);
    padding-bottom: 4px;
}

.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.mb-1 { margin-bottom: 10px; }
.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }

/* Progress Bars */
.progress-wrapper { margin-top: 15px; }

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #3b82f6);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-bar.accent-purple {
    background: linear-gradient(90deg, var(--accent), var(--primary));
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Badges & Utilities */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    background: rgba(255,255,255,0.1);
}
.badge.success { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.badge.warning { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.badge.danger { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.badge.paused { background: rgba(99, 102, 241, 0.2); color: var(--primary); }

.text-green { color: var(--success); }
.text-red { color: var(--danger); }

/* Download Items */
.download-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
}
.download-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.download-url {
    font-size: 0.9rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}
.folder-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 6px;
    transition: background 0.2s;
}

.folder-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.folder-item label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    flex: 1;
}

.folder-stats-badge {
    font-size: 0.8rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 12px;
    color: var(--text-muted);
}
.form-select {
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    outline: none;
}
.form-select:focus {
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.3);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}
.modal-content {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 30px;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes modalPop {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}


/* ========================================================
   Telegram Video Optimizer & Tree View Styles
   ======================================================== */
.telegram-tree-container {
    max-height: 480px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 12px;
    margin-top: 10px;
}

.tree-node {
    margin-bottom: 6px;
}

.tree-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.2s ease;
    user-select: none;
}

.tree-header:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.12);
}

.tree-toggle {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 20px;
    height: 20px;
    font-size: 0.75rem;
    color: var(--accent);
    cursor: pointer;
    border-radius: 4px;
    transition: transform 0.2s ease;
}

.tree-toggle.no-children {
    color: var(--text-muted);
    cursor: default;
    opacity: 0.5;
}

.tree-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    flex: 1;
    min-width: 0;
}

.tree-icon {
    font-size: 1.1rem;
}

.tree-title {
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #fff;
}

.tree-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.tree-children {
    display: none;
    padding-left: 24px;
    margin-left: 8px;
    border-left: 2px dashed rgba(255, 255, 255, 0.12);
    margin-top: 4px;
}

.tree-children.expanded {
    display: block;
}

.tree-empty {
    padding: 6px 12px;
    font-style: italic;
}

.badge.info {
    background: rgba(32, 190, 255, 0.15);
    color: #20beff;
    border: 1px solid rgba(32, 190, 255, 0.3);
}

.subfolder-header {
    background: rgba(255, 255, 255, 0.015);
}

.opt-target-cb {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}
