/* ============================================================
   Media Tracker — glassmorphic theme
   ============================================================ */

:root {
  --bg-1: #0b0d16;
  --bg-2: #131627;
  --glass: rgba(255, 255, 255, 0.055);
  --glass-strong: rgba(255, 255, 255, 0.09);
  --glass-border: rgba(255, 255, 255, 0.12);
  --text: #eef0f6;
  --text-dim: #a3a9bd;
  --accent: #7c9cff;
  --accent-2: #b98cff;
  --accent-3: #52e0c4;
  --accent-soft: rgba(124, 156, 255, 0.16);
  --green: #4ee6a3;
  --red: #ff7a86;
  --amber: #ffc069;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-glass: 0 8px 32px rgba(0,0,0,0.45);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: radial-gradient(circle at 15% 0%, #171b33 0%, var(--bg-1) 55%), var(--bg-1);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
  min-height: 100vh;
  position: relative;
}
a { color: var(--accent); text-decoration: none; transition: color 0.15s ease; }
a:hover { color: var(--accent-2); }
img { max-width: 100%; display: block; }

/* ---------- Animated background orbs ---------- */
.bg-orbs, .login-bg {
  position: fixed; inset: 0; overflow: hidden; z-index: 0; pointer-events: none;
}
.orb {
  position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.35;
  animation: float 18s ease-in-out infinite;
}
.orb-1 { width: 420px; height: 420px; background: var(--accent); top: -120px; left: -80px; animation-duration: 22s; }
.orb-2 { width: 380px; height: 380px; background: var(--accent-2); bottom: -140px; right: -100px; animation-duration: 26s; animation-delay: -6s; }
.orb-3 { width: 300px; height: 300px; background: var(--accent-3); top: 40%; left: 60%; animation-duration: 20s; animation-delay: -3s; opacity: 0.22; }

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(40px, -30px) scale(1.08); }
  66% { transform: translate(-30px, 25px) scale(0.95); }
}

/* ---------- Glass surfaces ---------- */
.glass {
  background: var(--glass);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-glass);
}

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; position: relative; z-index: 1; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  border-radius: 0 22px 22px 0;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  animation: slideInLeft 0.5s ease;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; }
.brand-icon { font-size: 22px; filter: drop-shadow(0 0 10px rgba(124,156,255,0.6)); }
.brand-name {
  font-weight: 800; font-size: 16px; letter-spacing: 0.2px;
  background: linear-gradient(90deg, #fff, var(--accent) 120%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.side-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.side-nav a {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-dim);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 13.5px;
  position: relative;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.side-nav a .ic { font-size: 15px; width: 18px; text-align: center; }
.side-nav a:hover { background: rgba(255,255,255,0.06); color: var(--text); transform: translateX(2px); }
.side-nav a.active {
  background: linear-gradient(90deg, var(--accent-soft), transparent);
  color: var(--accent);
  box-shadow: inset 2px 0 0 var(--accent);
}

.side-nav-footer { padding-top: 14px; border-top: 1px solid var(--glass-border); display: flex; flex-direction: column; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-size: 13px; color: var(--text-dim); }
.user-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); flex-shrink: 0; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  margin: 18px 24px 0;
  padding: 18px 26px;
  border-radius: var(--radius);
  animation: fadeInDown 0.5s ease;
  display: flex; align-items: center; gap: 14px;
}
.topbar h1 { margin: 0; font-size: 21px; font-weight: 800; letter-spacing: -0.01em; }
.content { padding: 22px 32px 60px; animation: fadeIn 0.5s ease; }

