/**
 * FORGE DESIGN SYSTEM — Component Styles
 * Version: 2.1
 * The Forge Command Center
 */

/* ═══════════════════════════════════════════════════════
   BASE RESET & TYPOGRAPHY
   ═══════════════════════════════════════════════════════ */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--forge-void);
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

h1 { font-size: 32px; letter-spacing: -0.01em; }
h2 { font-size: 24px; font-weight: 600; }
h3 { font-size: 18px; font-weight: 600; }

a {
  color: var(--forge-gold);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-forge-out);
}

a:hover {
  color: var(--forge-amber);
}

/* ═══════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════ */

.forge-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.02em;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-forge-out);
  white-space: nowrap;
}

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

.forge-btn svg {
  width: 16px;
  height: 16px;
}

/* PRIMARY — ember gradient, black text, prominent glow */
.forge-btn-primary {
  background: linear-gradient(180deg, #FF8C00 0%, #FF6200 100%);
  color: #000000;
  font-weight: 700;
  border-radius: var(--radius-lg);
}

.forge-btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #FFA033 0%, #FF7A1A 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(255, 122, 0, 0.4);
}

.forge-btn-primary:active:not(:disabled) {
  transform: scale(0.98);
}

/* SECONDARY — basalt background, slate border */
.forge-btn-secondary {
  background: var(--forge-basalt);
  color: var(--forge-ash);
  border: 1px solid var(--forge-slate);
}

.forge-btn-secondary:hover:not(:disabled) {
  background: var(--forge-slate);
  color: var(--text-primary);
}

/* GHOST — transparent, visible on hover */
.forge-btn-ghost {
  background: transparent;
  color: var(--forge-ash);
  border: 1px solid transparent;
}

.forge-btn-ghost:hover:not(:disabled) {
  color: var(--text-primary);
  background: rgba(138, 138, 146, 0.1);
}

/* DESTRUCTIVE — for delete/cancel actions */
.forge-btn-destructive {
  background: transparent;
  color: var(--forge-heat-critical);
  border: 1px solid var(--forge-heat-critical);
}

.forge-btn-destructive:hover:not(:disabled) {
  background: rgba(255, 45, 0, 0.1);
}

/* Icon-only button variant */
.forge-btn-icon {
  padding: 10px;
  border-radius: var(--radius-md);
}

/* ═══════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════ */

.forge-card {
  background: var(--forge-obsidian);
  border: 1px solid var(--forge-basalt);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--duration-normal) var(--ease-forge-out);
}

.forge-card:hover {
  border-color: var(--forge-slate);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.forge-card-active {
  border-color: var(--forge-ember);
  box-shadow: var(--forge-glow-ember);
}

.forge-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.forge-card-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════════
   INPUT FIELDS
   ═══════════════════════════════════════════════════════ */

.forge-input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.forge-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.forge-input {
  width: 100%;
  background: rgba(20, 20, 22, 0.6);
  border: 1px solid var(--forge-basalt);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  transition: all var(--duration-normal) var(--ease-forge-out);
}

.forge-input:focus {
  outline: none;
  border-color: var(--forge-gold);
  box-shadow: 0 0 0 3px rgba(255, 184, 0, 0.15);
  background: rgba(20, 20, 22, 0.8);
}

.forge-input::placeholder {
  color: var(--forge-cool-smoke);
}

.forge-input.error {
  border-color: var(--forge-heat-critical);
  animation: shake 0.4s var(--ease-forge-out);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* Textarea */
.forge-textarea {
  min-height: 100px;
  resize: vertical;
}

/* ═══════════════════════════════════════════════════════
   SELECT DROPDOWNS
   ═══════════════════════════════════════════════════════ */

.forge-select {
  width: 100%;
  padding: 12px 16px;
  background: var(--forge-obsidian);
  border: 2px solid var(--forge-basalt);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-forge-out);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8a8a' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

.forge-select:hover {
  border-color: var(--forge-ash);
}

.forge-select:focus {
  outline: none;
  border-color: var(--forge-ember);
  box-shadow: 0 0 0 2px rgba(255, 77, 0, 0.2);
}

.forge-select option {
  background: var(--forge-void);
  color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-modal) var(--ease-forge-out);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--forge-void);
  border: 1px solid var(--forge-basalt);
  border-radius: var(--radius-md);
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  transform: scale(0.95) translateY(10px);
  transition: transform var(--duration-modal) var(--ease-forge-out);
}

