@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --background: 0 0% 100%;
  --foreground: 0 0% 9%;
  --border: 0 0% 90%;
  --card: 0 0% 98%;
  --card-foreground: 0 0% 9%;
  --card-border: 0 0% 94%;
  --popover: 0 0% 95%;
  --popover-foreground: 0 0% 9%;
  --primary: 43 96% 35%;
  --primary-foreground: 43 20% 98%;
  --secondary: 0 0% 92%;
  --secondary-foreground: 0 0% 9%;
  --muted: 0 2% 93%;
  --muted-foreground: 0 2% 35%;
  --accent: 43 8% 91%;
  --accent-foreground: 43 8% 12%;
  --destructive: 0 84% 38%;
  --destructive-foreground: 0 10% 98%;
  --input: 0 0% 75%;
  --ring: 43 96% 45%;
  --radius: 0.5rem;
}

.dark {
  --background: 0 0% 8%;
  --foreground: 0 0% 95%;
  --border: 0 0% 18%;
  --card: 0 0% 10%;
  --card-foreground: 0 0% 95%;
  --card-border: 0 0% 13%;
  --popover: 0 0% 14%;
  --popover-foreground: 0 0% 95%;
  --primary: 43 96% 32%;
  --primary-foreground: 43 20% 98%;
  --secondary: 0 0% 18%;
  --secondary-foreground: 0 0% 95%;
  --muted: 0 2% 16%;
  --muted-foreground: 0 2% 70%;
  --accent: 43 8% 16%;
  --accent-foreground: 43 8% 92%;
  --destructive: 0 84% 35%;
  --destructive-foreground: 0 10% 98%;
  --input: 0 0% 30%;
  --ring: 43 96% 45%;
}

html { font-synthesis: none; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  line-height: 1.5;
  min-height: 100vh;
}

.font-serif { font-family: 'Playfair Display', Georgia, serif; }
.font-mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

.card {
  background-color: hsl(var(--card));
  border: 1px solid hsl(var(--card-border));
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header { padding: 1.25rem 1.25rem 0.75rem; }
.card-content { padding: 1.25rem; }
.card-title { font-weight: 600; font-size: 1.125rem; }
.card-description { color: hsl(var(--muted-foreground)); font-size: 0.875rem; margin-top: 0.25rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  text-decoration: none;
  line-height: 1.5;
}

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

.btn-primary {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); }

.btn-outline {
  background-color: transparent;
  border-color: hsl(var(--border));
  color: hsl(var(--foreground));
}
.btn-outline:hover:not(:disabled) { background-color: hsl(var(--accent)); }

.btn-ghost {
  background-color: transparent;
  border-color: transparent;
  color: hsl(var(--foreground));
}
.btn-ghost:hover:not(:disabled) { background-color: hsl(var(--accent)); }

.btn-destructive {
  background-color: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}
.btn-destructive:hover:not(:disabled) { filter: brightness(1.1); }