/* ---------- Mobile hamburger + sidebar drawer ---------- */
.hamburger {
  display: none;
  flex-direction: column; justify-content: center; gap: 4px;
  width: 34px; height: 34px; padding: 0;
  background: transparent; border: 1px solid var(--glass-border);
  border-radius: 9px; cursor: pointer; flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.hamburger span { display: block; width: 16px; height: 2px; margin: 0 auto; background: var(--text); border-radius: 2px; transition: transform 0.25s ease, opacity 0.2s ease; }
.hamburger:hover { border-color: var(--accent); background: rgba(255,255,255,0.06); }
.hamburger:active { transform: scale(0.94); }
.hamburger.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 15;
  background: rgba(5, 6, 12, 0.55);
  backdrop-filter: blur(2px);
  opacity: 0; transition: opacity 0.25s ease;
}
.sidebar-overlay.show { display: block; opacity: 1; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInLeft { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: translateX(0); } }
@keyframes popIn { from { opacity: 0; transform: scale(0.96) translateY(6px); } to { opacity: 1; transform: scale(1) translateY(0); } }

/* ---------- Alerts ---------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-weight: 500;
  border: 1px solid transparent;
  animation: popIn 0.3s ease;
}
.alert-success { background: rgba(78,230,163,0.12); color: var(--green); border-color: rgba(78,230,163,0.3); }
.alert-error   { background: rgba(255,122,134,0.12); color: var(--red); border-color: rgba(255,122,134,0.3); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass);
  backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.btn:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(124,156,255,0.18); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn .ripple {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: rgba(255,255,255,0.5); transform: scale(0);
  animation: rippleAnim 0.55s ease-out; z-index: -1;
}
@keyframes rippleAnim { to { transform: scale(2.6); opacity: 0; } }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent; color: #0b0d16; font-weight: 700;
}
.btn-primary:hover { filter: brightness(1.1); color: #0b0d16; box-shadow: 0 6px 20px rgba(124,156,255,0.35); }
.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); box-shadow: 0 4px 14px rgba(255,122,134,0.18); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* ---------- Cards / grids ---------- */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.toolbar .search { flex: 1; max-width: 320px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 18px;
}
.card {
  background: var(--glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  animation: popIn 0.35s ease both;
}
.card:hover { border-color: rgba(124,156,255,0.5); transform: translateY(-4px); box-shadow: 0 12px 30px rgba(0,0,0,0.4), 0 0 0 1px rgba(124,156,255,0.15); }

/* Uniform image sizing: every thumbnail is a fixed-ratio box with object-fit: contain,
   so posters/logos/actor photos of any source dimensions render in full without cropping. */
.card-thumb {
  width: 100%; aspect-ratio: 2 / 3;
  background: rgba(255,255,255,0.04);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  color: var(--text-dim); font-size: 12px;
}
.card-thumb img { width: 100%; height: 100%; object-fit: contain; transition: transform 0.35s ease; }
.card:hover .card-thumb img { transform: scale(1.06); }

.card-body { padding: 12px 13px; }
.card-title { font-weight: 700; font-size: 13.5px; margin: 0 0 4px; }
.card-meta { color: var(--text-dim); font-size: 12px; }

.logo-thumb {
  width: 100%; aspect-ratio: 16 / 9;
  background: rgba(255,255,255,0.04);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.logo-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 14px; }

/* Actor cards - uniform square avatar-style thumb */
.actor-card .card-thumb { aspect-ratio: 1 / 1; }

/* ---------- Tables ---------- */
table.data-table { width: 100%; border-collapse: collapse; background: var(--glass); backdrop-filter: blur(16px); border-radius: var(--radius); overflow: hidden; }
.data-table th, .data-table td {
  padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--glass-border); font-size: 13px;
}
.data-table th { color: var(--text-dim); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: 0.04em; background: rgba(255,255,255,0.03); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.03); }
.table-wrap { border: 1px solid var(--glass-border); border-radius: var(--radius); overflow: hidden; backdrop-filter: blur(16px); animation: popIn 0.35s ease; }

/* Uniform thumbnail chips inside tables (avatars, mini posters) */
.data-table img.thumb-round { width: 34px; height: 34px; object-fit: cover; border-radius: 50%; border: 1px solid var(--glass-border); }

