/* styles.css — YouTube Player */

@import url('https://fonts.googleapis.com/css2?family=Heebo:wght@300;400;500;700;800&family=Inter:wght@400;500;600&display=swap');

*, *::before, *::after { box-sizing: border-box; }

:root {
    --bg-base:    #f4f4f5;
    --bg-surface: #ffffff;
    --bg-card:    #ffffff;
    --bg-hover:   #f0f0f2;
    --border:     rgba(0,0,0,0.09);
    --border-hover: rgba(0,0,0,0.18);
    --text-primary:   #111111;
    --text-secondary: #555566;
    --text-muted:     #9999aa;
    --accent:    #7c3aed;
    --accent-light: rgba(124,58,237,0.08);
    --red:       #ff0000;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Heebo', sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    direction: rtl;
    overflow-x: hidden;
}

/* ─── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* ─── Animations ──────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
    from { transform: scale(0.96); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.animate-fade-in  { animation: fadeIn  0.35s cubic-bezier(0.16,1,0.3,1) forwards; }
.animate-scale-in { animation: scaleIn 0.28s cubic-bezier(0.16,1,0.3,1) forwards; }
.animate-slide-up { animation: slideUp 0.3s cubic-bezier(0.16,1,0.3,1) forwards; }

/* ─── Navbar ──────────────────────────────────────────────── */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    text-decoration: none;
}

.nav-logo-icon {
    width: 36px;
    height: 36px;
    background: var(--red);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    transition: transform 0.2s;
}
.nav-logo:hover .nav-logo-icon { transform: scale(1.08); }

.nav-logo-text {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 15px;
    position: relative;
}
.nav-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-btn.active { background: var(--accent-light); color: var(--accent); }

/* ─── Container ─────────────────────────────────────────────── */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ─── Categories ─────────────────────────────────────────────── */
.category-section {
    width: 100%;
    flex-shrink: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px 20px 20px;
    box-shadow: 0 1px 8px rgba(0,0,0,0.08);
    align-self: start;
}

@media (max-width: 700px) {
    .category-section { width: 100%; }
}

.category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.category-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.channels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    direction: rtl;
}

.channels-grid > * {
    min-width: 0;
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .channels-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
}

/* ─── Channel mini card ─────────────────────────────────────── */
.channel-mini-card {
    cursor: pointer;
    border-radius: 12px;
    padding: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: all 0.2s cubic-bezier(0.16,1,0.3,1);
    overflow: hidden;
}
.channel-mini-card:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

/* ─── Add channel tile (inside grid) ───────────────────────── */
.add-channel-tile {
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    border: 1.5px dashed rgba(255,255,255,0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 4px;
    background: transparent;
}
.add-channel-tile:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

/* ─── Channel view header ───────────────────────────────────── */
.channel-header {
    background: linear-gradient(to bottom, #f0f0f4, transparent);
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 24px;
    display: flex;
    gap: 24px;
    align-items: flex-start;
    border: 1px solid var(--border);
}

.channel-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
    flex-shrink: 0;
}

/* ─── Stat badges ─────────────────────────────────────────────── */
.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid;
}

.stat-badge-red    { background: rgba(239,68,68,0.1);    color: #f87171; border-color: rgba(239,68,68,0.2); }
.stat-badge-purple { background: rgba(124,58,237,0.1);   color: #a78bfa; border-color: rgba(124,58,237,0.2); }
.stat-badge-zinc   { background: rgba(113,113,122,0.1);  color: #a1a1aa; border-color: rgba(113,113,122,0.2); }
.stat-badge-green  { background: rgba(34,197,94,0.1);    color: #4ade80; border-color: rgba(34,197,94,0.2); }

/* ─── Search ─────────────────────────────────────────────────── */
.search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 12px;
    padding: 10px 40px 10px 100px;
    font-family: 'Heebo', sans-serif;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}
.search-input:focus {
    border-color: var(--accent);
    background: var(--bg-surface);
}
.search-input::placeholder { color: var(--text-muted); }

/* ─── Modals ─────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-box {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 28px;
    width: 100%;
    max-width: 440px;
    position: relative;
    animation: scaleIn 0.25s cubic-bezier(0.16,1,0.3,1) forwards;
}

.modal-input {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 12px;
    padding: 12px 16px;
    font-family: 'Heebo', sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
    direction: ltr;
}
.modal-input:focus { border-color: var(--accent); }
.modal-input::placeholder { color: var(--text-muted); direction: rtl; }

.btn-primary {
    background: var(--red);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 12px 20px;
    font-family: 'Heebo', sans-serif;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    width: 100%;
}
.btn-primary:hover { background: #dc2626; transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 16px;
    font-family: 'Heebo', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-secondary:hover { background: #2a2a2a; color: var(--text-primary); }

/* ─── Settings panel ─────────────────────────────────────────── */
.settings-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 260px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px;
    z-index: 200;
    animation: scaleIn 0.2s cubic-bezier(0.16,1,0.3,1) forwards;
    transform-origin: top left;
}

.settings-group {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 8px;
}

.settings-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: block;
    margin-bottom: 6px;
}

.settings-input {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 12px;
    outline: none;
    flex: 1;
    min-width: 0;
    direction: ltr;
    font-family: 'Inter', monospace;
    transition: border-color 0.15s;
}
.settings-input:focus { border-color: var(--accent); }
.settings-input::placeholder { color: var(--text-muted); }

.settings-save-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--accent);
    border-radius: 8px;
    padding: 7px 10px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 12px;
    flex-shrink: 0;
}
.settings-save-btn:hover { background: var(--accent-light); }

.settings-menu-btn {
    width: 100%;
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'Heebo', sans-serif;
}
.settings-menu-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ─── SortableJS ─────────────────────────────────────────────── */
.sortable-ghost {
    opacity: 0.3;
    background: var(--accent-light);
    border: 1.5px dashed var(--accent);
}
.drag-handle { cursor: grab; }
.drag-handle:active { cursor: grabbing; }

/* ─── Toast ──────────────────────────────────────────────────── */
#toastContainer {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

/* ─── Line clamp ─────────────────────────────────────────────── */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ─── Fav view ───────────────────────────────────────────────── */
.fav-filter-btn { transition: all 0.15s; }

/* ─── Back button ────────────────────────────────────────────── */
.back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'Heebo', sans-serif;
}
.back-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-hover); }

/* ─── Sort menu ──────────────────────────────────────────────── */
#sortMenu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 200px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 4px;
    z-index: 50;
    animation: scaleIn 0.2s cubic-bezier(0.16,1,0.3,1) forwards;
    transform-origin: top left;
}
#sortMenu button {
    width: 100%;
    text-align: right;
    padding: 9px 14px;
    font-size: 13px;
    font-family: 'Heebo', sans-serif;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.12s;
    display: flex;
    align-items: center;
    gap: 8px;
}
#sortMenu button:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ─── Empty state ────────────────────────────────────────────── */
.empty-icon {
    width: 80px;
    height: 80px;
    background: rgba(239,68,68,0.08);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin: 0 auto 16px;
    color: #f87171;
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 640px) {
    .channel-header { flex-direction: column; align-items: center; text-align: center; }
    .channel-avatar { width: 72px; height: 72px; }
}
