/* :root variables are kept from the original for consistency in styling */
:root {
  /* Font Params */
  --font: 'Segoe UI', system-ui, sans-serif;
  --font-size: 16px;
  --font-color: #f1f5f9;

  /* Colors */
  --surface: #111827;
  --background: #1f2937;
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --primary-active: #5b21b6;
  --primary-light: #a78bfa;
  --primary-dark: #5b21b6;
  --primary-darker: #4c1d95;
  --danger: #f43f5e;
  --danger-hover: #e11d48;
  --danger-active: #be123c;


  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-inset: inset 0 2px 4px 0 rgba(0, 0, 0, 0.05);


  /* Sizing */
  --bannerWidth: 300px;
  --bannerHeight: 168px;
  --coverWidth: 180px;
  --coverHeight: 300px;
  --slotWidth: 180px;
  --slotHeight: 300px;

  /* Transitions */
  --transition-fast: all 0.2s ease-in-out;
  --transition-medium: all 0.3s ease-in-out;

  /* Borders */
  --border-radius-sm: 0.25rem;
  --border-radius-md: 0.375rem;
  --border-radius-lg: 0.5rem;
}

/* Basic Reset & Body Styles */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--background);
  color: var(--font-color);
  font-family: var(--font);
  font-size: var(--font-size);
  min-height: 100vh;
  padding: 0.5rem;
  padding-top: 5rem; /* Space for the fixed header */
  display: flex;
  flex-direction: column;
}

/* Header Styles */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background: var(--surface);
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 1000;
  box-shadow: var(--shadow-md);
  transition: var(--transition-medium);
}

.site-header .header-title h1 {
  margin: 0;
  font-size: 1.8em;
  color: var(--primary-light);
  font-weight: 700;
}

.site-header .header-title p {
  font-size: 0.9em;
  opacity: 0.7;
  margin-top: 0.25rem;
}

.site-header .header-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.site-header .header-controls a,
.site-header .header-controls button {
  padding: 0.6rem 1.2rem;
  border-radius: var(--border-radius-md);
  font-weight: 600;
  transition: var(--transition-fast);
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.site-header .header-controls a:focus-visible,
.site-header .header-controls button:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}

.site-header .header-controls a {
  background: transparent;
  color: var(--font-color);
  font-size: 1.5rem;
  padding: 0.5rem; /* Adjust padding for icon-only button */
}

.site-header .header-controls a:hover {
  color: var(--primary-light);
  background-color: rgba(167, 139, 250, 0.1);
}

/* Login Button States */
#loginBtn[logged-in="true"] {
  display: none;
}

#loginBtn[logged-in="false"] {
  display: inline-flex; /* Use flex for alignment */
}

/* Generic Button Styles */
.btn {
    border: none;
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: var(--primary-darker);
}

/* Primary Button (Login) */
.btn-primary {
  background-color: var(--primary);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
  box-shadow: var(--shadow-md);
}

.btn-primary:active:not(:disabled) {
    background-color: var(--primary-active);
}

/* Secondary Button (Clean Memory) */
.btn-secondary {
  background-color: var(--surface);
  color: var(--font-color);
  border: 1px solid var(--primary-darker);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--primary-darker);
  border-color: var(--primary-light);
}

/* Main Content Area */
main {
  flex: 1;
  padding: 2rem 1.5rem;
  max-width: 1400px; /* Wider for large screens */
  margin: 0 auto; /* Center with 0 top/bottom margin */
  width: 100%;
}

/* Recommendations Section */
#recommendations-container {
  display: flex;
  flex-direction: column; /* Stack "because you watched" sections */
  gap: 3rem; /* Increased space between sections */
}

.because-you-watched-container {
  width: 100%;
}

.because-you-watched-title {
  font-size: 1.6em;
  font-weight: 600;
  color: var(--font-color);
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--primary-dark);
}

.Content-link {
  text-decoration: none;
  color: var(--primary-light);
  font-weight: 700;
}

