/* ============================================================
   YouTube Manager – Stylesheet
   ============================================================ */
:root {
  --primary: #FF6B35;
  --primary-dark: #e55a25;
  --bg: #f0f2f5;
  --card-bg: #fff;
  --text: #1a1a2e;
  --muted: #666;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,.09);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ── */
.site-header {
  background: linear-gradient(135deg, var(--primary) 0%, #ff9a56 100%);
  color: #fff;
  padding: .9rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 2px 8px rgba(255,107,53,.35);
  position: sticky;
  top: 0;
  z-index: 100;
}
.site-header .logo {
  font-size: 1.6rem;
  text-decoration: none;
  color: #fff;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.site-header .logo span { font-size: 1.8rem; }
.site-header .header-right { margin-left: auto; display: flex; gap: .5rem; }
.home-only-btn {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  border-radius: 10px;
  text-decoration: none;
  background: rgba(255,255,255,.2);
  border: 1.5px solid rgba(255,255,255,.5);
  color: #fff;
}
.btn-admin {
  background: rgba(255,255,255,.2);
  border: 1.5px solid rgba(255,255,255,.5);
  color: #fff;
  padding: .4rem .9rem;
  border-radius: 8px;
  text-decoration: none;
  font-size: .85rem;
  font-weight: 600;
  transition: background .2s;
}
.btn-admin:hover { background: rgba(255,255,255,.35); }

/* ── Main content ── */
.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1.25rem; }

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: .5rem;
}

/* ── Channel cards ── */
.channels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.2rem;
}

.channel-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 1rem;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  transition: transform .2s, box-shadow .2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
}
.channel-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,.14);
}
.channel-card img {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--primary);
}
.channel-card .ch-name {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.3;
}
.channel-card .ch-subs {
  font-size: .8rem;
  color: var(--muted);
}

/* ── Video grid ── */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.2rem;
}

.video-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  overflow: hidden;
  transition: transform .2s, box-shadow .2s;
  display: flex;
  flex-direction: column;
}
.video-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,.14);
}
.video-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  overflow: hidden;
}
.video-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.video-duration {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0,0,0,.75);
  color: #fff;
  font-size: .75rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.video-info { padding: .75rem; flex: 1; }
.video-title {
  font-weight: 600;
  font-size: .92rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.video-meta {
  margin-top: .4rem;
  font-size: .78rem;
  color: var(--muted);
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

/* ── Channel header (on channel.php) ── */
.channel-header {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
.channel-header img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid var(--primary);
  flex-shrink: 0;
}
.channel-header-info h1 { font-size: 1.4rem; margin-bottom: .25rem; }
.channel-header-info p  { color: var(--muted); font-size: .9rem; }

/* ── Watch page ── */
.watch-container { max-width: 900px; margin: 0 auto; padding: 1.5rem 1.25rem; }
.watch-compact { max-width: 980px; padding-top: .9rem; }
.video-player-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  background: #000;
}
.video-player-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}
.video-player-wrap #yt-player {
  position: absolute;
  inset: 0;
}
.watch-only-mode .site-header {
  display: none;
}
.floating-home {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 15;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(0,0,0,.55);
  border: 1px solid rgba(255,255,255,.3);
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}
.safe-guard-zone {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 60%;
  height: 58%;
  border: none;
  background: linear-gradient(
    to top left,
    rgba(0,0,0,.18) 0%,
    rgba(0,0,0,.08) 35%,
    rgba(0,0,0,.02) 60%,
    transparent 100%
  );
  border-top-left-radius: 18px;
  z-index: 14;
  pointer-events: auto;
}
.custom-fullscreen-btn {
  position: absolute;
  right: 14px;
  bottom: 12px;
  z-index: 22;
  border: none;
  border-radius: 12px;
  padding: .58rem .95rem;
  background: rgba(0,0,0,.62);
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,.35);
}
.custom-fullscreen-btn:hover {
  background: rgba(0,0,0,.76);
}
.video-details { background: var(--card-bg); border-radius: var(--radius); padding: 1.25rem; margin-top: 1rem; box-shadow: var(--shadow); }
.video-details h1 { font-size: 1.2rem; margin-bottom: .5rem; }
.video-details .meta { color: var(--muted); font-size: .85rem; }
.watch-toolbar {
  margin-top: .9rem;
  display: flex;
  gap: .6rem;
  align-items: center;
  flex-wrap: wrap;
}
.watch-btn {
  border: none;
  border-radius: 8px;
  padding: .55rem 1rem;
  font-size: .92rem;
  font-weight: 700;
  cursor: pointer;
}
.watch-btn-danger {
  background: #e53935;
  color: #fff;
}
.watch-btn-muted {
  background: #253244;
  color: #fff;
}
.watch-select {
  border-radius: 8px;
  padding: .5rem .7rem;
  font-size: .9rem;
  border: 1.5px solid #ddd;
}
.watch-parent-row {
  margin-top: .65rem;
  display: flex;
  justify-content: flex-end;
}

