/* ============================================================
   TradeByText — Main Stylesheet
   Mobile-first, zero frameworks, zero CDN dependencies.
   ============================================================ */

/* ---- CSS Variables ---- */
:root {
  --color-bg:          #ffffff;
  --color-text:        #1a1a2e;
  --color-muted:       #6b7280;
  --color-border:      #e5e7eb;
  --color-primary:     #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-success:     #059669;
  --color-warning:     #d97706;
  --color-danger:      #dc2626;

  /* Dashboard dark theme */
  --dash-bg:           #1a1a2e;
  --dash-surface:      #16213e;
  --dash-surface2:     #0f3460;
  --dash-text:         #e2e8f0;
  --dash-muted:        #94a3b8;
  --dash-border:       #334155;
  --dash-accent:       #3b82f6;
  --dash-accent-hover: #2563eb;

  --font-system: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 Helvetica, Arial, sans-serif, "Apple Color Emoji";

  --radius:     8px;
  --radius-sm:  4px;
  --shadow:     0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font-system); line-height: 1.5; }
img, svg { display: block; max-width: 100%; }
button { cursor: pointer; }

/* ============================================================
   Setup Page
   ============================================================ */

.setup-page {
  background: var(--color-bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.setup-container {
  width: 100%;
  max-width: 440px;
}

.setup-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 40px 32px;
}

.setup-header {
  text-align: center;
  margin-bottom: 32px;
}

.setup-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: -0.025em;
}

.tagline {
  margin-top: 8px;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.setup-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.form-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
}

.form-group input {
  padding: 10px 14px;
  font-size: 1rem;
  font-family: var(--font-system);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.form-group input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input::placeholder {
  color: #9ca3af;
}

.hint {
  font-size: 0.75rem;
  color: var(--color-muted);
}

.btn-primary {
  margin-top: 8px;
  padding: 12px 24px;
  font-size: 1rem;
  font-family: var(--font-system);
  font-weight: 600;
  color: #ffffff;
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  width: 100%;
}

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

.terms {
  margin-top: 20px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--color-muted);
  line-height: 1.6;
}

/* ============================================================
   Dashboard Page
   ============================================================ */

.dashboard-page {
  background: var(--dash-bg);
  min-height: 100vh;
  color: var(--dash-text);
}

.dash-header {
  background: var(--dash-surface);
  border-bottom: 1px solid var(--dash-border);
  padding: 0 24px;
}

.dash-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dash-header h1 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--dash-accent);
}

.business-name {
  font-size: 0.875rem;
  color: var(--dash-muted);
}

.dash-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* ---- Tabs ---- */

.tab-nav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--dash-border);
  margin-bottom: 24px;
  padding-bottom: 0;
}

.tab-btn {
  padding: 10px 20px;
  font-size: 0.9rem;
  font-family: var(--font-system);
  font-weight: 500;
  color: var(--dash-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

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

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

/* ---- Tab Panels ---- */

.tab-panel { display: block; }
.tab-panel[hidden] { display: none; }

.panel-header {
  margin-bottom: 16px;
}

.panel-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

/* ---- Tables ---- */

.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--dash-border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead {
  background: var(--dash-surface);
}

th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--dash-muted);
  border-bottom: 1px solid var(--dash-border);
  white-space: nowrap;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--dash-border);
  color: var(--dash-text);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: rgba(59, 130, 246, 0.05);
}

.loading {
  text-align: center;
  color: var(--dash-muted);
  padding: 32px !important;
}

/* ---- Status badges ---- */

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: capitalize;
}

.badge-draft     { background: rgba(148,163,184,.15); color: #94a3b8; }
.badge-sent      { background: rgba(59,130,246,.15);  color: #60a5fa; }
.badge-approved  { background: rgba(5,150,105,.15);   color: #34d399; }
.badge-rejected  { background: rgba(220,38,38,.15);   color: #f87171; }
.badge-expired   { background: rgba(217,119,6,.15);   color: #fbbf24; }
.badge-active    { background: rgba(59,130,246,.15);  color: #60a5fa; }
.badge-complete  { background: rgba(5,150,105,.15);   color: #34d399; }
.badge-cancelled { background: rgba(220,38,38,.15);   color: #f87171; }
.badge-unpaid    { background: rgba(217,119,6,.15);   color: #fbbf24; }
.badge-paid      { background: rgba(5,150,105,.15);   color: #34d399; }
.badge-overdue   { background: rgba(220,38,38,.15);   color: #f87171; }
.badge-lba_sent  { background: rgba(220,38,38,.2);    color: #ef4444; }
.badge-lba-sent  { background: rgba(220,38,38,.2);    color: #ef4444; }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 640px) {
  .setup-card {
    padding: 28px 20px;
  }

  .dash-main {
    padding: 16px 12px;
  }

  .tab-btn {
    padding: 8px 14px;
    font-size: 0.85rem;
  }

  th, td {
    padding: 10px 12px;
  }
}
