/* CSS Custom Properties for Light/Dark Theme */
:root {
  /* Light Theme Colors */
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary-color: #64748b;
  --accent-color: #f59e0b;
  --success-color: #10b981;
  --error-color: #ef4444;
  
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --bg-modal: rgba(0, 0, 0, 0.5);
  
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-tertiary: #94a3b8;
  --text-inverse: #ffffff;
  
  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
}

/* Dark Theme Colors */
[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-modal: rgba(0, 0, 0, 0.8);
  
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-tertiary: #94a3b8;
  --text-inverse: #1e293b;
  
  --border-color: #334155;
  --border-hover: #475569;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.2);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.3), 0 8px 10px -6px rgb(0 0 0 / 0.3);
}

/* Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  /* Prevent zoom on mobile when focusing inputs */
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
  /* Improve touch scrolling on mobile */
  -webkit-overflow-scrolling: touch;
}

/* Touch-friendly buttons */
button, .movie-card, .history-item {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Prevent iOS input zoom */
input[type="text"] {
  font-size: 16px;
}

/* Ensure minimum touch target size on mobile */
@media (max-width: 768px) {
  button, .theme-toggle, .history-btn {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Fix search input height consistency */
  .search-wrapper {
    min-height: auto;
  }
  
  .search-icon {
    font-size: 1rem;
  }
}

/* Loading Animation */
.loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}

.loader-content {
  text-align: center;
  color: var(--text-inverse);
}

.loader-spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Navigation */
.navbar {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm);
}

.navbar-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
}

.navbar-brand i {
  font-size: 1.75rem;
}

.navbar-controls {
  display: flex;
  gap: 0.75rem;
}

.theme-toggle,
.history-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.5rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
}

.theme-toggle:hover,
.history-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

/* Hero Section */
.hero {
  background: linear-gradient(135deg, var(--primary-color) 0%, #3b82f6 100%);
  color: var(--text-inverse);
  padding: 4rem 0;
  text-align: center;
}

.hero-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1rem;
}

.hero h1 {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 1rem;
  background: linear-gradient(45deg, #ffffff, #e2e8f0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: 1.25rem;
  opacity: 0.9;
  margin-bottom: 2rem;
}

/* Search Container */
.search-container {
  margin-top: 2rem;
  position: relative;
}

.search-wrapper {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  background: var(--bg-primary);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-xl);
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  z-index: 10;
  transition: all 0.3s ease;
  pointer-events: none;
  font-size: 1rem;
}

.search-icon.fa-spinner {
  color: var(--primary-color);
}

.search-icon.fa-keyboard {
  color: var(--accent-color);
}

.search-icon.fa-link {
  color: var(--success-color);
}

.search-icon.fa-globe {
  color: var(--primary-color);
}

.search-icon.fa-server {
  color: var(--secondary-color);
}

.search-icon.fa-home {
  color: var(--accent-color);
}

.search-icon.fa-envelope {
  color: var(--error-color);
}

#search-input {
  flex: 1;
  padding: 1rem 1rem 1rem 3rem;
  border: none;
  outline: none;
  font-size: 1rem;
  background: transparent;
  color: var(--text-primary);
  min-height: 3rem;
}

#search-input::placeholder {
  color: var(--text-tertiary);
}

.search-btn {
  background: var(--primary-color);
  color: var(--text-inverse);
  border: none;
  padding: 1rem 2rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
  min-height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.search-btn:hover {
  background: var(--primary-hover);
}

/* Search History */
.search-history-container {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
}

.search-history {
  position: absolute;
  top: 0.5rem;
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-height: 400px;
  overflow-y: auto;
  z-index: 200;
}

.search-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.search-history-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.clear-history {
  background: none;
  border: none;
  color: var(--error-color);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  transition: background-color 0.2s ease;
}

.clear-history:hover {
  background: var(--bg-secondary);
}

.history-list {
  padding: 0.5rem 0;
}

.history-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.history-item:hover {
  background: var(--bg-secondary);
}

.history-item i {
  color: var(--text-tertiary);
  font-size: 0.875rem;
}

/* Main Content */
.main-content {
  min-height: 60vh;
  padding: 2rem 0;
}

.content-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.search-info {
  margin-bottom: 2rem;
  text-align: center;
}

.search-info h2 {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.search-info p {
  color: var(--text-secondary);
  font-size: 1.125rem;
}

/* Movies Grid */
.movies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2rem;
  margin-bottom: 3rem;
}

.movie-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
}

.movie-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-xl);
  border-color: var(--primary-color);
}