.Content-link:hover {
  text-decoration: underline;
  text-decoration-color: var(--primary);
}

/* Content Grid */
.Content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.5rem;
}

/* Content Card */
.Content-card {
  background-color: var(--surface);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  transition: transform var(--transition-medium), box-shadow var(--transition-medium);
  display: flex;
  flex-direction: column;
  width: 100%;
  cursor: pointer;
  position: relative;
}

.Content-card:hover {
  transform: translateY(-8px) scale(1.03);
  box-shadow: var(--shadow-xl);
}

.Content-card img {
  width: 100%;
  height: 270px; /* Adjusted height */
  object-fit: cover;
  display: block;
  border-bottom: 3px solid var(--primary); /* Accent border */
}

.Content-info {
  padding: 1rem;
  text-align: center;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 90px; /* Ensure a minimum height for text content */
}

.Content-info h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.05em;
  color: var(--font-color);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.Content-info .rating,
.Content-info .year {
  font-size: 0.85em;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.4;
}

/* Status Messages */
.loading-message,
.no-results-message {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem;
  font-size: 1.25em;
  color: rgba(255, 255, 255, 0.7);
  width: 100%;
}

/* Floating Window (Modal) */
.floatWindow {
  position: fixed; /* Use fixed for viewport positioning */
  background: var(--surface);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  z-index: 1001;
  min-width: 320px;
  max-width: 500px;
  width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  border: 1px solid var(--primary-dark);
  /* Centered by default, can be overridden by JS */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.floatWindow .windowBar {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--primary-dark);
  color: var(--font-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: move;
  user-select: none;
}

.floatWindow .windowBar h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.floatWindow .windowBar .closeBtn {
  font-size: 1.5rem;
  background: transparent;
  border: none;
  color: var(--font-color);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 50%;
  transition: var(--transition-fast);
}

.floatWindow .windowBar .closeBtn:hover {
  color: var(--danger);
  background-color: rgba(244, 63, 94, 0.1);
}

.floatWindow .content {
  padding: 1.5rem;
  flex-grow: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.floatWindow .form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.floatWindow label {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
  font-weight: 500;
}

.floatWindow input[type="text"],
.floatWindow input[type="password"] {
  padding: 0.75rem 1rem;
  border: 1px solid var(--primary-darker);
  border-radius: var(--border-radius-md);
  background: var(--background);
  color: var(--font-color);
  transition: var(--transition-fast);
  width: 100%;
  font-size: 1rem;
}

.floatWindow input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.3);
}

/* Error Message */
.error-message {
  color: var(--danger);
  background-color: rgba(244, 63, 94, 0.1);
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--danger);
  font-size: 0.9rem;
  width: 100%;
  animation: fadeIn 0.3s ease-in-out;
  position: relative;
  display: flex;
  align-items: center;
}

.error-message::before {
  content: "⚠️"; /* Using emoji for indicator */
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.2rem;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}


/* Responsive Adjustments */
@media (max-width: 768px) {
  .site-header {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
  }

  .site-header .header-controls {
    width: 100%;
    justify-content: center;
  }

  main {
    padding: 1.5rem 1rem;
  }

  .Content-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  body {
    padding-top: 8rem; /* More space for wrapped header */
  }

  .site-header .header-title h1 {
    font-size: 1.5em;
  }

  .site-header .header-controls a,
  .site-header .header-controls button {
      padding: 0.6rem 1rem;
      font-size: 0.9rem;
  }

  main {
    padding: 1rem 0.5rem;
  }

  #recommendations-container {
      gap: 2rem;
  }
  
  .because-you-watched-title {
      font-size: 1.3em;
  }

  .Content-grid {
    /* Two columns on the smallest screens */
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .Content-card img {
    height: 220px;
  }
  
  .Content-info {
    padding: 0.75rem;
    min-height: 80px;
  }

  .Content-info h3 {
    font-size: 0.9em;
  }
}