/* Import modern premium font */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --bg-dark: #0f1108;
  --bg-card: #181d0d;
  --bg-input: #232a13;
  --accent: #8c9d6b;
  --accent-light: #a6b785;
  --text-primary: #f5f6f3;
  --text-secondary: #a3a89e;
  --border-color: #313a1a;
  --border-focus: #5d6d3f;
  
  --status-synced: #4caf50;
  --status-pending: #ffc107;
  --status-error: #f44336;
  
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --transition-speed: 0.3s;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* Typography utilities */
h1, h2, h3, h4 {
  font-weight: 600;
  letter-spacing: -0.02em;
}

input, textarea, select {
  font-family: var(--font-family);
  font-size: 1rem;
  background-color: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 14px;
  outline: none;
  width: 100%;
  transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

input:focus, textarea:focus, select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(140, 157, 107, 0.2);
}

label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

button {
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 8px;
  padding: 12px 18px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition-speed) ease;
}

/* Button styles */
.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #768757 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(140, 157, 107, 0.2);
}
.btn-primary:active {
  transform: scale(0.97);
}

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

.btn-danger {
  background-color: rgba(244, 67, 54, 0.15);
  border: 1px solid rgba(244, 67, 54, 0.3);
  color: #ff8a80;
}
.btn-danger:active {
  background-color: rgba(244, 67, 54, 0.25);
}

.btn-icon {
  padding: 10px;
  border-radius: 50%;
}

/* App Shell Components */
header {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background-color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--bg-dark);
}

.brand-text {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* View/Screen Management */
.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  padding: 16px;
  animation: fadeIn 0.25s ease-out;
}

.screen.active {
  display: flex;
}

/* Auth / PIN Screen */
#screen-auth {
  justify-content: center;
  align-items: center;
  padding: 30px 20px;
}

.auth-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 30px 24px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.auth-card h2 {
  margin-bottom: 8px;
  font-size: 1.5rem;
}

.auth-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.pin-field-wrapper {
  margin-bottom: 20px;
}

.pin-field-wrapper input {
  text-align: center;
  font-size: 1.5rem;
  letter-spacing: 0.5em;
  padding: 12px;
}

/* Product List Screen */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  position: sticky;
  top: 68px;
  z-index: 90;
  background-color: var(--bg-dark);
  padding: 4px 0 12px 0;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
}

.search-input-wrapper input {
  padding-left: 40px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
}

.product-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 80px; /* space for FAB */
}

.product-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  gap: 14px;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}

.product-card:active {
  transform: scale(0.98);
  border-color: var(--border-focus);
}

.product-thumb {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  object-fit: cover;
  background-color: var(--bg-input);
  flex-shrink: 0;
  border: 1px solid var(--border-color);
}

.product-info {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
  min-width: 0;
}

.product-title {
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.product-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
}

.stock-badge {
  background-color: var(--bg-input);
  color: var(--text-secondary);
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.sync-status-pill {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sync-status-pill.synced {
  background-color: rgba(76, 175, 80, 0.15);
  color: var(--status-synced);
}

.sync-status-pill.pending {
  background-color: rgba(255, 193, 7, 0.15);
  color: var(--status-pending);
}

.sync-status-pill.error {
  background-color: rgba(244, 67, 54, 0.15);
  color: var(--status-error);
}

/* Floating Action Button (FAB) */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, #768757 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  z-index: 95;
  transition: transform 0.2s;
}

.fab:active {
  transform: scale(0.9);
}

/* Form Screen styles */
.form-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.form-header h2 {
  font-size: 1.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Form Tabs */
.form-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
  gap: 4px;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.95rem;
  padding: 10px 16px;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  flex: 1;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.tab-content {
  display: none;
  flex-direction: column;
  gap: 16px;
}

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

/* General fields layout */
.form-group {
  display: flex;
  flex-direction: column;
}

/* Variants subform styling */
.variants-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.variant-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  animation: slideIn 0.2s ease-out;
}

.variant-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.variant-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
}

.variant-grid-fields {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

/* Image/Media layout */
.images-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.image-card {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-input);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.image-card.selected-for-variant {
  border: 2px solid var(--accent);
  box-shadow: 0 0 8px rgba(140, 157, 107, 0.4);
}

.variant-badge {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: rgba(140, 157, 107, 0.9);
  color: var(--bg-dark);
  font-size: 0.65rem;
  font-weight: 700;
  text-align: center;
  padding: 3px 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  pointer-events: none;
}

.select-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 500;
  text-align: center;
  padding: 3px 0;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.image-card:hover .select-overlay {
  opacity: 1;
}

.image-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.btn-remove-image {
  position: absolute;
  top: 4px;
  right: 4px;
  background-color: rgba(244, 67, 54, 0.85);
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  aspect-ratio: 1;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.8rem;
  gap: 6px;
  transition: border-color var(--transition-speed);
}

.upload-placeholder:active {
  border-color: var(--accent);
  color: var(--accent);
}

/* Form Action Buttons at bottom */
.form-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 30px;
  padding-bottom: 30px;
}

.action-row {
  display: flex;
  gap: 10px;
}

.action-row button {
  flex: 1;
}

/* Status Toasts */
#toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  background-color: #1a1a1a;
  color: #fff;
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent);
  padding: 14px 18px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.toast.success {
  border-left-color: var(--status-synced);
}

.toast.error {
  border-left-color: var(--status-error);
}

/* Loading Overlay */
#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 17, 8, 0.7);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: none;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  z-index: 2000;
  gap: 16px;
}

#loading-overlay.active {
  display: flex;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(140, 157, 107, 0.1);
  border-left-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

#loading-text {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.05em;
}

/* Empty list styling */
.empty-list {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

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

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

/* AI Generate Button layout styling */
.input-with-button {
  display: flex;
  gap: 8px;
  width: 100%;
}

.input-with-button input {
  flex: 1;
}

.input-with-button button {
  white-space: nowrap;
  flex-shrink: 0;
  align-self: stretch;
  padding: 0 16px;
}

.input-with-button button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Variant Image Container and Previews */
.variant-image-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
  border-top: 1px dashed var(--border-color);
  padding-top: 12px;
  width: 100%;
}

.variant-img-preview-container {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-input);
  overflow: hidden;
  flex-shrink: 0;
}

.variant-img-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.btn-remove-variant-img {
  position: absolute;
  top: 2px;
  right: 2px;
  background-color: rgba(244, 67, 54, 0.85);
  color: white;
  border: none;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.variant-image-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Variant Pills Container & Switcher Style */
.variant-pills-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  -webkit-overflow-scrolling: touch;
}

.variant-pill {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.variant-pill.active {
  background-color: var(--accent);
  color: var(--bg-card);
  border-color: var(--accent);
  font-weight: 600;
}