.floating-home-global {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 120;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(0,0,0,.55);
  border: 1px solid rgba(255,255,255,.25);
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

/* Android Box WebView has a hidden long-press hotspot at top-left. */
body.is-yt-box .floating-home-global {
  left: 94px;
}

.floating-admin-global {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 120;
  border-radius: 10px;
  background: rgba(0,0,0,.55);
  border: 1px solid rgba(255,255,255,.25);
  color: #fff;
  text-decoration: none;
  padding: .55rem .9rem;
  font-size: .9rem;
  font-weight: 700;
}

body > .container {
  padding-top: 4.2rem;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  margin-bottom: 1rem;
  font-size: .95rem;
}
.back-link:hover { color: var(--primary-dark); }

/* ── Pagination ── */
.pagination {
  display: flex;
  justify-content: center;
  gap: .5rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}
.page-btn {
  padding: .5rem 1rem;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  transition: all .2s;
  background: var(--card-bg);
}
.page-btn:hover, .page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ── Login / forms ── */
.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.auth-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 24px rgba(0,0,0,.12);
}
.auth-card h1 { font-size: 1.5rem; color: var(--primary); margin-bottom: .25rem; }
.auth-card .sub { color: var(--muted); font-size: .9rem; margin-bottom: 1.5rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .35rem; }
.form-group input {
  width: 100%;
  padding: .65rem .9rem;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color .2s;
}
.form-group input:focus { outline: none; border-color: var(--primary); }
.btn-primary {
  width: 100%;
  padding: .75rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s;
}
.btn-primary:hover { background: var(--primary-dark); }
.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }
.alert-error { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }

/* ── Admin layout ── */
.admin-wrap { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 220px;
  background: #1a1a2e;
  color: #aaa;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.admin-sidebar .brand {
  padding: 1.25rem 1.25rem .75rem;
  color: var(--primary);
  font-size: 1.1rem;
  font-weight: 800;
  border-bottom: 1px solid #2a2a45;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.admin-sidebar nav { padding: .75rem 0; flex: 1; }
.admin-sidebar nav a {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .65rem 1.25rem;
  color: #bbb;
  text-decoration: none;
  font-size: .9rem;
  transition: background .15s, color .15s;
}
.admin-sidebar nav a:hover, .admin-sidebar nav a.active {
  background: rgba(255,107,53,.15);
  color: var(--primary);
}
.admin-sidebar .logout-link {
  padding: 1rem 1.25rem;
  border-top: 1px solid #2a2a45;
}
.admin-sidebar .logout-link a {
  color: #888;
  text-decoration: none;
  font-size: .85rem;
}
.admin-sidebar .logout-link a:hover { color: #e55; }

.admin-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.admin-topbar {
  background: #fff;
  border-bottom: 1px solid #eee;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.admin-topbar h1 { font-size: 1.15rem; font-weight: 700; }
.admin-content { padding: 1.5rem; flex: 1; overflow-y: auto; }

/* Admin tables */
.admin-table { width: 100%; border-collapse: collapse; background: var(--card-bg); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.admin-table th { background: #f8f8f8; padding: .75rem 1rem; text-align: left; font-size: .85rem; font-weight: 600; color: var(--muted); border-bottom: 1px solid #eee; }
.admin-table td { padding: .75rem 1rem; border-bottom: 1px solid #f0f0f0; font-size: .9rem; vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #fafafa; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .6rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-gray   { background: #f0f0f0; color: #666; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .4rem .85rem;
  border-radius: 7px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity .2s;
}
.btn:hover { opacity: .8; }
.btn-sm { padding: .3rem .65rem; font-size: .8rem; }
.btn-orange { background: var(--primary); color: #fff; }
.btn-danger  { background: #ef4444; color: #fff; }
.btn-light   { background: #f0f0f0; color: var(--text); }

.admin-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.admin-card h2 { font-size: 1.1rem; margin-bottom: 1rem; display: flex; align-items: center; gap: .4rem; }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--card-bg); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.stat-card .num { font-size: 2rem; font-weight: 800; color: var(--primary); }
.stat-card .lbl { font-size: .85rem; color: var(--muted); margin-top: .2rem; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--muted);
}
.empty-state .icon { font-size: 4rem; margin-bottom: .75rem; }
.empty-state p { font-size: 1.1rem; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .channels-grid { grid-template-columns: repeat(2, 1fr); gap: .8rem; }
  .video-grid    { grid-template-columns: 1fr; }
  .admin-sidebar { display: none; }
  .channel-header { flex-direction: column; text-align: center; }
}

/* ── Notification / toast ── */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; }
.toast { background: #333; color: #fff; padding: .75rem 1.25rem; border-radius: 8px; font-size: .9rem; animation: slideIn .3s ease; max-width: 320px; }
.toast.toast-success { background: #16a34a; }
.toast.toast-error   { background: #dc2626; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Loading spinner ── */
.spinner { display: inline-block; width: 20px; height: 20px; border: 3px solid rgba(255,107,53,.3); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
