/* ============================================================ КиноЛента */
:root {
  --bg: #0e1116;
  --bg-soft: #12151c;
  --card: #171b23;
  --border: #232936;
  --text: #e8ebf1;
  --text-dim: #9aa3b2;
  --accent: #ff4d2e;
  --accent-soft: rgba(255, 77, 46, .14);
  --ok-bg: rgba(46, 180, 110, .15);
  --err-bg: rgba(230, 70, 70, .15);
}

[data-theme="light"] {
  --bg: #f4f5f8;
  --bg-soft: #ffffff;
  --card: #ffffff;
  --border: #dfe3ea;
  --text: #1c2230;
  --text-dim: #5b6472;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
.meta { color: var(--text-dim); font-size: 13px; margin: 4px 0 0; }

/* ------------------------------- layout ------------------------------ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  flex: 0 0 250px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
}

.page { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 26px 28px 48px; flex: 1; }

/* ------------------------------- sidebar ----------------------------- */
.side-head { padding: 20px 18px 14px; border-bottom: 1px solid var(--border); }
.brand-name { font-size: 21px; font-weight: 800; letter-spacing: .3px; display: block; }
.tagline { color: var(--text-dim); font-size: 12.5px; display: block; margin-top: 2px; }

.side-nav { padding: 14px 12px; flex: 1; }

.side-link, .side-group-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  color: var(--text);
  font: inherit;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.side-link:hover, .side-group-btn:hover { background: rgba(127, 140, 165, .12); }

.side-group { margin-top: 6px; }
.side-group-btn { display: flex; justify-content: space-between; align-items: center; font-weight: 600; color: var(--text-dim); text-transform: uppercase; font-size: 13px; letter-spacing: .4px; }

.caret { transition: transform .2s ease; font-size: 11px; }
.side-group.open > .side-group-btn .caret { transform: rotate(90deg); }
.side-sub { display: none; margin: 4px 0 8px 10px; padding-left: 10px; border-left: 1px solid var(--border); }
.side-group.open > .side-sub { display: block; }

.side-sub a {
  display: block;
  padding: 6px 12px;
  border-radius: 7px;
  color: var(--text-dim);
}
.side-sub a:hover, .side-sub a.active { background: var(--accent-soft); color: var(--text); }

.side-genres summary { cursor: pointer; padding: 6px 12px; border-radius: 7px; list-style: none; position: relative; padding-left: 24px; }
.side-genres summary::before { content: "\25B8"; position: absolute; left: 10px; transition: transform .2s ease; font-size: 11px; top: 7px; }
.side-genres[open] > summary::before { transform: rotate(90deg); }
.genre-list a { padding: 4px 12px 4px 26px; font-size: 13.5px; }

.side-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  position: relative;
}

.lang-switch a {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
  padding: 4px 8px;
  border-radius: 6px;
}
.lang-switch a.active { background: var(--accent-soft); color: var(--accent); }

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 34px; height: 34px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
}
.icon-btn:hover { background: rgba(127, 140, 165, .12); color: var(--text); }

.admin-dropdown {
  position: absolute;
  bottom: 58px;
  left: 16px;
  min-width: 190px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .45);
  padding: 6px;
  z-index: 40;
}
.dd-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  color: var(--text);
  font: inherit;
  padding: 8px 12px;
  border-radius: 7px;
  cursor: pointer;
}
.dd-item:hover { background: rgba(127, 140, 165, .12); }
.dd-logout { color: var(--accent); }

/* topbar (mobile only) */
.topbar { display: none; }