.btn-sm { padding: 0.25rem 0.75rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn-icon { padding: 0.5rem; width: 2.25rem; height: 2.25rem; }

.input-field {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}
.input-field:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}
.input-field::placeholder { color: hsl(var(--muted-foreground)); }
.input-lg { padding: 0.75rem 0.75rem; font-size: 1rem; height: 3rem; }

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

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-primary { background-color: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.badge-secondary { background-color: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.badge-outline { background-color: transparent; border-color: hsl(var(--border)); color: hsl(var(--foreground)); }
.badge-destructive { background-color: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }

.badge-new { background-color: rgba(34,197,94,0.1); color: #15803d; border-color: rgba(34,197,94,0.2); }
.badge-sold { background-color: rgba(59,130,246,0.1); color: #1d4ed8; border-color: rgba(59,130,246,0.2); }
.badge-scrap { background-color: rgba(249,115,22,0.1); color: #c2410c; border-color: rgba(249,115,22,0.2); }
.badge-reserved { background-color: rgba(168,85,247,0.1); color: #7c3aed; border-color: rgba(168,85,247,0.2); }

.dark .badge-new { color: #4ade80; }
.dark .badge-sold { color: #60a5fa; }
.dark .badge-scrap { color: #fb923c; }
.dark .badge-reserved { color: #c084fc; }

.avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-weight: 600;
  font-size: 0.875rem;
}

.tabs-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.25rem;
  background-color: hsl(var(--muted));
  border-radius: var(--radius);
  padding: 0.25rem;
  margin-bottom: 1.5rem;
}
.tab-trigger {
  padding: 0.5rem 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: transparent;
  color: hsl(var(--muted-foreground));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
}
.tab-trigger.active {
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

.switch {
  position: relative;
  width: 2.5rem;
  height: 1.25rem;
  background-color: hsl(var(--input));
  border-radius: 9999px;
  cursor: pointer;
  transition: background-color 0.2s;
  border: none;
  padding: 0;
}
.switch.active { background-color: hsl(var(--primary)); }
.switch::after {
  content: '';
  position: absolute;
  width: 1rem;
  height: 1rem;
  background: white;
  border-radius: 9999px;
  top: 0.125rem;
  left: 0.125rem;
  transition: transform 0.2s;
}
.switch.active::after { transform: translateX(1.25rem); }

.select-field {
  appearance: none;
  width: 100%;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  font-size: 0.875rem;
  cursor: pointer;
  outline: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
}
.select-field:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

.textarea-field {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  font-size: 0.875rem;
  outline: none;
  resize: none;
  font-family: inherit;
  min-height: 4rem;
}
.textarea-field:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

.skeleton {
  background: linear-gradient(90deg, hsl(var(--muted)) 25%, hsl(var(--muted) / 0.5) 50%, hsl(var(--muted)) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 24rem;
}
.toast {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background-color: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
  animation: toast-in 0.3s ease-out;
  font-size: 0.875rem;
}
.toast-title { font-weight: 600; margin-bottom: 0.125rem; }
.toast-desc { color: hsl(var(--muted-foreground)); font-size: 0.8125rem; }
.toast-destructive { border-color: hsl(var(--destructive) / 0.5); }
.toast-destructive .toast-title { color: hsl(var(--destructive)); }
@keyframes toast-in { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.dialog-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0,0,0,0.5);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fade-in 0.15s ease;
}
.dialog-content {
  background-color: hsl(var(--background));
  border-radius: calc(var(--radius) * 1.5);
  border: 1px solid hsl(var(--border));
  width: 100%;
  max-width: 28rem;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  animation: dialog-in 0.2s ease;
}
.dialog-sm { max-width: 20rem; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes dialog-in { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

.dropdown-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.25rem;
  background-color: hsl(var(--popover));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 0.25rem;
  min-width: 14rem;
  z-index: 50;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
  animation: dropdown-in 0.15s ease;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  cursor: pointer;
  transition: background-color 0.1s;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  color: hsl(var(--foreground));
  text-decoration: none;
}
.dropdown-item:hover { background-color: hsl(var(--accent)); }
.dropdown-label {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
}
.dropdown-separator {
  height: 1px;
  background-color: hsl(var(--border));
  margin: 0.25rem 0;
}
@keyframes dropdown-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

.hover-elevate { transition: transform 0.15s, box-shadow 0.15s; }
.hover-elevate:hover { transform: translateY(-1px); box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); }

.safe-area-bottom { padding-bottom: env(safe-area-inset-bottom, 0); }

@keyframes spin { to { transform: rotate(360deg); } }
.animate-spin { animation: spin 1s linear infinite; }

.text-primary { color: hsl(var(--primary)); }
.text-muted { color: hsl(var(--muted-foreground)); }
.bg-primary { background-color: hsl(var(--primary)); }
.bg-muted { background-color: hsl(var(--muted)); }
.border-primary { border-color: hsl(var(--primary)); }
