/* Movies Galore Universal Design System
   Keeps the familiar cinematic layout while allowing selectable color systems.
   Responsive behavior is based primarily on viewport/input capabilities; JS adds TV profile hints. */
:root {
  color-scheme: dark;
  --mg-accent: #ed1724;
  --mg-accent-strong: #ff3542;
  --mg-accent-soft: rgba(237,23,36,.15);
  --mg-page: #0b0b0f;
  --mg-surface: #121218;
  --mg-card: #19191f;
  --mg-card-raised: #202027;
  --mg-copy: #f5f5f7;
  --mg-muted: #a5a5af;
  --mg-line: rgba(255,255,255,.10);
  --mg-shadow: 0 14px 38px rgba(0,0,0,.34);
  --mg-radius: 14px;
}
html { min-height:100%; background:var(--mg-page); }
body {
  --bg: var(--mg-page);
  --panel: var(--mg-surface);
  --card: var(--mg-card);
  --text: var(--mg-copy);
  --muted: var(--mg-muted);
  --accent: var(--mg-accent);
  --accent2: var(--mg-accent-strong);
  --border: var(--mg-line);
  background:var(--mg-page) !important;
  color:var(--mg-copy) !important;
  accent-color:var(--mg-accent);
  transition:background-color .18s ease,color .18s ease;
}