.movie-card img {
  width: 100%;
  height: 400px;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.movie-card:hover img {
  transform: scale(1.05);
}

.movie-info {
  padding: 1.5rem;
}

.movie-info h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.movie-year {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.movie-type {
  display: inline-block;
  background: var(--primary-color);
  color: var(--text-inverse);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: capitalize;
}

/* Load More Button */
.load-more-container {
  text-align: center;
}

.load-more-btn {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  color: var(--text-primary);
  padding: 1rem 2rem;
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.load-more-btn:hover {
  background: var(--primary-color);
  color: var(--text-inverse);
  border-color: var(--primary-color);
  transform: translateY(-2px);
}

/* Movie Details Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-modal);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-primary);
  margin: 2rem auto;
  border-radius: var(--radius-xl);
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalSlideIn 0.3s ease;
}

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

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--bg-secondary);
  border: none;
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--error-color);
  color: var(--text-inverse);
}

.movie-details {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 2rem;
  padding: 2rem;
}

.movie-poster {
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.movie-poster img {
  width: 100%;
  height: auto;
  display: block;
}

.movie-meta {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.movie-title {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.movie-subtitle {
  color: var(--text-secondary);
  font-size: 1.125rem;
  margin-bottom: 1rem;
}

.movie-rating {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.rating-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.rating-value {
  font-weight: 600;
  color: var(--accent-color);
}

.movie-genres {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.genre-tag {
  background: var(--primary-color);
  color: var(--text-inverse);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
}

.movie-plot {
  font-size: 1.125rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.movie-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.info-item {
  background: var(--bg-secondary);
  padding: 1rem;
  border-radius: var(--radius-md);
}

.info-label {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

.info-value {
  font-weight: 500;
}

/* Footer */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 2rem 0 1rem;
  margin-top: 4rem;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  text-align: center;
}

.footer-section h4 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.footer-section p {
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 400px;
  margin: 0 auto;
}

.footer-bottom {
  text-align: center;
  padding-top: 1.5rem;
  margin-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  color: var(--text-secondary);
}

/* Utility Classes */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.text-primary {
  color: var(--primary-color);
}

.text-secondary {
  color: var(--text-secondary);
}

.text-success {
  color: var(--success-color);
}

.text-error {
  color: var(--error-color);
}

/* Responsive Design */
@media (max-width: 768px) {
  .hero {
    padding: 2rem 0;
  }
  
  .hero h1 {
    font-size: 2rem;
  }
  
  .hero p {
    font-size: 1rem;
  }
  
  .search-wrapper {
    flex-direction: column;
    margin: 0 1rem;
    border-radius: var(--radius-lg);
    position: relative;
  }
  
  .search-icon {
    left: 1rem;
    top: 1rem;
    transform: translateY(0);
    position: absolute;
    z-index: 10;
    font-size: 1rem;
  }
  
  #search-input {
    padding: 1rem 1rem 1rem 3rem;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    min-height: 3.5rem;
    font-size: 16px; /* Prevents zoom on iOS */
    width: 100%;
    box-sizing: border-box;
  }
  
  .search-btn {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    padding: 1rem;
    min-height: 3rem;
    width: 100%;
    justify-content: center;
  }
  
  .movies-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    padding: 1rem;
  }
  
  .movie-details {
    grid-template-columns: 1fr;
    padding: 1rem;
    gap: 1rem;
  }
  
  .movie-title {
    font-size: 2rem;
  }
  
  .navbar-brand {
    font-size: 1.25rem;
  }
  
  .navbar-container {
    padding: 0 1rem;
  }
  
  .navbar-controls {
    gap: 0.5rem;
  }
  
  .theme-toggle,
  .history-btn {
    width: 36px;
    height: 36px;
  }
  
  .movie-card {
    margin-bottom: 0.5rem;
  }
  
  .movie-card img {
    height: 300px;
  }
  
  .movie-info {
    padding: 1rem;
  }
  
  .modal-content {
    margin: 1rem;
    max-height: calc(100vh - 2rem);
  }
  
  .search-history {
    position: fixed;
    top: 160px;
    left: 1rem;
    right: 1rem;
    width: auto;
    max-height: 60vh;
  }
  
  .hero-content {
    padding: 0 1rem;
  }
  
  .content-wrapper {
    padding: 0 1rem;
  }
  
  .load-more-btn {
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
  }
  
  .movie-rating {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .rating-item {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
  }
  
  .movie-genres {
    gap: 0.375rem;
  }
  
  .genre-tag {
    padding: 0.2rem 0.6rem;
    font-size: 0.8rem;
  }
  
  .movie-info-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  .search-info h2 {
    font-size: 1.5rem;
  }
  
  .search-info p {
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .hero {
    padding: 1.5rem 0;
  }
  
  .hero h1 {
    font-size: 1.75rem;
  }
  
  .movies-grid {
    grid-template-columns: 1fr;
    padding: 0.75rem;
  }
  
  .navbar-brand span {
    display: none;
  }
  
  .movie-card img {
    height: 250px;
  }
  
  .search-wrapper {
    margin: 0 0.75rem;
  }
  
  .search-icon {
    left: 0.75rem;
    top: 0.875rem;
    font-size: 0.9rem;
  }
  
  #search-input {
    padding: 0.875rem 0.875rem 0.875rem 2.5rem;
    font-size: 16px;
    min-height: 3rem;
  }
  
  .search-btn {
    padding: 0.875rem;
    min-height: 2.75rem;
  }
  
  .main-content {
    padding: 1rem 0;
  }
  
  .movie-title {
    font-size: 1.75rem;
  }
  
  .movie-subtitle {
    font-size: 1rem;
  }
  
  .search-history {
    top: 140px;
    left: 0.75rem;
    right: 0.75rem;
  }
  
  .footer {
    padding: 1.5rem 0 1rem;
  }
  
  .footer-content {
    padding: 0 1rem;
  }
}
