/* General variables & tokens */
:root {
  --font-family: 'Outfit', sans-serif;
  --bg-primary: #f6f8fc;
  --bg-surface: #ffffff;
  --text-primary: #0b152d;
  --text-secondary: #57657d;
  --accent-color: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #e0ebff;
  --border-color: #e2e8f0;
  --input-bg: #f8fafc;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.04);
  --qr-placeholder-bg: #eff3f9;
}

.dark-theme {
  --bg-primary: #0b0f19;
  --bg-surface: #131b2e;
  --text-primary: #f8fafc;
  --text-secondary: #8a9cb8;
  --accent-color: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-light: #1e293b;
  --border-color: #242f47;
  --input-bg: #0b0f19;
  --qr-placeholder-bg: #1a2336;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

.app-container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.mobile-header {
  display: none;
}

.desktop-header-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 24px;
  width: 100%;
}

.main-content {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 40px;
  align-items: start;
}

.config-section {
  display: flex;
  flex-direction: column;
}

.desktop-title {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.desktop-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

/* Tabs styling */
.tabs-container {
  display: flex;
  gap: 8px;
  background: var(--input-bg);
  padding: 6px;
  border-radius: 12px;
  margin-bottom: 24px;
  border: 1px solid var(--border-color);
  width: fit-content;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--bg-surface);
  color: var(--accent-color);
  box-shadow: var(--shadow-sm);
}

/* Input Card styling */
.input-card {
  background: var(--bg-surface);
  padding: 24px;
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 24px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.input-wrapper input,
.input-wrapper textarea {
  width: 100%;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--input-bg);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.input-wrapper input:focus,
.input-wrapper textarea:focus {
  border-color: var(--accent-color);
}

.input-wrapper textarea {
  height: 100px;
  resize: none;
}

.hidden {
  display: none !important;
}

/* Accordion styling */
.accordion-card {
  background: var(--bg-surface);
  border-radius: 16px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.accordion-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: var(--font-family);
  color: var(--text-primary);
  transition: background-color 0.2s;
}

.accordion-header:hover {
  background-color: var(--input-bg);
}

.header-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 600;
}

.chevron {
  transition: transform 0.3s;
}

.accordion-header[aria-expanded="false"] .chevron {
  transform: rotate(-90deg);
}

.accordion-content {
  padding: 0 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.accordion-header[aria-expanded="false"] + .accordion-content {
  display: none;
}

/* Settings section within accordion */
.setting-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

/* Color Pickers */
.color-pickers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.color-picker-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.color-picker-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.picker-input-wrapper {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-color);
  background: var(--input-bg);
  border-radius: 8px;
  padding: 6px;
  gap: 8px;
  height: 48px;
}

.color-preview-box {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  cursor: pointer;
  flex-shrink: 0;
}

.hidden-picker {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.picker-input-wrapper input[type="text"] {
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 14px;
  outline: none;
  width: 100%;
  padding: 4px;
}

.transparent-checkerboard {
  background-image: 
    linear-gradient(45deg, #e2e8f0 25%, transparent 25%), 
    linear-gradient(-45deg, #e2e8f0 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #e2e8f0 75%), 
    linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
  background-size: 10px 10px;
  background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
}

.dark-theme .transparent-checkerboard {
  background-image: 
    linear-gradient(45deg, #242f47 25%, transparent 25%), 
    linear-gradient(-45deg, #242f47 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #242f47 75%), 
    linear-gradient(-45deg, transparent 75%, #242f47 75%);
}

.transparent-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.transparent-btn:hover {
  color: var(--text-primary);
  background: var(--border-color);
}

.transparent-btn.active {
  color: var(--accent-color);
  background: var(--accent-light);
}

/* Pattern styles selectors */
.pattern-options {
  display: flex;
  gap: 12px;
}

.pattern-btn {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.pattern-btn:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.pattern-btn.active {
  border-color: var(--accent-color);
  background: var(--accent-light);
  color: var(--accent-color);
  box-shadow: 0 0 0 2px var(--accent-light);
}

/* Preview Section (Right Column) */
.preview-section {
  background: var(--bg-surface);
  border-radius: 24px;
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  position: sticky;
  top: 40px;
}

.preview-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--text-primary);
}

.qr-preview-container {
  width: 100%;
  max-width: 290px;
  aspect-ratio: 1;
  background: var(--qr-placeholder-bg);
  border-radius: 20px;
  border: 2px dashed var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 16px;
  margin-bottom: 32px;
}

.qr-preview-container.transparent-bg {
  background-image: 
    linear-gradient(45deg, #e2e8f0 25%, transparent 25%), 
    linear-gradient(-45deg, #e2e8f0 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #e2e8f0 75%), 
    linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0px;
}

.dark-theme .qr-preview-container.transparent-bg {
  background-image: 
    linear-gradient(45deg, #242f47 25%, transparent 25%), 
    linear-gradient(-45deg, #242f47 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #242f47 75%), 
    linear-gradient(-45deg, transparent 75%, #242f47 75%);
}

#qr-canvas-holder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#qr-canvas-holder svg,
#qr-canvas-holder canvas {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
}

#qr-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
}

#qr-placeholder span {
  font-size: 13px;
  font-weight: 500;
}

/* Theme Toggle Button */
.theme-toggle {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.theme-toggle:hover {
  background: var(--input-bg);
}

/* Action Buttons */
.actions-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 600;
  padding: 14px 24px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.btn-primary {
  background: #000000;
  color: #ffffff;
  border: 1px solid #000000;
}

.btn-primary:hover {
  opacity: 0.9;
}

.dark-theme .btn-primary {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
}

.secondary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--input-bg);
}

.mobile-only {
  display: none;
}

/* Responsive styling (Mobile Breakpoint) */
@media (max-width: 767px) {
  body {
    background-color: var(--bg-surface);
    align-items: flex-start;
  }

  .app-container {
    padding: 0;
    max-width: 100%;
  }

  .mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-surface);
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .mobile-header .logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 18px;
    color: var(--text-primary);
  }

  .mobile-header .logo svg {
    color: var(--text-primary);
  }

  .desktop-header-actions {
    display: none;
  }

  .main-content {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 20px;
  }

  .config-section {
    order: 2;
  }

  .desktop-title,
  .desktop-subtitle {
    display: none;
  }

  /* Preview on Mobile goes to the top */
  .preview-section {
    display: contents;
  }

  .preview-title {
    display: none;
  }

  .qr-preview-container {
    order: 1;
    max-width: 100%;
    aspect-ratio: auto;
    height: auto;
    padding: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    margin-bottom: 24px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    overflow: hidden;
  }

  #qr-canvas-holder {
    width: 100%;
    height: auto;
    max-width: 260px;
    aspect-ratio: 1;
  }

  .mobile-only {
    display: block;
  }

  #mobile-status-text {
    text-align: center;
  }

  #mobile-status-text h3 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-primary);
  }

  #mobile-status-text p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
  }

  /* Form specific adjustments for mobile */
  .tabs-container {
    width: 100%;
    margin-bottom: 16px;
  }

  .tab-btn {
    flex: 1;
    justify-content: center;
  }

  .input-card {
    padding: 16px;
    margin-bottom: 16px;
  }

  .accordion-card {
    margin-bottom: 24px;
  }

  /* Action buttons below the form on Mobile */
  .config-section::after {
    content: "";
    display: block;
    height: 20px;
  }

  .actions-container {
    order: 3;
    margin-top: 8px;
    padding-bottom: 40px;
  }
}
