/* ==========================================================================
   QR Code Studio Pro — Precision UI Components
   ========================================================================== */

/* Cards */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm), var(--inner-highlight);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.card-desc {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.card-body {
  padding: 20px;
  min-width: 0;
}

/* Step Number Pill in Studio Headers */
.step-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-index {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent-primary-soft);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: #C4B5FD;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 15px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

.btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

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

.btn-sm {
  height: 34px;
  padding: 0 12px;
  font-size: 12.5px;
}

.btn-xs {
  height: 29px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-primary {
  background: linear-gradient(180deg, #9466FF 0%, #7C3AED 100%);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  color: #FFFFFF;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #9D74FF 0%, #8347F2 100%);
  box-shadow: 0 6px 18px rgba(139, 92, 246, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.btn-secondary {
  background-color: var(--bg-elevated);
  border-color: var(--border-strong);
  box-shadow: var(--inner-highlight);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background-color: #212839;
  border-color: rgba(255, 255, 255, 0.22);
}

.btn-outline {
  background-color: rgba(255, 255, 255, 0.02);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-outline:hover:not(:disabled) {
  background-color: rgba(34, 211, 238, 0.08);
  border-color: rgba(34, 211, 238, 0.55);
  color: var(--accent-secondary);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background-color: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.btn-danger {
  background: linear-gradient(180deg, #F05252 0%, #DC2626 100%);
  border-color: rgba(255, 255, 255, 0.14);
  color: #FFFFFF;
}

.btn-danger:hover:not(:disabled) {
  background: linear-gradient(180deg, #F86464 0%, #E02E2E 100%);
}

.icon-btn {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.icon-btn svg {
  width: 17px;
  height: 17px;
}

.icon-btn:hover {
  background-color: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.text-btn {
  background: none;
  border: none;
  color: var(--accent-secondary);
  font-size: 12px;
  font-weight: 500;
  padding: 2px 4px;
}

.text-btn:hover {
  text-decoration: underline;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-purple {
  background: var(--accent-primary-soft);
  color: #C4B5FD;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.badge-cyan {
  background: var(--accent-secondary-soft);
  color: var(--accent-secondary);
  border: 1px solid rgba(34, 211, 238, 0.25);
}

.badge-neutral {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

/* Form Controls */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.form-row-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.form-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.form-label .required {
  color: var(--accent-primary);
  margin-left: 3px;
}

.input,
.select,
.textarea {
  width: 100%;
  min-width: 0;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 9px 12px;
  font-size: 13px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
}

.input,
.select {
  height: 38px;
}

.input-sm,
.select-sm {
  height: 32px;
  padding: 4px 10px;
  font-size: 12.5px;
}

.textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.5;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  background-color: #0E121B;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-primary-soft);
}

.input.is-invalid,
.textarea.is-invalid,
.select.is-invalid {
  border-color: var(--danger);
}

.field-error {
  font-size: 11.5px;
  color: #FCA5A5;
  display: flex;
  align-items: center;
  gap: 5px;
}

.field-hint {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Checkbox & Switch */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
}

.toggle-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.toggle-title {
  font-size: 12.5px;
  font-weight: 500;
}

.toggle-desc {
  font-size: 11px;
  color: var(--text-muted);
}

.switch {
  position: relative;
  width: 38px;
  height: 21px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  transition: background-color var(--transition-fast);
  cursor: pointer;
}

.switch-slider::before {
  content: '';
  position: absolute;
  width: 15px;
  height: 15px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background-color: #FFFFFF;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: transform var(--transition-fast);
}

.switch input:checked + .switch-slider {
  background-color: var(--accent-primary);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(17px);
}

/* Range Slider */
.range-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.range-value {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  padding: 1px 7px;
  border-radius: var(--radius-sm);
}

.range-input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  outline: none;
}

.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid #FFFFFF;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.range-input::-webkit-slider-thumb:hover {
  transform: scale(1.14);
}

/* Color Picker Control (Overflow-Proof) */
.color-field {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 5px 10px 5px 6px;
  height: 38px;
  transition: border-color var(--transition-fast);
}

.color-field:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-primary-soft);
}

.color-swatch {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border: none;
  border-radius: 6px;
  padding: 0;
  background: none;
  cursor: pointer;
}

.color-swatch::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-swatch::-webkit-color-swatch {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
}

.color-hex {
  flex: 1;
  width: 100%;
  min-width: 0;
  background: transparent;
  border: none;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-primary);
  text-transform: uppercase;
}

.color-hex:focus {
  outline: none;
}

/* Alerts */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
  line-height: 1.45;
}

.alert svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  margin-top: 2px;
}

.alert-warning {
  background: var(--warning-soft);
  border: 1px solid rgba(245, 158, 11, 0.32);
  color: #FDE68A;
}

/* Popovers & Dropdowns */
.popover-anchor {
  position: relative;
}

.popover-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 300px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), var(--inner-highlight);
  z-index: 60;
  overflow: hidden;
}

.popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12.5px;
  font-weight: 600;
}

.popover-body {
  max-height: 280px;
  overflow-y: auto;
  padding: 8px;
}

.notification-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-secondary);
  box-shadow: 0 0 8px var(--accent-secondary);
}

.notification-item {
  padding: 9px 10px;
  border-radius: var(--radius-md);
  font-size: 12.5px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.notification-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.notification-time {
  font-size: 11px;
  color: var(--text-muted);
}

.profile-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 10px 4px 5px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.profile-chip:hover {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}

.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: #080A0F;
  font-weight: 700;
  font-size: 10.5px;
  display: grid;
  place-items: center;
}

.profile-meta {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.2;
}

.profile-name {
  font-size: 12px;
  font-weight: 600;
}

.profile-role {
  font-size: 10px;
  color: var(--text-muted);
}

.profile-chevron {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}

.profile-panel-header {
  padding: 14px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.profile-panel-header span {
  font-size: 11.5px;
  color: var(--text-secondary);
}

.profile-panel-actions {
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.menu-action {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px;
  text-align: left;
}

.menu-action svg {
  width: 15px;
  height: 15px;
}

.menu-action:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

/* Search Dropdown */
.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  max-height: 320px;
  overflow-y: auto;
  z-index: 65;
}

.search-result-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  text-align: left;
  color: var(--text-primary);
}

.search-result-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.search-result-title {
  font-size: 13px;
  font-weight: 500;
}

.search-result-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.75);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 100;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), var(--inner-highlight);
  overflow: hidden;
}

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

.modal-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
}

.modal-body {
  padding: 20px;
  color: var(--text-secondary);
  font-size: 13.5px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Toasts */
.toast-container {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 110;
  max-width: 360px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md), var(--inner-highlight);
  animation: toastIn 180ms ease-out;
}

.toast svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-success svg { color: var(--success); }
.toast-error svg { color: var(--danger); }
.toast-warning svg { color: var(--warning); }
.toast-info svg { color: var(--accent-secondary); }

.toast-content {
  flex: 1;
  font-size: 13px;
}

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

/* Empty State */
.empty-state {
  padding: 40px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.empty-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.14), rgba(34, 211, 238, 0.08));
  border: 1px solid rgba(139, 92, 246, 0.25);
  display: grid;
  place-items: center;
  color: #C4B5FD;
}

.empty-icon svg {
  width: 22px;
  height: 22px;
}

.empty-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.empty-desc {
  margin: 0;
  max-width: 360px;
  color: var(--text-secondary);
  font-size: 12.5px;
}