.modal-overlay.active .modal-content {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--forge-basalt);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.modal-header h2 {
  margin: 0 0 var(--space-sm) 0;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
}

.modal-header p {
  margin: 0;
  color: var(--forge-ash);
  font-size: 14px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--forge-ash);
  cursor: pointer;
  padding: var(--space-xs);
  transition: color var(--duration-fast) var(--ease-forge-out);
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-lg);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--forge-basalt);
  display: flex;
  gap: var(--space-md);
  justify-content: flex-end;
}

/* ═══════════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════════ */

.forge-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-family: var(--font-body);
}

.forge-table thead th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--forge-ash);
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--forge-basalt);
  background: var(--forge-obsidian);
  position: sticky;
  top: 0;
  z-index: 10;
}

.forge-table tbody tr {
  transition: background var(--duration-fast) var(--ease-forge-out);
}

.forge-table tbody tr:nth-child(odd) {
  background: var(--forge-void);
}

.forge-table tbody tr:nth-child(even) {
  background: rgba(20, 20, 22, 0.5);
}

.forge-table tbody tr:hover {
  background: rgba(42, 42, 48, 0.4);
}

.forge-table tbody tr.clickable {
  cursor: pointer;
}

.forge-table tbody td {
  padding: 14px 16px;
  color: var(--text-primary);
  font-size: 14px;
  border-bottom: 1px solid rgba(30, 30, 34, 0.5);
  vertical-align: middle;
}

/* Monetary amounts — right-aligned monospace */
.forge-table .amount {
  font-family: var(--font-mono);
  font-weight: 500;
  text-align: right;
  color: var(--text-gold);
}

/* Invoice number column */
.forge-table .invoice-number {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--forge-gold);
}

/* ═══════════════════════════════════════════════════════
   STATUS BADGES
   ═══════════════════════════════════════════════════════ */

.forge-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Status badges — stoplight colors ONLY here */
.forge-badge-draft {
  background: rgba(138, 138, 146, 0.15);
  color: var(--forge-ash);
}

.forge-badge-sent {
  background: rgba(255, 184, 0, 0.15);
  color: var(--forge-gold);
}

.forge-badge-paid {
  background: rgba(46, 160, 67, 0.15);
  color: var(--status-pass);
}

.forge-badge-overdue {
  background: rgba(255, 45, 0, 0.15);
  color: var(--status-block);
}

.forge-badge-pending {
  background: rgba(240, 176, 0, 0.15);
  color: var(--status-flag);
}

/* ═══════════════════════════════════════════════════════
   SECTION HEADERS
   ═══════════════════════════════════════════════════════ */

.forge-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.forge-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════
   DIVIDERS & HEAT SEAMS
   ═══════════════════════════════════════════════════════ */

.forge-divider {
  height: 1px;
  background: var(--forge-basalt);
  margin: var(--space-lg) 0;
}

.forge-heat-seam {
  height: 1px;
  background: var(--forge-ember);
  margin: var(--space-lg) 0;
}

/* ═══════════════════════════════════════════════════════
   EMPTY STATES
   ═══════════════════════════════════════════════════════ */

.forge-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl) var(--space-lg);
  text-align: center;
}

.forge-empty-state-icon {
  width: 80px;
  height: 80px;
  margin-bottom: var(--space-lg);
  color: var(--forge-ember);
  opacity: 0.6;
}

.forge-empty-state h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.forge-empty-state p {
  color: var(--forge-ash);
  font-size: 14px;
  margin-bottom: var(--space-lg);
  max-width: 320px;
}

/* ═══════════════════════════════════════════════════════
   TOOLTIPS
   ═══════════════════════════════════════════════════════ */

[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: 6px 10px;
  background: var(--forge-slate);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-fast) var(--ease-forge-out);
  pointer-events: none;
  z-index: 100;
}

[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(-4px);
}

/* ═══════════════════════════════════════════════════════
   UTILITY CLASSES
   ═══════════════════════════════════════════════════════ */

.text-gold { color: var(--text-gold); }
.text-ash { color: var(--forge-ash); }
.text-secondary { color: var(--text-secondary); }
.text-mono { font-family: var(--font-mono); }
.text-right { text-align: right; }
.text-center { text-align: center; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.w-full { width: 100%; }
.hidden { display: none !important; }
