/* Shared Variables */
:root {
  --bg-primary: #fafafa;
  --bg-secondary: #ffffff;
  --text-primary: #333333;
  --text-secondary: #666666;
  --accent: #FF3B30;
  --accent-light: #FF6259;
  --accent-dark: #CC2F26;
  --success: #34C759;
  --error: #FF3B30;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.16);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 24px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
}

@media (prefers-color-scheme: dark) {
  :root {
      --bg-primary: #121212;
      --bg-secondary: #1e1e1e;
      --text-primary: #ffffff;
      --text-secondary: #b3b3b3;
      --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
      --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.25);
      --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.3);
  }
}

/* General Reset Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  transition: all 0.3s ease; /* Using 0.3s for consistency */
}

/* Upload Page Styles */
.upload-page {
  font-family: 'Poppins', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: var(--space-lg);
  overflow-x: hidden;
}

.upload-page .container {
  width: 100%;
  max-width: 480px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
  transform: translateZ(0);
}

.upload-page .header {
  margin-bottom: var(--space-xl);
  text-align: center;
}

.upload-page .logo-container {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-md);
  position: relative;
}

.upload-page .logo {
  height: 64px;
  width: 64px;
  background: var(--accent);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: white;
  box-shadow: 0 8px 20px rgba(255, 59, 48, 0.3);
}

.upload-page .logo-spark {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0;
}

.upload-page .spark-1 {
  top: -5px;
  right: -5px;
  animation: sparkle 3s infinite 0.2s;
}

.upload-page .spark-2 {
  top: 10px;
  right: -15px;
  animation: sparkle 3s infinite 0.5s;
}

.upload-page .spark-3 {
  bottom: 0;
  right: -5px;
  animation: sparkle 3s infinite 0.8s;
}

.upload-page h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: var(--space-xs);
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.upload-page p {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.5;
  max-width: 320px;
  margin: 0 auto;
}

/* Recipe Page Styles */
.recipe-page {
  font-family: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  padding: 0;
  margin: 0;
  line-height: 1.6;
  padding-bottom: 80px; /* Space for fixed button */
}

.recipe-page .container {
  padding: 20px;
  max-width: 800px;
  margin: 0 auto;
  margin-bottom: 200px;
}

.recipe-page h1 {
  font-size: 45px;
  margin-bottom: 15px;
  color: var(--accent);
  text-transform: capitalize;
  line-height: 50px;
}

.recipe-page p {
  margin-bottom: 15px;
  color: var(--text-secondary);
}

.recipe-page .meta-info {
  margin-bottom: 20px;
}

.recipe-page .meta-info p {
  margin-bottom: 0px;
}

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

.recipe-page h2 {
  font-size: 20px;
  margin: 25px 0 15px 0;
  color: var(--text-primary);
}

.recipe-page ul,
.recipe-page ol {
  padding-left: 25px;
  margin-bottom: 20px;
}

.recipe-page li {
  margin-bottom: 10px;
  line-height: 1.3;
}

.recipe-page img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  margin: 15px 0;
}

/* Unique Styles for Upload Page */
.upload-area {
  background: linear-gradient(145deg, rgba(255, 59, 48, 0.03), rgba(255, 59, 48, 0.08));
  border: 2px dashed rgba(255, 59, 48, 0.2);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  text-align: center;
  cursor: pointer;
  margin-bottom: var(--space-lg);
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.upload-area:hover {
  transform: translateY(-4px);
  background: linear-gradient(145deg, rgba(255, 59, 48, 0.06), rgba(255, 59, 48, 0.12));
  border-color: var(--accent-light);
  box-shadow: var(--shadow-md);
}

.upload-area:active {
  transform: translateY(0);
  background: linear-gradient(145deg, rgba(255, 59, 48, 0.1), rgba(255, 59, 48, 0.15));
}

.upload-icon {
  font-size: 48px;
  color: var(--accent);
  margin-bottom: var(--space-md);
  filter: drop-shadow(0 4px 6px rgba(255, 59, 48, 0.2));
}

.upload-text {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: var(--space-xs);
}

.upload-hint {
  font-size: 13px;
  color: var(--text-secondary);
  font-style: italic;
}

.upload-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.files-container {
  margin: var(--space-lg) 0;
}

.files-counter {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
  font-size: 14px;
  color: var(--text-secondary);
}

.clear-all {
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.clear-all:hover {
  background: rgba(255, 59, 48, 0.08);
}

.clear-all i {
  margin-right: 4px;
  font-size: 12px;
}

.thumbnails-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}

.thumbnail-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 1;
  box-shadow: var(--shadow-sm);
  transform: translateZ(0);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.thumbnail-item:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
  z-index: 1;
}

.thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: filter 0.3s ease;
}

.thumbnail-item:hover .thumbnail {
  filter: brightness(1.1);
}

.thumbnail-delete {
  position: absolute;
  top: var(--space-xs);
  right: var(--space-xs);
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.thumbnail-item:hover .thumbnail-delete {
  opacity: 1;
  transform: scale(1);
}

.thumbnail-delete:hover {
  background: var(--error);
}

.file-info {
  font-size: 12px;
  color: white;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
  padding: var(--space-sm) var(--space-xs) var(--space-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  opacity: 0;
  transform: translateY(5px);
  transition: all 0.2s ease;
}

.thumbnail-item:hover .file-info {
  opacity: 1;
  transform: translateY(0);
}

.submit-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: white;
  border: none;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-sm);
  position: relative;
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(255, 59, 48, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.submit-btn:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(255, 59, 48, 0.4);
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
}

.submit-btn:active {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 59, 48, 0.3);
}

