/* Modern QR Code Generator - shadcn/ui inspired design */

:root {
  --background: 0 0% 100%;
  --foreground: 222.2 84% 4.9%;
  --card: 0 0% 100%;
  --card-foreground: 222.2 84% 4.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 222.2 84% 4.9%;
  --primary: 222.2 47.4% 11.2%;
  --primary-foreground: 210 40% 98%;
  --secondary: 210 40% 96%;
  --secondary-foreground: 222.2 84% 4.9%;
  --muted: 210 40% 96%;
  --muted-foreground: 215.4 16.3% 46.9%;
  --accent: 210 40% 96%;
  --accent-foreground: 222.2 84% 4.9%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 210 40% 98%;
  --border: 214.3 31.8% 91.4%;
  --input: 214.3 31.8% 91.4%;
  --ring: 222.2 84% 4.9%;
  --radius: 0.5rem;
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  margin: 0;
  padding: 2rem 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  max-width: 42rem;
  margin: 0 auto;
}

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

.header h1 {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 0 0 0.5rem 0;
  color: hsl(var(--foreground));
}

.subtitle {
  color: hsl(var(--muted-foreground));
  font-size: 1.125rem;
  margin: 0;
}

.card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  padding: 1.5rem;
}

.form-section {
  margin-bottom: 2rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: hsl(var(--foreground));
}

.select,
.input,
.textarea {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid hsl(var(--input));
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  transition: border-color 0.2s, box-shadow 0.2s;
}

.select:focus,
.input:focus,
.textarea:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

.textarea {
  resize: vertical;
  min-height: 6rem;
}

.input-fields {
  margin-bottom: 1.5rem;
}

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

/* Format selection styling */
#downloadFormat {
  background: transparent;
  //border-color: hsl(var(--primary) / 0.3);
  font-weight: 500;
}

#downloadFormat:focus {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 2px hsl(var(--primary) / 0.2);
}

.color-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border: 1px solid hsl(var(--input));
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--background));
  transition: border-color 0.2s, box-shadow 0.2s;
}

.color-input-wrapper:focus-within {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

.color-input {
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
  background: none;
  padding: 0;
}

.color-input::-webkit-color-swatch-wrapper {
  padding: 0;
  border-radius: calc(var(--radius) - 4px);
}

.color-input::-webkit-color-swatch {
  border: none;
  border-radius: calc(var(--radius) - 4px);
}

.color-value {
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  width: 100%;
  margin-bottom: 1rem;
}

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

.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}

.btn-primary:hover:not(:disabled) {
  background: hsl(var(--primary) / 0.9);
}

.btn-secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border-color: hsl(var(--border));
}

.btn-secondary:hover:not(:disabled) {
  background: hsl(var(--secondary) / 0.8);
}

.icon {
  width: 1rem;
  height: 1rem;
}

.qr-display {
  text-align: center;
  margin: 2rem 0;
  padding: 2rem;
  background: hsl(var(--muted));
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
}

.qr-display img {
  max-width: 100%;
  height: auto;
  border-radius: calc(var(--radius) - 2px);
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.qr-display:empty {
  display: none;
}

/* Checkbox styling for WiFi hidden network */
input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin-right: 0.5rem;
  accent-color: hsl(var(--primary));
}

/* Responsive design */
@media (max-width: 640px) {
  body {
    padding: 1rem 0.5rem;
  }
  
  .header h1 {
    font-size: 1.875rem;
  }
  
  .subtitle {
    font-size: 1rem;
  }
  
  .card {
    padding: 1rem;
  }
  
  .settings-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  .color-input-wrapper {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}

/* Focus styles for accessibility */
.select:focus-visible,
.input:focus-visible,
.textarea:focus-visible,
.btn:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

/* Loading state */
.btn.loading {
  position: relative;
  color: transparent;
}

.btn.loading::after {
  content: "";
  position: absolute;
  width: 1rem;
  height: 1rem;
  border: 2px solid hsl(var(--primary-foreground));
  border-top: 2px solid transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* QR Actions */
.qr-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.qr-actions .btn {
  flex: 1;
  min-width: 120px;
  margin-bottom: 0;
}

/* Scanner Modal */
.scanner-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.scanner-content {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 10px 25px -3px rgb(0 0 0 / 0.1), 0 4px 6px -2px rgb(0 0 0 / 0.05);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow: hidden;
}

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

.scanner-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.close-btn {
  background: none;
  border: none;
  padding: 0.5rem;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  color: hsl(var(--muted-foreground));
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn:hover {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}

.close-btn svg {
  width: 1.25rem;
  height: 1.25rem;
}

.scanner-body {
  padding: 1.5rem;
}

.scanner-container {
  position: relative;
  width: 100%;
  height: 300px;
  border-radius: var(--radius);
  overflow: hidden;
  background: hsl(var(--muted));
  border: 1px solid hsl(var(--border));
}

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

.scanner-result,
.scanner-error {
  text-align: center;
  padding: 2rem 1rem;
}

.result-success,
.result-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.result-success .icon,
.result-error .icon {
  width: 3rem;
  height: 3rem;
  color: hsl(var(--destructive));
}

.result-success .icon {
  color: #10b981;
}

.result-success h4,
.result-error h4 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
}

.result-success p,
.result-error p {
  margin: 0;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
  word-break: break-all;
  background: hsl(var(--muted));
  padding: 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid hsl(var(--border));
}

.scanner-footer {
  padding: 1.5rem;
  border-top: 1px solid hsl(var(--border));
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.scanner-footer .btn {
  margin-bottom: 0;
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .qr-actions {
    flex-direction: column;
  }
  
  .qr-actions .btn {
    flex: none;
    min-width: auto;
  }
  
  .scanner-content {
    width: 95%;
    margin: 1rem;
  }
  
  .scanner-container {
    height: 250px;
  }
}