/* ============================================
   BASE STYLES
   ============================================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  min-height: 100vh;
  color: #fff;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.login-container {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-container h1 {
  font-size: 2rem;
  margin-bottom: 10px;
}

.login-container .subtitle {
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 30px;
}

.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.8);
}

.form-group input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1rem;
  transition: border-color 0.3s;
}

.form-group input:focus {
  outline: none;
  border-color: #4ade80;
}

.form-group input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.error-message {
  color: #f87171;
  font-size: 0.9rem;
  margin-bottom: 15px;
  min-height: 20px;
}

#login-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
  border: none;
  border-radius: 10px;
  color: #000;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

#login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(74, 222, 128, 0.3);
}

#login-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.divider {
  display: flex;
  align-items: center;
  margin: 24px 0;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.85rem;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.2);
}

.divider span {
  padding: 0 16px;
}

.google-btn {
  width: 100%;
  padding: 14px;
  background: #fff;
  border: none;
  border-radius: 10px;
  color: #333;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.google-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(255, 255, 255, 0.2);
}

.google-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ============================================
   MAIN APP
   ============================================ */
.app-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.app-header h1 {
  font-size: 1.5rem;
}

.logout-btn {
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.3s;
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ============================================
   USERS DISPLAY
   ============================================ */
.users-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-bottom: 30px;
}

.user-card {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  flex: 1;
  max-width: 180px;
  transition: transform 0.3s, box-shadow 0.3s;
}

.user-card.active {
  transform: scale(1.05);
  box-shadow: 0 0 30px rgba(74, 222, 128, 0.4);
  border: 2px solid #4ade80;
}

.user-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 12px;
  border: 3px solid rgba(255, 255, 255, 0.3);
}

.user-card.active .user-avatar {
  border-color: #4ade80;
}

.user-name {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.user-status {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
}

.user-card.active .user-status {
  color: #4ade80;
}

.switch-indicator {
  display: flex;
  align-items: center;
}

.picker-arrow {
  color: #4ade80;
  transition: transform 0.3s;
}

.picker-arrow.left {
  transform: rotate(180deg);
}

/* ============================================
   MOVIE PICKER
   ============================================ */
.movie-picker {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 30px;
}

.current-picker-display {
  text-align: center;
  margin-bottom: 20px;
  font-size: 1.1rem;
}

#current-picker-text {
  color: #4ade80;
  font-weight: 600;
}

.search-container {
  position: relative;
  margin-bottom: 16px;
}

#movie-search {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1rem;
  transition: border-color 0.3s;
}

#movie-search:focus {
  outline: none;
  border-color: #4ade80;
}

#movie-search::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #1e293b;
  border-radius: 10px;
  margin-top: 8px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  display: none;
}

.search-results.show {
  display: block;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.search-result-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.search-result-item img {
  width: 40px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
}

.search-result-item .no-poster {
  width: 40px;
  height: 60px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.search-result-info {
  flex: 1;
}

.search-result-title {
  font-weight: 500;
  margin-bottom: 4px;
}

.search-result-year {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
}

/* Selected movie */
.selected-movie {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(74, 222, 128, 0.15);
  border: 2px solid #4ade80;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 16px;
}

.selected-movie img {
  width: 50px;
  height: 75px;
  object-fit: cover;
  border-radius: 6px;
}

.selected-info {
  flex: 1;
}

#selected-title {
  font-weight: 600;
  margin-bottom: 4px;
}

#selected-year {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.7);
}

.clear-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

.clear-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.record-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
  border: none;
  border-radius: 10px;
  color: #000;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.record-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(74, 222, 128, 0.3);
}

.record-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Disabled state when not your turn */
.movie-picker.disabled {
  opacity: 0.6;
}

.movie-picker.disabled #movie-search {
  cursor: not-allowed;
}

.movie-picker.disabled .current-picker-display {
  color: rgba(255, 255, 255, 0.7);
}

.movie-picker.disabled #current-picker-text {
  color: rgba(255, 255, 255, 0.5);
}

/* ============================================
   HISTORY
   ============================================ */
.history-section {
  margin-bottom: 30px;
}

.history-section h2 {
  font-size: 1.2rem;
  margin-bottom: 16px;
}

.history-list {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  overflow: hidden;
}

.empty-history {
  padding: 30px;
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
}

.history-item {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.history-item:last-child {
  border-bottom: none;
}

.history-item.undo-pending {
  background: rgba(251, 191, 36, 0.1);
  border-left: 3px solid #fbbf24;
}

.history-content {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}

.history-item img {
  width: 40px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
}

.history-item .no-poster {
  width: 40px;
  height: 60px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.history-info {
  flex: 1;
}

.history-title {
  font-weight: 500;
  margin-bottom: 4px;
}

.history-meta {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
}

/* Undo button (on latest entry for picker) */
.history-actions {
  display: flex;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.2s;
}

.history-item:hover .history-actions {
  opacity: 1;
}

.action-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.undo-btn:hover {
  background: rgba(251, 191, 36, 0.3);
  color: #fbbf24;
}

/* Undo status (for picker waiting) */
.undo-status {
  display: flex;
  align-items: center;
  gap: 12px;
}

.undo-waiting {
  font-size: 0.85rem;
  color: #fbbf24;
}

.undo-cancel-btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s;
}

.undo-cancel-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Undo approval (for other person) */
.undo-approval {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.undo-request-text {
  font-size: 0.85rem;
  color: #fbbf24;
}

.undo-approval-actions {
  display: flex;
  gap: 8px;
}

/* Confirm buttons */
.confirm-actions {
  display: flex;
  gap: 8px;
}

.confirm-btn {
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.confirm-yes {
  background: #4ade80;
  color: #000;
}

.confirm-yes:hover {
  background: #22c55e;
}

.confirm-no {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.confirm-no:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Undo override confirmation (when recording over pending request) */
.undo-override-confirm {
  background: rgba(251, 191, 36, 0.15);
  border: 2px solid #fbbf24;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  text-align: center;
}

.override-message {
  margin-bottom: 8px;
}

.override-subtext {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 16px;
}

/* ============================================
   ATTRIBUTION
   ============================================ */
.attribution {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
}

.tmdb-logo {
  height: 20px;
}

/* ============================================
   LOADING STATE
   ============================================ */
.loading {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

.loading.hidden {
  display: none;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: #4ade80;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 500px) {
  .users-container {
    gap: 10px;
  }
  
  .user-card {
    padding: 16px;
  }
  
  .user-avatar {
    width: 60px;
    height: 60px;
  }
  
  .user-name {
    font-size: 1rem;
  }
  
  .picker-arrow svg {
    width: 24px;
    height: 24px;
  }
  
  /* Always show action buttons on mobile (no hover) */
  .history-actions {
    opacity: 1;
  }
  
  /* Stack undo approval on mobile */
  .undo-approval {
    align-items: stretch;
  }
  
  .undo-approval-actions {
    justify-content: flex-end;
  }
  
  .undo-status {
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
  }
  
  .history-content {
    flex-wrap: wrap;
  }
}