/* ---------- Forms ---------- */
.form-card {
  background: var(--glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 26px 28px;
  max-width: 780px;
  animation: popIn 0.35s ease;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.field .hint { font-size: 11.5px; color: var(--text-dim); opacity: 0.8; }
input[type=text], input[type=date], input[type=number], input[type=url], input[type=password], input[type=email],
select, textarea {
  background: rgba(255,255,255,0.045);
  border: 1px solid var(--glass-border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 13.5px;
  font-family: var(--font);
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); background: rgba(255,255,255,0.07);
  box-shadow: 0 0 0 3px rgba(124,156,255,0.15);
}
textarea { resize: vertical; min-height: 70px; }
.readonly-field {
  background: rgba(255,255,255,0.03);
  border: 1px dashed var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 13.5px;
  color: var(--accent-3);
  font-weight: 600;
}
fieldset { border: 1px solid var(--glass-border); border-radius: var(--radius); padding: 16px 18px; margin: 0 0 18px; }
legend { padding: 0 8px; font-weight: 700; font-size: 13px; color: var(--accent); }

.image-input-group {
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: rgba(255,255,255,0.03);
}
.image-input-group .current-preview { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.image-input-group .current-preview img {
  width: 56px; height: 56px; object-fit: contain; border-radius: 8px; border: 1px solid var(--glass-border);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.image-input-group .current-preview img:hover { transform: scale(1.8); box-shadow: 0 10px 30px rgba(0,0,0,0.5); z-index: 5; position: relative; }
.image-input-group .or-sep { font-size: 11px; color: var(--text-dim); text-align: center; margin: 8px 0; text-transform: uppercase; letter-spacing: 0.05em; }

/* Drag-and-drop dropzone wrapping each file input */
.dropzone {
  position: relative;
  border: 1.5px dashed var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 16px 12px;
  text-align: center;
  background: rgba(255,255,255,0.025);
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
  cursor: pointer;
}
.dropzone:hover { border-color: var(--accent); background: rgba(124,156,255,0.06); }
.dropzone.drag-over { border-color: var(--accent-3); background: rgba(82,224,196,0.1); transform: scale(1.01); }
.dropzone .dz-icon { font-size: 22px; margin-bottom: 4px; display: block; animation: none; }
.dropzone.drag-over .dz-icon { animation: bounce 0.6s ease infinite; }
.dropzone .dz-text { font-size: 12.5px; color: var(--text-dim); }
.dropzone .dz-text strong { color: var(--accent); font-weight: 600; }
.dropzone .dz-filename { font-size: 12px; color: var(--accent-3); font-weight: 600; margin-top: 6px; word-break: break-all; }
.dropzone input[type=file] {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer;
}
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

.form-actions { display: flex; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--glass-border); }

.repeat-block { border: 1px dashed var(--glass-border); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 10px; position: relative; background: rgba(255,255,255,0.03); animation: popIn 0.25s ease; }
.repeat-block .remove-btn { position: absolute; top: 8px; right: 8px; }

/* ---------- Stat cards (dashboard) ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--glass); backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border); border-radius: var(--radius); padding: 18px 20px;
  transition: transform 0.2s ease, box-shadow 0.2s ease; animation: popIn 0.35s ease both;
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(124,156,255,0.12), transparent 60%);
  opacity: 0; transition: opacity 0.2s ease;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(0,0,0,0.35); }
.stat-card:hover::before { opacity: 1; }
.stat-card .num {
  font-size: 30px; font-weight: 800; position: relative;
  background: linear-gradient(90deg, #fff, var(--accent-3));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat-card .label { color: var(--text-dim); font-size: 12.5px; margin-top: 4px; position: relative; }

.section-title { font-size: 15px; font-weight: 700; margin: 30px 0 14px; display: flex; align-items: center; justify-content: space-between; }
.section-title .see-all { font-size: 12.5px; font-weight: 600; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-green { background: rgba(78,230,163,0.15); color: var(--green); }
.badge-gray { background: rgba(163,169,189,0.15); color: var(--text-dim); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); border-radius: 20px; padding: 4px 10px 4px 4px; font-size: 12.5px; }
.chip img { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }

.detail-header { display: flex; gap: 22px; margin-bottom: 26px; flex-wrap: wrap; animation: popIn 0.4s ease; }

/* Uniform detail-page image boxes: fixed size box regardless of source image dimensions */
.detail-poster {
  width: 180px; height: 270px; flex-shrink: 0;
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--glass-border); background: rgba(255,255,255,0.04);
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
.detail-poster img { width: 100%; height: 100%; object-fit: contain; }
.detail-poster.square { width: 160px; height: 160px; }

.detail-info h2 { margin: 0 0 8px; font-size: 22px; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 12px 24px; margin-top: 14px; }
.kv-grid .kv label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-dim); margin-bottom: 2px; }
.kv-grid .kv .val { font-size: 14px; font-weight: 600; }

/* Uniform gallery: every image forced into the same 16:9 box */
.image-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px,1fr)); gap: 12px; }
.image-gallery img, .image-gallery > label img {
  width: 100%; aspect-ratio: 16 / 9; object-fit: contain;
  border-radius: var(--radius-sm); border: 1px solid var(--glass-border);
  transition: transform 0.2s ease;
}
.image-gallery img:hover { transform: scale(1.03); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-dim); animation: fadeIn 0.4s ease; }
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }

.text-dim { color: var(--text-dim); }
.mb-0 { margin-bottom: 0; }

/* ---------- Staggered card animation ---------- */
.grid .card:nth-child(1) { animation-delay: 0.02s; }
.grid .card:nth-child(2) { animation-delay: 0.06s; }
.grid .card:nth-child(3) { animation-delay: 0.10s; }
.grid .card:nth-child(4) { animation-delay: 0.14s; }
.grid .card:nth-child(5) { animation-delay: 0.18s; }
.grid .card:nth-child(6) { animation-delay: 0.22s; }
.grid .card:nth-child(n+7) { animation-delay: 0.24s; }

/* ============================================================
   Login page
   ============================================================ */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; overflow: hidden; }
.login-wrap { position: relative; z-index: 1; width: 100%; display: flex; justify-content: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 380px;
  border-radius: 22px;
  padding: 36px 32px;
  animation: popIn 0.5s ease;
}
.login-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 6px; }
.login-brand .brand-icon { font-size: 30px; }
.login-brand .brand-name { font-size: 20px; }
.login-sub { text-align: center; color: var(--text-dim); font-size: 13px; margin: 0 0 22px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form .btn { margin-top: 6px; padding: 11px; }
.login-hint { text-align: center; color: var(--text-dim); font-size: 11.5px; margin: 18px 0 0; }
.login-hint code { background: rgba(255,255,255,0.08); padding: 1px 6px; border-radius: 4px; }

@media (max-width: 900px) {
  .hamburger { display: flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 20;
    border-radius: 0 22px 22px 0;
    transform: translateX(-105%);
    transition: transform 0.3s cubic-bezier(.22,.9,.36,1);
    animation: none;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 60px rgba(0,0,0,0.55); }
  .content { padding: 16px 16px 50px; }
  .topbar { margin: 12px; padding: 14px 16px; }
  .topbar h1 { font-size: 17px; }
  .form-grid { grid-template-columns: 1fr; }
  .detail-header { gap: 16px; }
  .detail-poster { width: 130px; height: 195px; }
  .detail-poster.square { width: 120px; height: 120px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 12px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-card { padding: 18px 16px; max-width: 100%; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .search { max-width: none; }
  fieldset { padding: 12px; }
}

@media (max-width: 520px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 10px; }
  .data-table th, .data-table td { padding: 8px 10px; font-size: 12px; }
  .table-wrap { overflow-x: auto; }
  .data-table { min-width: 560px; }
  .detail-header { flex-direction: column; align-items: center; text-align: center; }
  .kv-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}