/* ------------------------------- hero -------------------------------- */
.hero { position: relative; border-radius: 14px; overflow: hidden; margin-bottom: 30px; min-height: 360px; display: flex; align-items: flex-end; background: var(--card); }
.hero-bg { position: absolute; inset: 0; background-size: cover; background-position: center; transition: opacity .4s ease; }
.hero-bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(10, 12, 16, .92) 8%, rgba(10, 12, 16, .5) 55%, rgba(10, 12, 16, .35)); }
.hero-content { position: relative; padding: 34px 38px; max-width: 720px; }
.kicker { color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; font-size: 12.5px; margin: 0 0 8px; }
.hero-content h1 { font-size: clamp(26px, 4vw, 44px); margin-bottom: 6px; color: #fff; text-shadow: 0 2px 14px rgba(0,0,0,.5); }
.hero-content .meta { color: #c7cdd8; }

/* ------------------------------- grid -------------------------------- */
.page-title { font-size: 24px; margin-bottom: 18px; }
.genre-clear { color: var(--accent); }
.genre-clear:hover { text-decoration: underline; }

.film-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; }

.card { background: var(--card); border-radius: 12px; overflow: hidden; border: 1px solid transparent; transition: transform .15s ease, border-color .15s ease; display: block; }
.card:hover { transform: translateY(-3px); border-color: var(--border); }

.poster { position: relative; aspect-ratio: 16 / 9; background: linear-gradient(135deg, #2a3040, #171b23); overflow: hidden; }
[data-theme="light"] .poster { background: linear-gradient(135deg, #c8cfdd, #eef0f4); }
.poster img { width: 100%; height: 100%; object-fit: cover; }

/* poster fallback (no image yet): big initial on the gradient */
.poster.noimg::after {
  content: attr(data-initial);
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 52px; font-weight: 800; color: rgba(255, 255, 255, .35);
}

.card-body { padding: 12px 14px 14px; }
.card-body h3 { font-size: 15px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pager { text-align: center; margin-top: 30px; }

/* ------------------------------- film -------------------------------- */
.film { max-width: 860px; }
.film-trailer { border-radius: 12px; overflow: hidden; background: #000; margin-bottom: 22px; }
.film-trailer video { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: contain; background: #000; }
.trailer-missing {
  aspect-ratio: 16 / 9;
  border: 2px dashed var(--border);
  display: flex; align-items: center; justify-content: center; gap: 14px;
  color: var(--text-dim); font-size: 18px; background: transparent;
}
.film-title { font-size: clamp(24px, 3.4vw, 36px); }
.film-desc { max-width: 70ch; margin-top: 10px; color: var(--text-dim); font-size: 15.5px; }

/* ------------------------------- buttons ----------------------------- */
.btn {
  display: inline-block;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 18px;
  border-radius: 9px;
  font: inherit;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { padding: 12px 24px; font-size: 15.5px; }
.btn.small { padding: 4px 10px; font-size: 13px; border-radius: 7px; }
.btn.danger { color: #e64646; border-color: rgba(230, 70, 70, .5); }

/* ------------------------------- news -------------------------------- */
.news-list { display: grid; gap: 18px; max-width: 860px; }
.news-item { background: var(--card); border-radius: 12px; padding: 20px 24px; border: 1px solid var(--border); }
.news-item h2 { font-size: 19px; margin-bottom: 6px; }
.news-item p:last-child { color: var(--text-dim); margin: 0; }

/* ------------------------------- about / misc ------------------------ */
.lead { max-width: 74ch; color: var(--text-dim); font-size: 16px; }
.center-block { display: flex; justify-content: center; padding-top: 8vh; }
.login-card, .uc-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 30px 34px; width: min(420px, 92vw); text-align: center; }
.login-form label, .user-add-form label { display: block; text-align: left; margin-top: 14px; font-size: 14px; color: var(--text-dim); }
.login-form input, .user-add-form input { width: 100%; margin-top: 6px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; }
.uc-body { text-align: center; padding-top: 14vh; }

/* ------------------------------- admin -------------------------------- */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px 22px; margin-bottom: 18px; max-width: 640px; }
.status-line { color: var(--text-dim); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(5, 7, 10, .66); display: flex; align-items: center; justify-content: center; z-index: 90; padding: 20px; }
.modal-backdrop[hidden] { display: none; }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: 14px; width: min(560px, 100%); max-height: 88vh; overflow-y: auto; padding: 22px 26px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-close { background: none; border: 0; color: var(--text-dim); font-size: 24px; cursor: pointer; line-height: 1; }
.modal-subhead { margin-top: 26px; }

.user-list { list-style: none; padding: 0; margin: 0 0 8px; }
.user-list li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.uname { font-weight: 600; }
.inline-form { display: inline; margin: 0; }

/* ------------------------------- flashes / footer -------------------- */
.flash-wrap { max-width: 1280px; width: calc(100% - 56px); margin: 14px auto 0; }
.flash { padding: 10px 16px; border-radius: 9px; font-size: 14px; margin-bottom: 8px; }
.flash.ok, .flash.success { background: var(--ok-bg); color: #7fe0ae; }
.flash.error, .flash.danger { background: var(--err-bg); color: #ff9c9c; }

.site-footer { border-top: 1px solid var(--border); padding: 16px 28px; color: var(--text-dim); font-size: 13px; text-align: center; }

/* ------------------------------- mobile ------------------------------ */
@media (max-width: 940px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 80;
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, .5);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }

  .topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-soft);
    position: sticky; top: 0; z-index: 30;
  }
  .topbar-brand { font-size: 18px; }

  .container { padding: 20px 16px 40px; }
  .hero { min-height: 290px; }
  .hero-content { padding: 24px; }
  .film-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }

  /* backdrop behind the open sidebar */
  body.sidebar-open::before {
    content: "";
    position: fixed; inset: 0;
    background: rgba(5, 7, 10, .6);
    z-index: 70;
  }
}
