:root {
  --primary-color: #4a90e2;
  --secondary-color: #ff6b6b;
  --ai-color: #8a4fff;
  --background-color: #ffffff;
  --text-color: #2d3436;
  --accent-color: #f0f7ff;
  --card-bg: #ffffff;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.dark-mode {
  --background-color: #1a1a1a;
  --text-color: #ffffff;
  --accent-color: #2d3436;
  --card-bg: #2a2a2a;
  --shadow: 0 4px 6px rgba(255, 255, 255, 0.1);
}

body {
  font-family: "Poppins", sans-serif;
  margin: 0;
  padding: 2rem;
  background-color: var(--background-color);
  color: var(--text-color);
  transition: var(--transition);
  min-height: 100vh;
  background-image: linear-gradient(
    135deg,
    var(--accent-color) 0%,
    var(--background-color) 100%
  );
}

h1 {
  font-size: 2.5rem;
  margin-bottom: 2rem;
  background: linear-gradient(45deg, #4a90e2, #6c5ce7);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: titleFloat 3s ease-in-out infinite;
  text-align: center;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.container {
  display: flex;
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  align-items: flex-start;
  background: var(--card-bg);
  border-radius: 25px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.camera-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 50%;
}

.text-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 50%;
  height: 70vh;
}

video,
#capturedImage {
  width: 100%;
  border-radius: 20px;
  border: 3px solid var(--primary-color);
  box-shadow: var(--shadow);
  aspect-ratio: 4/3;
  object-fit: cover;
  background: #000;
}

.button-container {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1rem;
  position: relative;
}

button {
  padding: 1rem 2rem;
  border: none;
  border-radius: 15px;
  cursor: pointer;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: var(--transition);
  background: linear-gradient(45deg, var(--primary-color), #6c5ce7);
  color: white;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.9rem;
}

button#retake {
  background: linear-gradient(45deg, var(--secondary-color), #ff7675);
}

button#copyClipboard {
  background: linear-gradient(45deg, #2ecc71, #27ae60);
  padding: 1rem 1.5rem;
}

button#toggleCamera {
  background: linear-gradient(45deg, #9b59b6, #8e44ad);
  padding: 1rem;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* AI Summary Button Container */
.ai-summary-container {
  position: relative;
  display: inline-block;
}

button#aiSummaryBtn {
  background: linear-gradient(45deg, var(--ai-color), #6a11cb);
  padding: 1rem 1.5rem;
  position: relative;
  z-index: 2;
}

/* Model Toggle Styles */
.model-toggle {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  background: var(--card-bg);
  border-radius: 15px;
  padding: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  display: none;
  z-index: 100;
  width: 100%;
  border: 1px solid rgba(138, 79, 255, 0.2);
  animation: fadeIn 0.3s ease;
}

.dark-mode .model-toggle {
  background: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.model-toggle.visible {
  display: block;
}

.model-option {
  padding: 10px 15px;
  border-radius: 10px;
  cursor: pointer;
  margin: 5px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

.model-option:hover {
  background: rgba(138, 79, 255, 0.1);
}

.model-option.active {
  background: rgba(138, 79, 255, 0.2);
  color: var(--ai-color);
  font-weight: 500;
}

.model-option i {
  width: 20px;
  text-align: center;
}

button:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#extractedText {
  white-space: pre-wrap;
  background: var(--accent-color);
  padding: 1.5rem;
  border-radius: 15px;
  border: 2px dashed var(--primary-color);
  height: 100%;
  overflow-y: auto;
  font-family: "Courier New", monospace;
  font-size: 1.1rem;
  animation: textAppear 0.5s ease-out;
  line-height: 1.6;
}

.search-box {
  display: flex;
  gap: 1rem;
  margin-top: auto;
  position: relative;
}

#searchText {
  padding: 1rem;
  border-radius: 15px;
  border: 2px solid var(--primary-color);
  width: 100%;
  transition: var(--transition);
  background: var(--background-color);
  color: var(--text-color);
  font-family: "Poppins", sans-serif;
  font-size: 1rem;
}

.dark-mode-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  font-size: 1.5rem;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--text-color);
  transition: var(--transition);
  z-index: 100;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.enter-hint {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 8px 15px;
  border-radius: 20px;
  font-size: 0.9rem;
  animation: floatBubble 2s infinite;
  white-space: nowrap;
}

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

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

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

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

.ai-summary-section {
  margin-top: 2rem;
  padding: 1.5rem;
  background: var(--card-bg);
  border-radius: 20px;
  box-shadow: var(--shadow);
  border: 2px solid var(--ai-color);
  max-width: 1200px;
  margin: 2rem auto;
  display: none;
}

.ai-summary-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 1rem;
}

.ai-summary-icon {
  font-size: 1.8rem;
  color: var(--ai-color);
}

.ai-summary-content {
  font-family: "Inter", sans-serif;
  font-size: 1.1rem;
  line-height: 1.6;
  padding: 1.5rem;
  background: rgba(138, 79, 255, 0.05);
  border-radius: 15px;
  min-height: 100px;
  border-left: 4px solid var(--ai-color);
}

.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(138, 79, 255, 0.3);
  border-radius: 50%;
  border-top-color: var(--ai-color);
  animation: spin 1s ease-in-out infinite;
  margin-right: 10px;
}

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

.tts-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 15px;
  display: none;
}

.tts-controls.visible {
  display: flex;
}

#speakBtn {
  background: var(--ai-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
}

#speakBtn:hover {
  transform: scale(1.1);
}

#speedControl {
  padding: 5px 10px;
  border-radius: 15px;
  border: 1px solid var(--ai-color);
  background: var(--background-color);
  color: var(--text-color);
}

.model-info {
  margin-top: 10px;
  padding: 10px;
  background: rgba(138, 79, 255, 0.05);
  border-radius: 10px;
  font-size: 0.85rem;
  display: none;
}

.model-info.visible {
  display: block;
}

.app-footer {
  text-align: center;
  margin-top: 2rem;
  padding: 1rem;
  color: var(--text-color);
  opacity: 0.7;
  font-size: 0.9rem;
}

@media (max-width: 768px) {
  .container {
    flex-direction: column;
    padding: 1rem;
  }

  .camera-column,
  .text-column {
    width: 100%;
  }

  h1 {
    font-size: 2rem;
  }

  #extractedText {
    height: 300px;
  }

  .enter-hint {
    display: none;
  }

  .button-container {
    flex-wrap: wrap;
  }

  .search-box {
    flex-direction: column;
  }

  .search-box button {
    width: 100%;
  }

  .ai-summary-container {
    width: 100%;
  }

  body {
    padding: 1rem;
  }
}
