/* ========================================
   Tamil Cinema Tracker - Global Styles
   File: assets/style.css
   ======================================== */

/* Base & Typography */
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans Tamil', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.font-tamil {
  font-family: 'Noto Sans Tamil', system-ui, sans-serif;
}

/* Utility Classes */
.poster-aspect {
  aspect-ratio: 2/3;
  width: 100%;
}

.line-clamp-1 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Cinema Theme Colors */
.bg-cinema-900 { background-color: #0a0a0f; }
.bg-cinema-800 { background-color: #12121a; }
.bg-cinema-700 { background-color: #1e1e2e; }
.bg-cinema-600 { background-color: #2a2a3a; }
.border-cinema-700 { border-color: #1e1e2e; }
.border-cinema-600 { border-color: #2a2a3a; }
.text-cinema-gray { color: #94a3b8; }

/* ========================================
   Film Card Component (CONSOLIDATED)
   ======================================== */
/* Film Card - Flex container for poster + info */
.watchlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

/* Card wrapper (replaces <a> film-card) */
.film-card {
  display: flex;
  flex-direction: column;
  background-color: #1e1e2e;
  border-radius: 0.75rem;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  height: 100%;
  position: relative;
}

.film-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

/* Poster container */
/* Poster Container */
.poster-area {
  position: relative;
  width: 100%;
  aspect-ratio: 2/3;
  background: #12121a;
  overflow: hidden; /* 🔑 Critical: Clips the zoomed image cleanly */
}

/* Poster Image + Hover Animation */
.poster-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94); /* Smooth cinematic ease */
}

.poster-area:hover .poster-img {
  transform: scale(1.08); /* Gentle zoom on hover */
}

/* ✅ Ensure edit button stays sharp and clickable */
.admin-edit-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  background: rgba(18, 18, 26, 0.95);
  color: white;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 14px;
  text-decoration: none;
  border: 1px solid #2a2a3a;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
}

.admin-edit-btn:hover {
  background: #dc2626; /* Red highlight on hover */
  transform: scale(1.1);
}

/* Info section */
.film-info {
  padding: 0.75rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-height: 70px;
}

.film-title {
  font-weight: 500;
  font-size: 0.875rem;
  color: #f1f5f9;
  margin: 0;
  line-height: 1.3;
}

.film-title-en {
  font-size: 0.75rem;
  color: #94a3b8;
  margin: 0;
  line-height: 1.2;
}

.film-meta {
  font-size: 0.75rem;
  color: #64748b;
  margin: 0;
}

.film-rating {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: auto;
  font-size: 0.75rem;
  color: #fbbf24;
  font-weight: 600;
  padding-top: 0.5rem;
}
/* ========================================
   Star Rating Component
   ======================================== */
.star-rating {
  display: inline-flex;
  gap: 4px;
  direction: ltr;
  user-select: none;
}

.star-rating label {
  cursor: pointer;
  position: relative;
  display: inline-block;
  padding: 2px;
}

.star-rating input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.star-rating .star {
  font-size: 1.5rem;
  color: #4b5563;
  transition: color 0.15s ease, transform 0.1s ease;
  display: inline-block;
  line-height: 1;
}

.star-rating .star.filled {
  color: #fbbf24;
}

.star-rating .star.half {
  position: relative;
  color: #4b5563;
}

.star-rating .star.half::before {
  content: "★";
  position: absolute;
  left: 0;
  top: 0;
  width: 50%;
  overflow: hidden;
  color: #fbbf24;
  z-index: 1;
}

.rating-display {
  font-weight: 600;
  color: #fbbf24;
  margin-left: 8px;
  font-size: 0.875rem;
  min-width: 40px;
  text-align: left;
}

.star-rating.sm .star {
  font-size: 1.25rem;
}

/* ========================================
   Header & Navigation
   ======================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: rgba(18, 18, 26, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #1e1e2e;
}

.site-header .nav-link { color: #cbd5e1; transition: color 0.15s ease; }
.site-header .nav-link:hover { color: #f1f5f9; }
.site-header .btn-login { background-color: #1e1e2e; transition: background-color 0.15s ease; }
.site-header .btn-login:hover { background-color: #2a2a3a; }
.site-header .btn-register { background-color: #dc2626; transition: background-color 0.15s ease; }
.site-header .btn-register:hover { background-color: #b91c1c; }

/* ========================================
   Film Detail Page
   ======================================== */
.film-header {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  margin-bottom: 2.5rem;
}
@media (min-width: 768px) { .film-header { flex-direction: row; } }

.film-poster-large { width: 100%; max-width: 16rem; flex-shrink: 0; }
.film-poster-large .poster-aspect { border-radius: 0.75rem; overflow: hidden; box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4); }
.film-details { flex: 1; }

.film-title-main { font-size: 1.875rem; font-weight: 700; margin-bottom: 0.25rem; line-height: 1.2; }
.film-title-en-main { font-size: 1.25rem; color: #94a3b8; margin-bottom: 1rem; }

.film-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem 1.5rem;
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}
.film-meta-grid .label { color: #64748b; }
.film-meta-grid .value { color: #e2e8f0; }

.film-overview { color: #cbd5e1; line-height: 1.6; margin-bottom: 1.5rem; }

.rating-summary {
  display: flex; flex-wrap: wrap; align-items: center; gap: 1rem;
  background-color: #1e1e2e; border-radius: 0.75rem; padding: 1rem; border: 1px solid #1e1e2e;
}
.rating-summary .stat { text-align: center; }
.rating-summary .stat-value { font-size: 1.875rem; font-weight: 700; color: #fbbf24; line-height: 1; }
.rating-summary .stat-label { font-size: 0.75rem; color: #64748b; }
.rating-summary .divider { width: 1px; height: 2.5rem; background-color: #2a2a3a; }
.rating-summary .tmdb-badge { text-align: center; }
.rating-summary .tmdb-value { font-size: 1.25rem; font-weight: 600; color: #e2e8f0; }
.rating-summary .tmdb-label { font-size: 0.75rem; color: #64748b; }

.btn-watchlist { margin-left: auto; }
.btn-watchlist.add { background-color: #1e1e2e; transition: background-color 0.15s ease; }
.btn-watchlist.add:hover { background-color: #2a2a3a; }
.btn-watchlist.in { background-color: #16a34a; transition: background-color 0.15s ease; }
.btn-watchlist.in:hover { background-color: #15803d; }

/* ========================================
   Forms & Sections
   ======================================== */
.rating-section, .comment-form {
  margin-bottom: 2.5rem; background-color: #1e1e2e; border-radius: 0.75rem; padding: 1.25rem; border: 1px solid #1e1e2e;
}
.rating-section-title, .songs-section-title, .comments-section-title {
  font-size: 1.125rem; font-weight: 600; margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem;
}
.rating-form .form-group, .comment-form textarea { margin-bottom: 1rem; }
.rating-form textarea, .comment-form textarea {
  width: 100%; background-color: #1e1e2e; border: 1px solid #2a2a3a; border-radius: 0.5rem;
  padding: 0.75rem 1rem; font-size: 0.875rem; color: #f1f5f9; resize: vertical; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.rating-form textarea:focus, .comment-form textarea:focus {
  outline: none; border-color: #dc2626; box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2);
}
.comment-form .form-actions { display: flex; align-items: center; justify-content: space-between; }
.spoiler-toggle { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; color: #cbd5e1; cursor: pointer; }

/* Songs */
.songs-list { background-color: #1e1e2e; border-radius: 0.75rem; border: 1px solid #1e1e2e; }
.song-item { padding: 1rem; display: flex; flex-direction: column; gap: 1rem; border-bottom: 1px solid #1e1e2e; }
.song-item:last-child { border-bottom: none; }
@media (min-width: 640px) { .song-item { flex-direction: row; align-items: center; justify-content: space-between; } }
.song-title { font-weight: 500; color: #f1f5f9; }
.song-meta { font-size: 0.75rem; color: #94a3b8; margin-top: 0.25rem; }
.song-rating { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }
.song-rating .avg { font-size: 0.875rem; color: #94a3b8; }

/* Comments */
.comment-list { display: flex; flex-direction: column; gap: 1rem; }
.comment-item { background-color: #1e1e2e; border-radius: 0.5rem; padding: 1rem; border: 1px solid #1e1e2e; }
.comment-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 0.5rem; }
.comment-author { font-size: 0.875rem; color: #94a3b8; }
.comment-spoiler-toggle { font-size: 0.75rem; color: #f87171; background: none; border: none; cursor: pointer; transition: color 0.15s ease; }
.comment-spoiler-toggle:hover { color: #fca5a5; }
.comment-body { color: #e2e8f0; line-height: 1.5; }
.comment-body.spoiler-blur { filter: blur(4px); user-select: none; cursor: pointer; }
.comment-body.spoiler-blur:hover { filter: blur(2px); }
.comment-spoiler-hint { font-size: 0.75rem; color: #64748b; font-style: italic; margin-top: 0.5rem; }

/* Empty States */
.empty-state { text-align: center; padding: 3rem 1rem; color: #64748b; }
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; display: block; }
.empty-state .title { font-size: 1.125rem; font-weight: 600; color: #cbd5e1; margin-bottom: 0.5rem; }

/* ========================================
   Watchlist & Auth Modal
   ======================================== */
.watchlist-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem;
}
@media (min-width: 640px) { .watchlist-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 768px) { .watchlist-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1024px) { .watchlist-grid { grid-template-columns: repeat(5, 1fr); } }

.auth-modal {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background-color: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px);
}
.auth-modal-content {
  background-color: #12121a; border-radius: 0.75rem; padding: 1.5rem; border: 1px solid #1e1e2e;
  width: 100%; max-width: 24rem; margin: 1rem; text-align: center; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}
.auth-modal-title { font-size: 1.125rem; font-weight: 600; margin-bottom: 0.5rem; }
.auth-modal-desc { color: #94a3b8; font-size: 0.875rem; margin-bottom: 1.25rem; }
.auth-modal-actions { display: flex; gap: 0.75rem; margin-bottom: 0.75rem; }
.auth-modal-actions .btn { flex: 1; padding: 0.625rem; border-radius: 0.5rem; font-size: 0.875rem; font-weight: 500; transition: background-color 0.15s ease; text-decoration: none; display: inline-block; }
.auth-modal-actions .btn-login { background-color: #1e1e2e; color: #f1f5f9; }
.auth-modal-actions .btn-login:hover { background-color: #2a2a3a; }
.auth-modal-actions .btn-register { background-color: #dc2626; color: white; }
.auth-modal-actions .btn-register:hover { background-color: #b91c1c; }
.auth-modal-cancel { font-size: 0.75rem; color: #64748b; background: none; border: none; cursor: pointer; transition: color 0.15s ease; }
.auth-modal-cancel:hover { color: #94a3b8; }

/* ========================================
   Global UI Elements
   ======================================== */
.site-footer { border-top: 1px solid #1e1e2e; padding: 1.5rem 0; text-align: center; color: #64748b; font-size: 0.875rem; margin-top: 3rem; }
[x-cloak] { display: none !important; }

input[type="text"], input[type="email"], input[type="password"], input[type="search"], textarea, select {
  background-color: #1e1e2e; border: 1px solid #2a2a3a; border-radius: 0.5rem; padding: 0.5rem 0.75rem;
  font-size: 0.875rem; color: #f1f5f9; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: #dc2626; box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2); }
::placeholder { color: #64748b; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.5rem 1rem; border-radius: 0.5rem; font-size: 0.875rem; font-weight: 500; transition: background-color 0.15s ease, transform 0.1s ease; cursor: pointer; text-decoration: none; border: none; }
.btn:active { transform: scale(0.98); }
.btn-primary { background-color: #dc2626; color: white; }
.btn-primary:hover { background-color: #b91c1c; }
.btn-secondary { background-color: #1e1e2e; color: #f1f5f9; }
.btn-secondary:hover { background-color: #2a2a3a; }
.btn-ghost { background-color: transparent; color: #cbd5e1; }
.btn-ghost:hover { color: #f1f5f9; background-color: rgba(255, 255, 255, 0.05); }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

@media (max-width: 639px) { .hide-mobile { display: none; } }
@media (min-width: 640px) { .hide-desktop { display: none; } }

@media print {
  .no-print { display: none !important; }
  body { background: white; color: black; font-size: 12pt; }
  .film-poster-large .poster-aspect { box-shadow: none; }
}


/* Cast Section Styles */
.cast-scroll-container {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.75rem;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  scrollbar-color: #2a2a3a transparent;
}

.cast-scroll-container::-webkit-scrollbar { height: 6px; }
.cast-scroll-container::-webkit-scrollbar-track { background: transparent; }
.cast-scroll-container::-webkit-scrollbar-thumb { background: #2a2a3a; border-radius: 3px; }

.cast-card {
  min-width: 110px;
  width: 110px;
  flex-shrink: 0;
  scroll-snap-align: start;
  background-color: #1e1e2e;
  border: 1px solid #1e1e2e;
  border-radius: 0.75rem;
  padding: 0.75rem;
  text-align: center;
  transition: border-color 0.2s ease, transform 0.2s ease;
  text-decoration: none;
  color: inherit;
}

.cast-card:hover {
  border-color: #dc2626;
  transform: translateY(-2px);
}

.cast-avatar {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  overflow: hidden;
  background: #2a2a3a;
  margin: 0 auto 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: #64748b;
}

.cast-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cast-avatar .fallback { display: none; }
.cast-avatar img.hidden { display: none; }
.cast-avatar img.hidden + .fallback { display: flex; }

.cast-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.15rem;
}

.cast-char {
  font-size: 0.7rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== CAST STRIP - BULLETPROOF VERSION ===== */
.cast-strip {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding: 0.75rem 0;
  margin-bottom: 1.5rem;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.cast-strip::-webkit-scrollbar { display: none; }

.cast-avatar-square {
  width: 80px;
  height: 80px;
  border-radius: 0.5rem;
  flex-shrink: 0;
  background: #2a2a3a;
  border: 2px solid transparent;
  transition: border-color 0.2s ease, transform 0.2s ease;
  cursor: pointer;
}
.cast-avatar-square:hover {
  border-color: #dc2626;
  transform: scale(1.05);
}
.cast-avatar-square img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.cast-avatar-square .fallback {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 2rem; color: #64748b;
}

/* ===== CAST STRIP ===== */
.cast-section { position: relative; }

.cast-strip {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding: 0.5rem 0 1.5rem; /* Extra bottom padding for tooltip */
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.cast-strip::-webkit-scrollbar { display: none; }

.cast-avatar {
  width: 80px;
  height: 80px;
  border-radius: 0.5rem;
  flex-shrink: 0;
  background: #2a2a3a;
  border: 2px solid transparent;
  transition: border-color 0.2s ease, transform 0.2s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.cast-avatar:hover {
  border-color: #dc2626;
  transform: scale(1.05);
}
.cast-avatar img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.cast-avatar .fallback {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 2rem; color: #64748b;
}

/* ===== TOOLTIP - Fixed Position, Viewport-Relative ===== */
.cast-tooltip {
  position: fixed; /* ← Viewport-relative, ignores all parent overflow */
  left: 0; 
  top: 0;
  background: #1e1e2e;
  border: 1px solid #374151;
  border-radius: 0.5rem;
  padding: 0.6rem 0.9rem;
  min-width: 170px;
  max-width: 220px;
  text-align: center;
  z-index: 10000;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
  /* NO display:none here - JS controls visibility */
}

.cast-tooltip-name {
  display: block;
  font-weight: 700;
  font-size: 0.95rem;
  color: #ffffff;
  margin-bottom: 0.15rem;
  line-height: 1.25;
}

.cast-tooltip-role {
  display: block;
  font-size: 0.8rem;
  color: #94a3b8;
  font-style: italic;
  line-height: 1.2;
}

.cast-tooltip-arrow {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -6px; /* Points UP to avatar */
  border: 6px solid transparent;
  border-bottom: 6px solid #374151;
}