.submit-btn:disabled {
  background: linear-gradient(135deg, rgba(255, 59, 48, 0.3), rgba(255, 98, 89, 0.3));
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  color: rgba(255, 255, 255, 0.6);
}

.submit-btn i {
  transition: transform 0.3s ease;
}

.submit-btn:hover i {
  transform: translateY(-2px);
}

.loader {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.2s ease;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  will-change: opacity;
}

.loader.active {
  display: flex;
  opacity: 1;
}

.loader-spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top: 3px solid var(--accent);
  -webkit-animation: spin 1s linear infinite;
  animation: spin 1s linear infinite;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  will-change: transform;
}

.loader-text {
  margin-top: 16px;
  font-size: 16px;
  font-weight: 500;
  color: #fff;
  text-align: center;
  opacity: 0;
  transform: translateY(10px);
  -webkit-transform: translateY(10px);
  animation: loaderTextFloat 3s ease-in-out infinite;
  will-change: transform, opacity;
}

.loader.active .loader-text {
  opacity: 1;
  animation: fadeInAndFloat 1.5s ease forwards, loaderTextFloat 3s ease-in-out infinite;
}

.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  transform: scale(0);
  animation: ripple 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.float-animation {
  animation: float 6s ease-in-out infinite;
}

.blob {
  position: absolute;
  background: linear-gradient(135deg, rgba(255, 59, 48, 0.2), rgba(255, 98, 89, 0.1));
  border-radius: 50%;
  filter: blur(40px);
  z-index: -1;
  animation: blob-pulse 15s infinite alternate;
}

.blob-1 {
  width: 300px;
  height: 300px;
  top: -150px;
  right: -150px;
}

.blob-2 {
  width: 200px;
  height: 200px;
  bottom: -100px;
  left: -100px;
  animation-delay: 5s;
}

/* Unique Styles for Recipe Page */
.recipe-page .copy-button-container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to bottom, transparent, rgba(250, 250, 250, 0.8) 20%);
  padding: 15px 20px;
  padding-top: 50px;
  margin-top: -35px;
  z-index: 1000;
  display: flex;
  gap: 10px;
  align-items: center;
  max-width: 100%;
  box-sizing: border-box;
}

@media (prefers-color-scheme: dark) {
  .recipe-page .copy-button-container {
    background: linear-gradient(to bottom, transparent, rgba(18, 18, 18, 0.8) 20%);
  }
}

.copy-button {
  background: #8E8E93;
  color: white;
  border: none;
  border-radius: 10px;
  padding: 14px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  width: auto;
  margin-bottom: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.copy-button:hover {
  background: #636366;
}

.copy-button:active {
  transform: scale(0.98);
}

.recipe-page #copyButton {
  width: 50px;
  min-width: 50px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.recipe-page #copyButton i {
  font-size: 18px;
}

.recipe-page #newRecipeButton {
  background: rgba(255, 59, 48, 0.9);
  flex-grow: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.recipe-page #newRecipeButton:hover {
  background: rgba(255, 98, 89, 0.9);
}

/* Tooltip Styles */
.copy-tooltip {
  position: absolute;
  bottom: calc(100%);
  left: 100%;
  transform: translateX(-50%) translateY(10px);
  background: var(--accent);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  margin-bottom: 8px;
  z-index: 1001;
  pointer-events: none;
}

.copy-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 25%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: var(--accent) transparent transparent transparent;
}

.copy-tooltip.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Keyframes */
@keyframes sparkle {
  0% { transform: scale(0); opacity: 0; }
  20% { transform: scale(1); opacity: 1; }
  40% { transform: scale(0); opacity: 0; }
  100% { transform: scale(0); opacity: 0; }
}

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

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

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

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

@keyframes ripple {
  to {
      transform: scale(4);
      opacity: 0;
  }
}

@keyframes float {
  0% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
  100% { transform: translateY(0); }
}

@keyframes blob-pulse {
  0% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.3) rotate(20deg); opacity: 0.8; }
  100% { transform: scale(1) rotate(0deg); opacity: 0.5; }
}

@keyframes loaderTextFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

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

/* Media Queries */
@media (max-width: 480px) {
  .upload-page .container {
      padding: var(--space-lg);
  }
  
  .upload-page .thumbnails-container {
      grid-template-columns: repeat(2, 1fr);
  }
  
  .upload-page h1 {
      font-size: 24px;
  }
  
  .upload-page p {
      font-size: 14px;
  }

  .recipe-page .copy-button-container {
    padding: 12px 16px;
    padding-top: 40px;
    gap: 8px;
  }

  .copy-button {
    padding: 12px;
    font-size: 15px;
  }

  .recipe-page #copyButton {
    width: 44px;
    min-width: 44px;
    padding: 12px;
  }

  .recipe-page #copyButton i {
    font-size: 16px;
  }
}