/* --- Global Reset & Base Styles --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: #f4f4f4;
  color: #333;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1; /* Allows main to grow and push footer down */
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* --- Header & Navigation --- */
header {
  background: #1f1f1f;
  color: white;
  text-align: center;
  padding: 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
}

header h1 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 24px;
}

nav {
  margin-top: 10px;
}

nav a {
  color: white;
  margin: 0 15px;
  text-decoration: none;
  font-weight: bold;
}

nav a:hover {
  text-decoration: underline;
}

/* --- Controls (Filters & Sorting) --- */
.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
  margin-bottom: 20px;
}

select {
  padding: 10px;
  font-size: 16px;
  border: 1px solid #ccc;
  border-radius: 5px;
}

/* --- Movie Cards Grid --- */
.movies-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 25px;
}

.movie-card {
  background: white;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  overflow: hidden;
  transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.movie-card:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

.movie-card img {
  width: 100%;
  height: 330px;
  object-fit: cover;
  cursor: pointer;
}

.movie-card h3 {
  margin: 15px;
  font-size: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.movie-card p {
  margin: 0 15px 15px;
  color: #555;
  font-weight: bold;
}

/* --- Add to Watchlist Button --- */
.add-btn {
  display: block;
  width: calc(100% - 30px);
  margin: 0 15px 15px;
  padding: 10px;
  border: none;
  border-radius: 5px;
  background-color: #007bff;
  color: white;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s;
}

.add-btn:hover {
  background-color: #0056b3;
}

.add-btn.added {
  background-color: #28a745; /* Green for added */
  cursor: default;
}

/* --- Pagination --- */
.pagination {
  display: flex;
  justify-content: center;
  margin: 30px 0;
}

.pagination button {
  margin: 0 5px;
  padding: 10px 15px;
  border: none;
  background: #333;
  color: white;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.pagination button:hover {
  background: #555;
}

.pagination button.active {
  background: #007bff;
}

/* --- Modal --- */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.8);
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: white;
  padding: 25px;
  border-radius: 10px;
  max-width: 400px;
  width: 90%;
  position: relative;
  text-align: center;
  animation: fadeIn 0.3s;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.modal-content img {
  width: 100%;
  border-radius: 10px;
  margin-bottom: 15px;
}

.close {
  position: absolute;
  top: 10px; right: 20px;
  font-size: 30px;
  font-weight: bold;
  color: #555;
  cursor: pointer;
}

/* --- Login & 404 Pages --- */
.login-form, .error-page {
  display: flex;
  flex-direction: column;
  max-width: 350px;
  margin: 50px auto;
  text-align: center;
  padding: 20px;
}

.login-form input, .login-form button {
  padding: 12px;
  margin: 8px 0;
  border-radius: 5px;
  border: 1px solid #ccc;
}

.login-form button {
  background: #1f1f1f;
  color: white;
  border: none;
  cursor: pointer;
}

.error-page h1 {
  font-size: 80px;
  margin: 0;
}

.error-page a {
  display: inline-block;
  margin-top: 20px;
  text-decoration: none;
  background: #1f1f1f;
  color: white;
  padding: 12px 25px;
  border-radius: 5px;
}

/* --- Footer --- */
footer {
  background: #1f1f1f;
  color: #ccc;
  text-align: center;
  padding: 20px 0;
  width: 100%;
}

/* --- Responsive Design --- */
@media (max-width: 600px) {
  .movies-container {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
  header h1 {
    font-size: 20px;
  }
}