/* === YouTube-inspirierte Dark UI === */
:root {
  --bg: #0f0f0f;
  --bg-elev: #1f1f1f;
  --bg-hover: #272727;
  --border: #303030;
  --text: #f1f1f1;
  --text-muted: #aaa;
  --accent: #ff0033;
  --accent-hover: #cc0029;
  --header-h: 56px;
  --sidebar-w: 240px;
  --sidebar-w-collapsed: 72px;
  --thumb-radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Roboto', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* === Header === */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg);
  display: flex;
  align-items: center;
  padding: 0 16px;
  z-index: 50;
  gap: 16px;
}

.header__left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 200px;
}

.menu-btn {
  background: transparent;
  border: 0;
  color: var(--text);
  width: 40px; height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.menu-btn:hover { background: var(--bg-hover); }
.menu-btn svg { width: 24px; height: 24px; fill: currentColor; }

.logo {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.5px;
}
.logo__play {
  background: var(--accent);
  width: 30px; height: 22px;
  border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
}
.logo__play::after {
  content: '';
  border-left: 8px solid #fff;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  margin-left: 2px;
}
.logo__text { color: var(--text); }
.logo__sub { color: var(--text-muted); font-size: 10px; vertical-align: super; margin-left: 2px; }

/* === Search === */
.header__center {
  flex: 1;
  display: flex;
  justify-content: center;
  max-width: 720px;
  margin: 0 auto;
}
.search {
  display: flex;
  width: 100%;
  max-width: 640px;
}
.search input {
  flex: 1;
  background: #121212;
  border: 1px solid var(--border);
  border-right: 0;
  border-radius: 40px 0 0 40px;
  color: var(--text);
  padding: 0 16px;
  height: 40px;
  font-size: 16px;
  outline: none;
}
.search input:focus {
  border-color: #1c62b9;
  background: #0a0a0a;
}
.search button {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  width: 64px;
  border-radius: 0 40px 40px 0;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.search button:hover { background: var(--bg-hover); }
.search button svg { width: 22px; height: 22px; fill: currentColor; }

.header__right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 200px;
  justify-content: flex-end;
}
.icon-btn {
  background: transparent;
  border: 0;
  color: var(--text);
  width: 40px; height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--bg-hover); }
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff0033, #cc0099);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

/* === Layout === */
.layout {
  display: flex;
  padding-top: var(--header-h);
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  padding: 12px;
  position: fixed;
  top: var(--header-h);
  bottom: 0;
  overflow-y: auto;
  background: var(--bg);
}
.sidebar__section {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.sidebar__section:last-child { border-bottom: 0; }
.sidebar__title {
  padding: 8px 12px;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
}
.sidebar__item {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  transition: background 0.1s;
}
.sidebar__item:hover { background: var(--bg-hover); }
.sidebar__item.active { background: var(--bg-hover); font-weight: 500; }
.sidebar__item svg { width: 22px; height: 22px; fill: currentColor; flex-shrink: 0; }
.sidebar__item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main {
  margin-left: var(--sidebar-w);
  padding: 24px;
  flex: 1;
  min-width: 0;
}

/* === Video Grid (Home) === */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px 12px;
}

.video-card {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  border-radius: var(--thumb-radius);
  overflow: hidden;
  transition: transform 0.15s;
}
.video-card:hover .video-card__thumb {
  border-radius: 0;
}
.video-card__thumb {
  position: relative;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: var(--thumb-radius);
  overflow: hidden;
  transition: border-radius 0.15s;
}
.video-card__thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.video-card__duration {
  position: absolute;
  right: 6px; bottom: 6px;
  background: rgba(0,0,0,0.85);
  color: #fff;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: 4px;
  font-weight: 500;
}
.video-card__body {
  display: flex;
  gap: 12px;
  padding: 12px 4px 0;
}
.video-card__avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #444, #222);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  color: #ccc;
}
.video-card__meta { flex: 1; min-width: 0; }
.video-card__title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
  margin: 0 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.video-card__channel,
