/* Base Styles */
:root {
  --background: #ffffff;
  --foreground: #0f172a;
  --card: #ffffff;
  --card-foreground: #0f172a;
  --primary: #3b82f6;
  --primary-foreground: #ffffff;
  --secondary: #f1f5f9;
  --secondary-foreground: #1e293b;
  --muted: #f1f5f9;
  --muted-foreground: #64748b;
  --accent: #f1f5f9;
  --accent-foreground: #1e293b;
  --destructive: #ef4444;
  --destructive-foreground: #ffffff;
  --success: #22c55e;
  --success-foreground: #ffffff;
  --border: #e2e8f0;
  --input: #e2e8f0;
  --ring: #3b82f6;
  --radius: 0.5rem;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.dark {
  --background: #0f172a;
  --foreground: #f8fafc;
  --card: #1e293b;
  --card-foreground: #f8fafc;
  --primary: #3b82f6;
  --primary-foreground: #0f172a;
  --secondary: #334155;
  --secondary-foreground: #f8fafc;
  --muted: #334155;
  --muted-foreground: #94a3b8;
  --accent: #334155;
  --accent-foreground: #f8fafc;
  --destructive: #7f1d1d;
  --destructive-foreground: #f8fafc;
  --success: #166534;
  --success-foreground: #f8fafc;
  --border: #334155;
  --input: #334155;
  --ring: #3b82f6;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--background);
  color: var(--foreground);
  line-height: 1.5;
  transition: background-color 0.3s, color 0.3s;
}

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

h1 {
  font-size: 1.875rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Navbar */
.navbar {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
  background-color: var(--card);
}

.navbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--foreground);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo:hover {
  text-decoration: none;
}

nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  color: var(--muted-foreground);
  text-decoration: none;
}

.nav-link:hover {
  background-color: var(--secondary);
  color: var(--secondary-foreground);
  text-decoration: none;
}

.nav-link.active {
  background-color: var(--primary);
  color: var(--primary-foreground);
}

.nav-link i {
  margin-right: 0.5rem;
}

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-foreground);
  position: relative;
}

.theme-toggle:hover {
  background-color: var(--secondary);
  color: var(--secondary-foreground);
}

.theme-toggle .fa-sun {
  display: block;
}

.theme-toggle .fa-moon {
  display: none;
}

.dark .theme-toggle .fa-sun {
  display: none;
}

.dark .theme-toggle .fa-moon {
  display: block;
}

/* Main Content */
main.container {
  padding-top: 2rem;
  padding-bottom: 2rem;
}

.header-section {
  text-align: center;
  margin-bottom: 2rem;
}

.header-section p {
  color: var(--muted-foreground);
}

/* Cards */
.card {
  background-color: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.image-card {
  padding-bottom: 1rem;
}

/* Image Container */
.image-container {
  height: 400px;
  background-color: var(--muted);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted-foreground);
  width: 100%;
  height: 100%;
  transition: background-color 0.2s;
}

.placeholder:hover {
  background-color: var(--secondary);
}

.placeholder-icon {
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  background-color: var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.placeholder-icon i {
  font-size: 1.5rem;
}

.preview-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Camera */
.camera-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

#camera-view {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-controls {
  position: absolute;
  bottom: 1rem;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1.5rem;
}

.camera-button {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.6);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.capture-button {
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.3);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.capture-button-inner {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background-color: white;
}

/* Capture Preview */
.capture-preview {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--background);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.capture-actions {
  position: absolute;
  bottom: 1rem;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 2rem;
  padding: 0 1.5rem;
}

.action-button {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.25rem;
}

.action-button.cancel {
  background-color: var(--destructive);
  color: var(--destructive-foreground);
}

.action-button.confirm {
  background-color: var(--success);
  color: var(--success-foreground);
}

/* Camera error message */
.camera-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  padding: 2rem;
  text-align: center;
}

.camera-error p {
  margin-bottom: 1.5rem;
  color: var(--muted-foreground);
  font-size: 1.1rem;
}