/* Selectable palettes */
body[data-mg-theme="galore"] { color-scheme:dark; --mg-accent:#ed1724; --mg-accent-strong:#ff4651; --mg-accent-soft:rgba(237,23,36,.15); --mg-page:#0b0b0f; --mg-surface:#121218; --mg-card:#19191f; --mg-card-raised:#222229; --mg-copy:#f5f5f7; --mg-muted:#a5a5af; --mg-line:rgba(255,255,255,.10); }
body[data-mg-theme="oled"] { color-scheme:dark; --mg-accent:#ff2635; --mg-accent-strong:#ff6872; --mg-accent-soft:rgba(255,38,53,.16); --mg-page:#000; --mg-surface:#080808; --mg-card:#101010; --mg-card-raised:#191919; --mg-copy:#fff; --mg-muted:#a0a0a0; --mg-line:rgba(255,255,255,.12); }
body[data-mg-theme="blue"] { color-scheme:dark; --mg-accent:#278bff; --mg-accent-strong:#72b5ff; --mg-accent-soft:rgba(39,139,255,.16); --mg-page:#07101d; --mg-surface:#0d1a2b; --mg-card:#12243a; --mg-card-raised:#19304b; --mg-copy:#f2f7ff; --mg-muted:#a8bad0; --mg-line:rgba(155,195,255,.16); }
body[data-mg-theme="purple"] { color-scheme:dark; --mg-accent:#9a5cff; --mg-accent-strong:#c19aff; --mg-accent-soft:rgba(154,92,255,.17); --mg-page:#100b19; --mg-surface:#1a1227; --mg-card:#241a35; --mg-card-raised:#302247; --mg-copy:#fbf7ff; --mg-muted:#c0b2d2; --mg-line:rgba(205,170,255,.16); }
body[data-mg-theme="light"] { color-scheme:light; --mg-accent:#d71928; --mg-accent-strong:#a90d19; --mg-accent-soft:rgba(215,25,40,.10); --mg-page:#f1f2f5; --mg-surface:#fff; --mg-card:#fff; --mg-card-raised:#f7f7fa; --mg-copy:#171820; --mg-muted:#626575; --mg-line:rgba(20,24,36,.13); --mg-shadow:0 12px 30px rgba(20,24,36,.10); }
body[data-mg-theme="green"] { color-scheme:dark; --mg-accent:#20bd83; --mg-accent-strong:#75e0b5; --mg-accent-soft:rgba(32,189,131,.15); --mg-page:#07120f; --mg-surface:#0d1c17; --mg-card:#13271f; --mg-card-raised:#1a352a; --mg-copy:#f1fff8; --mg-muted:#a7c4b6; --mg-line:rgba(151,235,195,.14); }

/* Header and navigation */
body[data-mg-theme] header {
  background:linear-gradient(180deg,var(--mg-surface),var(--mg-page)) !important;
  color:var(--mg-copy) !important;
  border-bottom:1px solid var(--mg-line) !important;
}
body[data-mg-theme] header h1 { color:var(--mg-copy) !important; }
body[data-mg-theme] nav a,
body[data-mg-theme] .logout-button {
  color:var(--mg-copy) !important;
  background:var(--mg-card) !important;
  border:1px solid var(--mg-line) !important;
}
body[data-mg-theme] nav a:hover,
body[data-mg-theme] nav a:focus-visible,
body[data-mg-theme] nav a.active { background:var(--mg-accent-soft) !important; border-color:var(--mg-accent) !important; }
/* Common components across pages */
body[data-mg-theme] .card,
body[data-mg-theme] .movie-card,
body[data-mg-theme] .movie-item,
body[data-mg-theme] .category-container,
body[data-mg-theme] .channel-card,
body[data-mg-theme] .content-card,
body[data-mg-theme] .modal-content,
body[data-mg-theme] .panel,
body[data-mg-theme] .movie-info-card {
  background-color:var(--mg-card) !important; color:var(--mg-copy) !important;
  border-color:var(--mg-line) !important; box-shadow:var(--mg-shadow);
}
body[data-mg-theme] h1, body[data-mg-theme] h2, body[data-mg-theme] h3,
body[data-mg-theme] .movie-title, body[data-mg-theme] .title,
body[data-mg-theme] .category-title, body[data-mg-theme] label { color:var(--mg-copy); }
body[data-mg-theme] p, body[data-mg-theme] .description,
body[data-mg-theme] .muted, body[data-mg-theme] .movie-description { color:var(--mg-muted); }
body[data-mg-theme] button:not(.mg-search-result),
body[data-mg-theme] input[type="submit"] {
  accent-color:var(--mg-accent);
}
body[data-mg-theme] .search-form button,
body[data-mg-theme] .header-search-button,
body[data-mg-theme] .mg-register-submit,
body[data-mg-theme] .donate-btn {
  background:linear-gradient(135deg,var(--mg-accent),var(--mg-accent-strong)) !important;
  color:#fff !important; border-color:transparent !important;
}
body[data-mg-theme] input:not([type="checkbox"]):not([type="radio"]),
body[data-mg-theme] select, body[data-mg-theme] textarea {
  border-color:var(--mg-line);
}
body[data-mg-theme] .site-footer { background:var(--mg-surface) !important; border-top:1px solid var(--mg-line); }
body[data-mg-theme] .site-footer a { color:var(--mg-copy) !important; }
body[data-mg-theme] .year, body[data-mg-theme] .movie-year { color:var(--mg-accent-strong) !important; }
body[data-mg-theme] .arrow, body[data-mg-theme] .back-to-top { background:var(--mg-card-raised) !important; color:var(--mg-copy) !important; border-color:var(--mg-line) !important; }

/* Keep light theme readable even on legacy pages with hard-coded white text. */
body[data-mg-theme="light"] { color:#171820 !important; }
body[data-mg-theme="light"] header nav a,
body[data-mg-theme="light"] .site-footer a,
body[data-mg-theme="light"] .site-footer p { color:#171820 !important; }
body[data-mg-theme="light"] .header-search-input,
body[data-mg-theme="light"] .mg-design-select,
body[data-mg-theme="light"] input:not([type="checkbox"]):not([type="radio"]),
body[data-mg-theme="light"] select, body[data-mg-theme="light"] textarea { background:#fff !important; color:#171820 !important; }
body[data-mg-theme="light"] .header-search-suggestions { background:#fff !important; border-color:rgba(0,0,0,.15) !important; }
body[data-mg-theme="light"] .mg-search-result-title,
body[data-mg-theme="light"] .mg-search-all,
body[data-mg-theme="light"] .mg-search-empty strong { color:#171820 !important; }
body[data-mg-theme="light"] .mg-search-result:hover,
body[data-mg-theme="light"] .mg-search-result.selected { background:#f2e9ea !important; }

/* TV / Android TV / set-top box profile: remote-friendly focus and larger hit targets. */
html[data-mg-device="tv"] body { font-size:18px; }
html[data-mg-device="tv"] header { padding:24px 3vw !important; }
html[data-mg-device="tv"] header h1 { font-size:clamp(30px,2.4vw,48px) !important; }
html[data-mg-device="tv"] nav { gap:14px !important; }
html[data-mg-device="tv"] nav a,
html[data-mg-device="tv"] .logout-button { padding:14px 20px !important; font-size:18px !important; }
html[data-mg-device="tv"] .mg-design-select { min-height:46px; font-size:16px; max-width:210px; }
html[data-mg-device="tv"] .header-search-wrapper { max-width:1100px !important; margin:24px auto !important; }
html[data-mg-device="tv"] .header-search-input,
html[data-mg-device="tv"] .header-search-button { height:64px !important; font-size:20px !important; }
html[data-mg-device="tv"] .mg-search-result { min-height:90px; padding:14px 18px; }
html[data-mg-device="tv"] .mg-search-poster-wrap { width:58px; height:82px; flex-basis:58px; }
html[data-mg-device="tv"] .mg-search-result-title { font-size:18px; }
html[data-mg-device="tv"] .mg-search-result-meta,
html[data-mg-device="tv"] .mg-search-result-overview { font-size:14px; }
html[data-mg-device="tv"] button, html[data-mg-device="tv"] a,
html[data-mg-device="tv"] select, html[data-mg-device="tv"] input { scroll-margin:120px; }
html[data-mg-device="tv"] :focus-visible {
  outline:4px solid var(--mg-accent) !important; outline-offset:4px !important;
  box-shadow:0 0 0 7px color-mix(in srgb,var(--mg-accent) 22%,transparent) !important;
}
html[data-mg-device="tv"] .movie, html[data-mg-device="tv"] .card { transition:transform .12s ease,border-color .12s ease; }
html[data-mg-device="tv"] a:focus-visible .card,
html[data-mg-device="tv"] .movie:focus-within .card { transform:scale(1.035); border-color:var(--mg-accent) !important; }

/* Phone / tablet layouts. CSS viewport detection is more reliable than UA strings. */
@media (max-width:700px) {
  .mg-appearance-controls { margin:8px auto 0; width:max-content; max-width:100%; }
  .mg-device-profile { display:none; }
  .mg-design-select { max-width:190px; }
  .header-search-wrapper { width:100%; }
  body[data-mg-theme] main, body[data-mg-theme] .container { max-width:100%; }
}
@media (min-width:701px) and (max-width:1100px) {
  header { padding-left:18px; padding-right:18px; }
  nav { gap:7px; }
  nav a { padding:9px 10px; }
  .mg-appearance-controls { margin:6px auto 0; }
}
@media (pointer:coarse) and (max-width:1100px) {
  button, select, input[type="submit"], .fav-btn, .arrow { min-height:42px; }
  nav a { min-height:42px; display:inline-flex; align-items:center; }
}
@media (prefers-reduced-motion:reduce) {
  *, *::before, *::after { scroll-behavior:auto !important; animation-duration:.01ms !important; transition-duration:.01ms !important; }
}


/* Universal layout finishing layer: preserve existing structure, unify surfaces. */
body[data-mg-theme] {
  min-width: 320px;
  overflow-x: hidden;
}
body[data-mg-theme] main,
body[data-mg-theme] .main-content,
body[data-mg-theme] .container,
body[data-mg-theme] .content,
body[data-mg-theme] .page-container {
  color: var(--mg-copy);
}
body[data-mg-theme] input,
body[data-mg-theme] select,
body[data-mg-theme] textarea {
  color: var(--mg-copy);
  background-color: var(--mg-card);
  border-radius: 9px;
}
body[data-mg-theme] .movie-card,
body[data-mg-theme] .movie-item,
body[data-mg-theme] .card,
body[data-mg-theme] .channel-card,
body[data-mg-theme] .content-card {
  border-radius: var(--mg-radius);
  overflow: hidden;
}
body[data-mg-theme] a,
body[data-mg-theme] button,
body[data-mg-theme] input,
body[data-mg-theme] select {
  -webkit-tap-highlight-color: transparent;
}
body[data-mg-theme] :focus-visible {
  outline: 2px solid var(--mg-accent);
  outline-offset: 3px;
}
body[data-mg-theme="light"] .mg-search-panel-head,
body[data-mg-theme="light"] .mg-search-panel-foot,
body[data-mg-theme="light"] .mg-search-result-meta,
body[data-mg-theme="light"] .mg-search-result-overview {
  color: var(--mg-muted) !important;
}
body[data-mg-theme="light"] .mg-search-result-title,
body[data-mg-theme="light"] .mg-search-all strong {
  color: var(--mg-copy) !important;
}

/* All display classes use the same layout; only density and navigation targets change. */
html[data-mg-device="phone"] .mg-appearance-controls {
  flex-wrap: wrap;
  margin: 8px auto;
}
html[data-mg-device="phone"] .mg-device-profile { display: none; }
html[data-mg-device="phone"] .mg-design-select { max-width: 100%; }
html[data-mg-device="tablet"] .mg-appearance-controls {
  margin: 8px auto;
}
html[data-mg-device="tv"] .mg-appearance-controls {
  padding: 9px 12px;
  gap: 12px;
  border-radius: 12px;
}
html[data-mg-device="tv"] .mg-appearance-label {
  font-size: 12px;
}
html[data-mg-device="tv"] .mg-design-select {
  min-height: 52px;
  min-width: 190px;
  max-width: 260px;
  padding: 10px 36px 10px 13px;
  font-size: 18px;
}
html[data-mg-device="tv"] .mg-device-profile {
  font-size: 13px;
}
html[data-mg-device="tv"] button,
html[data-mg-device="tv"] a,
html[data-mg-device="tv"] select,
html[data-mg-device="tv"] input {
  min-height: 48px;
}
html[data-mg-device="tv"] .mg-appearance-controls,
html[data-mg-device="tv"] .header-search-wrapper,
html[data-mg-device="tv"] .header-search-suggestions {
  scroll-margin-top: 100px;
}
@media (max-width: 480px) {
  .mg-appearance-controls {
    max-width: calc(100% - 16px);
  }
  .mg-appearance-label { font-size: 9px; }
  .mg-design-select { max-width: min(58vw, 210px); }
  .header-search-wrapper { max-width: 100%; }
}
@media (min-width: 1600px) {
  body[data-mg-theme] main,
  body[data-mg-theme] .container,
  body[data-mg-theme] .page-container {
    max-width: 1560px;
    margin-left: auto;
    margin-right: auto;
  }
}


/* Profile entry point replaces the old always-visible header theme dropdown. */
.mg-profile-link {
  display:inline-flex; align-items:center; gap:9px; min-height:42px;
  padding:4px 10px 4px 5px; border:1px solid var(--mg-line);
  border-radius:999px; background:var(--mg-card); color:var(--mg-copy) !important;
  text-decoration:none; transition:border-color .15s ease,background .15s ease;
}
.mg-profile-link:hover,.mg-profile-link:focus-visible {
  border-color:var(--mg-accent); background:var(--mg-accent-soft);
}
.mg-profile-link .user-avatar {
  display:block; width:34px; height:34px; min-width:34px; margin:0;
  object-fit:cover; border-radius:50%; border:2px solid var(--mg-accent);
}
.mg-profile-link .username { color:var(--mg-copy) !important; font-weight:750; }
@media(max-width:600px) {
  .mg-profile-link { min-height:40px; padding-right:8px; gap:6px; }
  .mg-profile-link .user-avatar { width:31px; height:31px; min-width:31px; }
}
html[data-mg-device="tv"] .mg-profile-link { min-height:54px; padding:6px 14px 6px 7px; gap:12px; }
html[data-mg-device="tv"] .mg-profile-link .user-avatar { width:44px; height:44px; min-width:44px; }