.video-card__stats {
  color: var(--text-muted);
  font-size: 12px;
  margin: 0;
}

/* === Empty state === */
.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}
.empty h2 { color: var(--text); margin: 0 0 12px; }
.empty code {
  background: var(--bg-elev);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', Menlo, monospace;
  color: var(--text);
}

/* === Watch page === */
.watch {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 24px;
  max-width: 1800px;
  margin: 0 auto;
}
@media (max-width: 1100px) {
  .watch { grid-template-columns: 1fr; }
}

.player-wrap {
  width: 100%;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 16/9;
}
.player-wrap video {
  width: 100%; height: 100%;
  display: block;
}
.watch__title {
  font-size: 20px;
  font-weight: 600;
  margin: 16px 0 8px;
  color: var(--text);
}
.watch__meta {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.watch__channel {
  display: flex;
  align-items: center;
  gap: 12px;
}
.watch__channel-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff0033, #cc0099);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
}
.watch__channel-name { font-weight: 500; }
.watch__channel-sub { font-size: 12px; color: var(--text-muted); }

.btn {
  background: var(--bg-elev);
  color: var(--text);
  border: 0;
  height: 36px;
  border-radius: 18px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover { background: var(--bg-hover); }
.btn--primary { background: #fff; color: #000; }
.btn--primary:hover { background: #ddd; }

.description {
  background: var(--bg-elev);
  border-radius: 12px;
  padding: 12px 16px;
  margin-top: 16px;
  color: var(--text);
  font-size: 14px;
}
.description__meta { color: var(--text-muted); font-size: 13px; margin-bottom: 4px; }

/* === Sidebar: Up next === */
.up-next h3 {
  font-size: 16px;
  margin: 0 0 12px;
}
.up-next__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.up-next__item {
  display: grid;
  grid-template-columns: 168px 1fr;
  gap: 8px;
  cursor: pointer;
  border-radius: 8px;
  padding: 4px;
  transition: background 0.1s;
}
.up-next__item:hover { background: var(--bg-hover); }
.up-next__item.active { background: var(--bg-hover); }
.up-next__thumb {
  aspect-ratio: 16/9;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}
.up-next__thumb img { width: 100%; height: 100%; object-fit: cover; }
.up-next__meta { min-width: 0; padding-top: 2px; }
.up-next__title {
  font-size: 14px;
  font-weight: 500;
  margin: 0 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.up-next__channel { font-size: 12px; color: var(--text-muted); margin: 0; }

/* === Login Page === */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at top, #1a1a1a, #0a0a0a 70%);
  padding: 20px;
}
.login-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 30px 60px rgba(0,0,0,0.5);
}
.login-card .logo {
  justify-content: center;
  font-size: 28px;
  margin-bottom: 8px;
}
.login-card .logo__play { width: 40px; height: 28px; }
.login-card .logo__play::after {
  border-left-width: 10px;
  border-top-width: 6px;
  border-bottom-width: 6px;
}
.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  margin: 0 0 32px;
  font-size: 14px;
}
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form label {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.login-form input {
  width: 100%;
  background: #0a0a0a;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s;
}
.login-form input:focus { border-color: var(--accent); }
.login-form button {
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 12px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.login-form button:hover { background: var(--accent-hover); }
.login-error {
  background: rgba(255, 0, 51, 0.1);
  border: 1px solid rgba(255, 0, 51, 0.3);
  color: #ff6b8a;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
}
.login-footer {
  margin-top: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* === Loading skeletons === */
.skeleton {
  background: linear-gradient(90deg, #222 0%, #2a2a2a 50%, #222 100%);
  background-size: 200% 100%;
  animation: skeleton 1.4s ease-in-out infinite;
}
@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* === Responsive === */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .header__center { display: none; }
}
@media (max-width: 600px) {
  .header__left { min-width: auto; }
  .header__right { min-width: auto; }
  .main { padding: 16px; }
  .video-grid { grid-template-columns: 1fr; }
}