/* Loading */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted-foreground);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 10;
}

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

.loading p {
  color: white;
  font-weight: 500;
}

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

/* Tabs */
.tabs {
  margin-bottom: 1.5rem;
}

.tab-header {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.tab-button {
  padding: 0.75rem;
  background-color: var(--secondary);
  color: var(--secondary-foreground);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 500;
  transition: background-color 0.2s;
}

.tab-button.active {
  background-color: var(--primary);
  color: var(--primary-foreground);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Buttons */
.button-container {
  display: flex;
  justify-content: center;
}

.primary-button {
  background-color: var(--primary);
  color: var(--primary-foreground);
  border: none;
  border-radius: var(--radius);
  padding: 0.75rem 1.5rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 10rem;
}

.primary-button i {
  margin-right: 0.5rem;
}

.secondary-button {
  background-color: var(--secondary);
  color: var(--secondary-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1.5rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.secondary-button i {
  margin-right: 0.5rem;
}

.danger-button {
  background-color: var(--destructive);
  color: var(--destructive-foreground);
  border: none;
  border-radius: var(--radius);
  padding: 0.75rem 1.5rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.danger-button i {
  margin-right: 0.5rem;
}

.small {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
}

.icon-button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted-foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
}

.icon-button:hover {
  color: var(--foreground);
}

/* Result actions */
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

/* How it works */
ol {
  padding-left: 1.5rem;
  margin-bottom: 1.5rem;
}

ol li {
  margin-bottom: 0.5rem;
}

.powered-by {
  text-align: center;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

/* Gallery */
.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.gallery-actions {
  display: flex;
  gap: 0.5rem;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.gallery-item {
  background-color: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.gallery-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.gallery-image {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.gallery-date {
  padding: 0.75rem;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.empty-gallery {
  text-align: center;
  padding: 3rem 1rem;
}

.empty-icon {
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
  background-color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
}

.empty-icon i {
  font-size: 2rem;
  color: var(--muted-foreground);
}

.empty-gallery h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--foreground);
}

.empty-gallery p {
  color: var(--muted-foreground);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-content {
  background-color: var(--card);
  border-radius: var(--radius);
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

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

.close-button {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted-foreground);
}

.modal-body {
  flex: 1;
  overflow: auto;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body img {
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
}

.modal-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Settings */
.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
}

.setting-text {
  flex: 1;
}

.setting-text label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.setting-text p {
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.toggle-switch {
  position: relative;
  width: 3rem;
  height: 1.5rem;
}

.toggle-input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-label {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--muted);
  transition: .4s;
  border-radius: 1.5rem;
}

.toggle-label:before {
  position: absolute;
  content: "";
  height: 1.25rem;
  width: 1.25rem;
  left: 0.125rem;
  bottom: 0.125rem;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

.toggle-input:checked + .toggle-label {
  background-color: var(--primary);
}

.toggle-input:checked + .toggle-label:before {
  transform: translateX(1.5rem);
}

.divider {
  height: 1px;
  background-color: var(--border);
  margin: 0.5rem 0;
}

.info-text {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  margin-bottom: 1rem;
}

.info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
}

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

.info-value {
  color: var(--muted-foreground);
}

.info-link {
  display: flex;
  align-items: center;
}

.info-link i {
  font-size: 0.75rem;
  margin-left: 0.25rem;
}

/* API Key Input */
.api-key-container {
  display: flex;
  align-items: center;
}

.api-key-input {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--input);
  color: var(--foreground);
}

/* Responsive */
@media (max-width: 768px) {
  .nav-link span {
    display: none;
  }

  .nav-link i {
    margin-right: 0;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .setting-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .toggle-switch {
    margin-top: 0.5rem;
  }

  .result-actions {
    flex-direction: column;
    align-items: center;
  }

  .result-actions button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .tab-header {
    grid-template-columns: 1fr;
  }

  .gallery-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .modal-footer {
    flex-direction: column;
  }

  .modal-footer button {
    width: 100%;
  }

  .capture-actions {
    gap: 1rem;
  }
}

