/* =========================
   THEME & RESETS
   ========================= */
   :root{
    /* Colors */
    --bg-1: #0f1024;
    --bg-2: #15162b;
    --bg-3: #1a1b32;
  
    --text: #ffffff;
    --text-muted: rgba(255,255,255,.78);
    --text-dim: rgba(255,255,255,.65);
  
    --brand-1: #667eea; /* indigo */
    --brand-2: #764ba2; /* purple */
    --brand-glow: 0 10px 24px rgba(102,126,234,.28);
  
    /* Surfaces */
    --surface: rgba(255,255,255,.05);
    --surface-strong: rgba(255,255,255,.08);
    --border: rgba(255,255,255,.12);
  
    /* Effects */
    --blur: 14px;
    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 22px;
    --shadow-1: 0 10px 24px rgba(0,0,0,.35);
    --shadow-2: 0 24px 48px rgba(0,0,0,.35);
  
    /* Typography & spacing */
    --step--1: clamp(.9rem, .85rem + .2vw, .98rem);
    --step-0: clamp(1rem, .95rem + .35vw, 1.05rem);
    --step-1: clamp(1.125rem, 1rem + .7vw, 1.25rem);
    --step-2: clamp(1.35rem, 1.1rem + 1.2vw, 1.6rem);
    --step-3: clamp(1.8rem, 1.4rem + 2vw, 2.4rem);
    --step-4: clamp(2.4rem, 1.8rem + 3vw, 3.2rem);
  
    --space-1: .5rem;
    --space-2: .75rem;
    --space-3: 1rem;
    --space-4: 1.25rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;
    --space-8: 4rem;
  }
  
  *,
  *::before,
  *::after { box-sizing: border-box; }
  
  html, body { height: 100%; }
  
  body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: radial-gradient(1200px 800px at 20% -10%, #1d1e3a 0%, transparent 60%),
                radial-gradient(1200px 800px at 100% 10%, #151636 0%, transparent 60%),
                linear-gradient(135deg, var(--bg-1) 0%, var(--bg-3) 100%);
    color: var(--text);
    min-height: 100vh;
    font-size: var(--step-0);
    line-height: 1.6;
    overflow-x: hidden;
    text-rendering: optimizeLegibility;
  }
  
  /* Containers */
  .container {
    max-width: 1280px;
    margin-inline: auto;
    padding-inline: 20px;
  }
  
  /* =========================
     HEADER
     ========================= */
  header {
    background: linear-gradient(135deg, rgba(255,255,255,.08) 0%, rgba(255,255,255,.04) 100%);
    backdrop-filter: blur(var(--blur));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: clamp(32px, 5vw, 64px) clamp(20px, 4vw, 40px);
    text-align: center;
    margin: var(--space-7) auto var(--space-6);
    box-shadow: var(--shadow-1);
    position: relative;
    overflow: clip;
  }
  
  header::before{
    content:'';
    position:absolute; inset:0;
    background: linear-gradient(90deg, transparent 30%, rgba(255,255,255,.06) 50%, transparent 70%);
    transform: translateX(-100%);
    animation: shimmer 4s ease-in-out infinite;
  }
  
  @keyframes shimmer {
    0%, 100% { transform: translateX(-100%); }
    50% { transform: translateX(100%); }
  }
  
  header h1{
    font-size: var(--step-4);
    font-weight: 800;
    background: linear-gradient(135deg, var(--brand-1) 0%, var(--brand-2) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: var(--space-4);
    position: relative;
    z-index: 1;
  }
  
  /* =========================
     FORM
     ========================= */
  #movieForm{
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    position: relative;
    z-index: 1;
  }
  
  .input-wrapper{
    width: 100%;
    max-width: 680px;
    position: relative;
  }
  
  #movieInput{
    width: 100%;
    padding: 18px 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--step-0);
    background: rgba(255,255,255,.06);
    color: var(--text);
    backdrop-filter: blur(10px);
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
    outline: none;
  }
  
  #movieInput::placeholder{ color: var(--text-dim); }
  
  #movieInput:focus-visible{
    border-color: var(--brand-1);
    box-shadow: 0 0 0 4px rgba(102,126,234,.18);
    background: rgba(255,255,255,.08);
  }
  
  #movieForm button{
    padding: 14px 28px;
    background: linear-gradient(135deg, var(--brand-1) 0%, var(--brand-2) 100%);
    border: none;
    color: white;
    font-size: var(--step-0);
    font-weight: 700;
    border-radius: var(--radius);
    cursor: pointer;
    transition: transform .15s ease, box-shadow .2s ease, filter .2s ease;
    box-shadow: var(--brand-glow);
  }
  
  @media (hover:hover){
    #movieForm button:hover{
      transform: translateY(-2px);
      box-shadow: 0 14px 28px rgba(102,126,234,.35);
      filter: brightness(1.02);
    }
  }
  #movieForm button:active{ transform: translateY(0); }
  
  /* =========================
     AUTOCOMPLETE
     ========================= */
  .autocomplete-box{
    position: absolute;
    inset-inline: 0;
    background: rgba(26,26,46,.96);
    backdrop-filter: blur(18px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: min(320px, 50vh);
    overflow-y: auto;
    z-index: 1000;
    margin-top: 8px;
    box-shadow: var(--shadow-2);
  }
  
  .autocomplete-box div{
    padding: 14px 18px;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
    border-bottom: 1px solid rgba(255,255,255,.06);
  }
  .autocomplete-box div:last-child{ border-bottom: none; }
  
  @media (hover:hover){
    .autocomplete-box div:hover{
      background: rgba(102,126,234,.12);
      color: var(--brand-1);
    }
  }
  
  /* =========================
     SECTION HEADERS
     ========================= */
  #searchResults h2,
  #aiSuggestions h2{
    font-size: var(--step-3);
    font-weight: 800;
    text-align: center;
    margin: var(--space-7) 0 var(--space-5);
    background: linear-gradient(135deg, var(--brand-1) 0%, var(--brand-2) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
  }
  
  /* =========================
     GRID
     ========================= */
  .movie-grid{
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: clamp(16px, 2vw, 24px);
    margin-top: var(--space-5);
  }
  
  #searchResults,
  #aiSuggestions{
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px 20px;
  }
  
  /* =========================
     CARD
     ========================= */
  .movie-card{
    display: flex;
    flex-direction: column;
    background: var(--surface);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: clip;
    transition: transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s ease, border-color .2s ease;
    position: relative;
    will-change: transform;
    animation: fadeInUp .5s ease-out both;
    cursor: pointer;
  }
  
  @media (hover:hover){
    .movie-card:hover{
      transform: translateY(-8px);
      box-shadow: var(--shadow-2);
      border-color: rgba(102,126,234,.28);
    }
  }
  
  /* Decorative overlay on hover-capable devices only */
  @media (hover:hover){
    .movie-card::before{
      content:'';
      position:absolute; inset:0;
      background: linear-gradient(135deg, rgba(102,126,234,.10) 0%, rgba(118,75,162,.10) 100%);
      opacity: 0; transition: opacity .2s ease; z-index: 1;
    }
    .movie-card:hover::before{ opacity: 1; }
  }
  
     /* Poster frame keeps consistent poster ratio without cropping */
   .movie-card .poster-frame{
     width: 100%;
     aspect-ratio: 2 / 3;            /* standard poster ratio */
     background: rgba(255,255,255,.06);
     border-bottom: 1px solid var(--border);
     overflow: hidden;               /* hide tiny overflow if any */
     display: grid;                  /* easy centering */
     place-items: center;
   }

   /* Image is fully visible inside the frame */
   .movie-card img{
     max-width: 100%;
     max-height: 100%;
     width: 100%;
     height: 100%;
     object-fit: contain;            /* <-- no crop */
     display: block;
     filter: brightness(1) contrast(1); /* keep true colors */
     transform: none;                /* avoid hover zoom cropping */
   }
   
   /* Rating badge for movie cards */
   .movie-card .rating-badge{
     position: absolute;
     top: 8px;
     right: 8px;
     background: linear-gradient(135deg, var(--brand-1) 0%, var(--brand-2) 100%);
     color: white;
     padding: 4px 8px;
     border-radius: var(--radius-sm);
     font-weight: 700;
     font-size: 0.75rem;
     box-shadow: var(--shadow-1);
     display: flex;
     align-items: baseline;
     gap: 1px;
     z-index: 3;
   }
   
   .movie-card .rating-score{
     font-size: 0.8rem;
     font-weight: 800;
   }
   
   .movie-card .rating-label{
     font-size: 0.65rem;
     opacity: 0.9;
   }
  
  /* Content */
  .movie-card-content{
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 18px;
    position: relative;
    z-index: 2;
    min-block-size: 220px; /* keeps layout tidy with varying synopses */
  }
  
  .movie-card h3{
    font-size: var(--step-1);
    font-weight: 800;
    line-height: 1.25;
    color: var(--text);
  }
  
  .movie-year{
    font-weight: 700;
    color: var(--brand-1);
    font-size: var(--step--1);
  }
  
  .movie-director{
    font-style: italic;
    color: var(--text-dim);
    font-size: var(--step--1);
  }
  
  .movie-actors{
    color: var(--text-muted);
    font-size: var(--step--1);
    line-height: 1.4;
  }
  
  .movie-synopsis{
    color: var(--text-dim);
    font-size: var(--step--1);
    line-height: 1.6;
    margin-top: auto;
    display: -webkit-box;
    -webkit-line-clamp: 6;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  
  /* =========================
     SELECTED MOVIE INFO
     ========================= */
  #selectedMovieInfo{
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px 20px;
  }
  
  .selected-movie-card{
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: var(--space-6);
    background: var(--surface);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-6);
    margin-top: var(--space-5);
  }
  
  .selected-movie-poster{
    position: relative;
  }
  
  .selected-movie-poster img{
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    border-radius: var(--radius-sm);
  }
  
  
  .movie-header{
    margin-bottom: var(--space-5);
  }
  
  .movie-title-row{
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
  }
  
  .selected-movie-details h3{
    font-size: var(--step-2);
    font-weight: 800;
    color: var(--text);
    margin: 0;
  }
  
  .header-rating{
    background: linear-gradient(135deg, var(--brand-1) 0%, var(--brand-2) 100%);
    color: white;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: var(--step--1);
    display: flex;
    align-items: baseline;
    gap: 2px;
    box-shadow: var(--shadow-1);
  }
  
  .movie-director{
    color: var(--text-muted);
    font-size: var(--step--1);
    font-style: italic;
  }
  
  .movie-actions{
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
  }
  
  .action-item{
    background: rgba(255,255,255,.03);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: all 0.2s ease;
  }
  
  .action-item:hover{
    background: rgba(255,255,255,.05);
    border-color: rgba(102,126,234,.2);
  }
  
  .action-header{
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: rgba(255,255,255,.05);
    border-bottom: 1px solid rgba(255,255,255,.08);
    cursor: pointer;
    transition: background 0.2s ease;
  }
  
  .action-header:hover{
    background: rgba(255,255,255,.08);
  }
  
  .action-icon{
    font-size: var(--step-0);
  }
  
  .action-title{
    font-weight: 700;
    color: var(--text);
    font-size: var(--step--1);
  }
  
  .action-content{
    padding: var(--space-4);
  }
  
  .action-content p{
    color: var(--text-muted);
    line-height: 1.6;
    margin: 0;
  }
  
  .genre-tags{
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  
  .genre-tag{
    background: linear-gradient(135deg, var(--brand-1) 0%, var(--brand-2) 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
  }

  /* =========================
     AI SUGGESTIONS
     ========================= */
  #aiSuggestions:not(:empty){ margin-top: var(--space-7); }
  
  /* =========================
     TABS INTERFACE
     ========================= */
  .tabs-container{
    margin-top: var(--space-5);
  }
  
  .tabs-nav{
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: var(--space-5);
    padding: var(--space-2);
    background: rgba(255,255,255,.03);
    border-radius: var(--radius);
    border: 1px solid var(--border);
  }
  
  .tab-button{
    padding: var(--space-2) var(--space-4);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: var(--step--1);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
  }
  
  .tab-button:hover{
    background: rgba(255,255,255,.05);
    color: var(--text);
    border-color: rgba(102,126,234,.3);
  }
  
  .tab-button.active{
    background: linear-gradient(135deg, var(--brand-1) 0%, var(--brand-2) 100%);
    color: white;
    border-color: transparent;
    box-shadow: var(--brand-glow);
  }
  
  .tab-content{
    position: relative;
  }
  
  .tab-panel{
    display: none;
    animation: fadeInUp 0.3s ease-out;
  }
  
  .tab-panel.active{
    display: block;
  }
  #aiSuggestions h3{
    font-size: var(--step-2);
    font-weight: 800;
    text-align: center;
    margin: var(--space-6) 0 var(--space-4);
    color: var(--text);
    background: linear-gradient(135deg, var(--brand-1) 0%, var(--brand-2) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    position: relative;
  }
  #aiSuggestions h3::after{
    content:'';
    position:absolute; left:50%; transform: translateX(-50%);
    bottom: -10px; width: 64px; height: 3px;
    background: linear-gradient(135deg, var(--brand-1) 0%, var(--brand-2) 100%);
    border-radius: 2px;
  }
  
  /* =========================
     LOADING
     ========================= */
  .loading{
    text-align: center;
    padding: 60px 20px;
    font-size: var(--step-0);
    color: var(--text-muted);
  }
  .loading::after{
    content:'';
    display:inline-block;
    inline-size: 20px; block-size: 20px;
    border: 2px solid rgba(102,126,234,.3);
    border-radius: 50%;
    border-top-color: var(--brand-1);
    animation: spin 1s linear infinite;
    margin-left: 10px;
  }
  @keyframes spin{ to{ transform: rotate(360deg); } }
  
  /* =========================
     FOOTER
     ========================= */
  footer{
    margin-top: var(--space-8);
    text-align: center;
    padding: 40px 20px;
    color: var(--text-dim);
    font-size: .92rem;
    border-top: 1px solid var(--border);
  }
  
  /* =========================
     ANIMATIONS (safe)
     ========================= */
  @keyframes fadeInUp{
    from{ opacity: 0; transform: translateY(18px); }
    to{ opacity: 1; transform: translateY(0); }
  }
  
  /* Respect user motion preference */
  @media (prefers-reduced-motion: reduce){
    *{ animation: none !important; transition: none !important; }
  }
  
  /* =========================
     RESPONSIVE
     ========================= */
  @media (max-width: 900px){
    .container{ padding-inline: 16px; }
    header{ margin: var(--space-6) auto var(--space-5); }
    #movieForm button{ padding: 12px 22px; }
    .movie-card-content{ padding: 16px; min-block-size: 200px; }
  }
  
  @media (max-width: 640px){
    header{ border-radius: var(--radius); }
    header h1{ font-size: var(--step-3); }
    .movie-grid{ grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
    .movie-card img{ aspect-ratio: 16/11; }
    #searchResults h2, #aiSuggestions h2{ font-size: var(--step-2); margin: var(--space-6) 0 var(--space-4); }
    
    .selected-movie-card{
      grid-template-columns: 1fr;
      gap: var(--space-4);
      padding: var(--space-4);
    }
    
    .selected-movie-poster{
      max-width: 200px;
      margin: 0 auto;
    }
    
    
    .action-header{
      padding: var(--space-2) var(--space-3);
    }
    
    .action-content{
      padding: var(--space-3);
    }
    
    .movie-title-row{
      flex-direction: column;
      align-items: flex-start;
      gap: var(--space-2);
    }
    
    .header-rating{
      align-self: flex-end;
      padding: 4px 10px;
      font-size: 0.8rem;
    }
    
    .tabs-nav{
      gap: var(--space-1);
      padding: var(--space-1);
    }
    
    .tab-button{
      padding: var(--space-1) var(--space-2);
      font-size: 0.8rem;
    }
    
    .movie-card .rating-badge{
      top: 6px;
      right: 6px;
      padding: 3px 6px;
      font-size: 0.7rem;
    }
    
    .movie-card .rating-score{
      font-size: 0.75rem;
    }
    
    .movie-card .rating-label{
      font-size: 0.6rem;
    }
  }
  
  /* =========================
     SCROLLBAR (WebKit)
     ========================= */
  ::-webkit-scrollbar{ width: 10px; height:10px; }
  ::-webkit-scrollbar-track{ background: rgba(255,255,255,.08); border-radius: 6px; }
  ::-webkit-scrollbar-thumb{
    background: linear-gradient(135deg, var(--brand-1) 0%, var(--brand-2) 100%);
    border-radius: 6px;
  }
  ::-webkit-scrollbar-thumb:hover{
    background: linear-gradient(135deg, #5a6fd8 0%, #6a5acd 100%);
  }
  
  /* =========================
     FOCUS VISIBILITY
     ========================= */
  :focus-visible{
    outline: 3px solid rgba(102,126,234,.45);
    outline-offset: 2px;
    border-radius: 6px;
  }