/* ===========================
   TradeTracker - Mobile-First CSS
   =========================== */

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

:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-light: #eff6ff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --amber: #f59e0b;
  --amber-light: #fffbeb;
  --green: #16a34a;
  --green-light: #f0fdf4;
  --red: #dc2626;
  --red-light: #fef2f2;
  --white: #ffffff;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  padding-bottom: 32px;
}

/* ===========================
   Stripe Banner
   =========================== */

.stripe-banner {
  background: linear-gradient(135deg, #1e3a8a 0%, var(--blue) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  gap: 12px;
}

.stripe-banner span {
  opacity: 0.9;
}

.stripe-btn {
  background: white;
  color: var(--blue-dark);
  border: none;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: opacity 0.15s;
}

.stripe-btn:hover {
  opacity: 0.9;
}

/* ===========================
   Header
   =========================== */

.app-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 16px;
}

.app-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.3px;
}

/* ===========================
   Tab Navigation
   =========================== */

.tab-nav {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  padding: 0 16px;
  gap: 0;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  font-family: var(--font);
}

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

.tab-btn:hover:not(.active) {
  color: var(--gray-700);
}

/* ===========================
   Main Content
   =========================== */

.main-content {
  padding: 16px;
  max-width: 640px;
  margin: 0 auto;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-900);
}

/* ===========================
   Buttons
   =========================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
  font-family: var(--font);
  text-decoration: none;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

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

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

.btn-ghost {
  background: var(--gray-100);
  color: var(--gray-700);
}

.btn-ghost:hover {
  background: var(--gray-200);
}

.btn-danger {
  background: var(--red);
  color: white;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
}

.btn-full {
  width: 100%;
  display: flex;
}

/* ===========================
   Cards
   =========================== */

.cards-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  border: 1px solid var(--gray-200);
}

.client-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.client-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 2px;
}

.client-meta {
  font-size: 13px;
  color: var(--gray-500);
  line-height: 1.5;
}

.client-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Job Cards */

.job-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.job-info {
  flex: 1;
  min-width: 0;
}

.job-client {
  font-size: 12px;
  color: var(--blue);
  font-weight: 500;
  margin-bottom: 2px;
}

.job-description {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 4px;
  word-break: break-word;
}

.job-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

.status-pending {
  background: var(--gray-100);
  color: var(--gray-600);
}

.status-in-progress {
  background: var(--amber-light);
  color: #92400e;
}

.status-done {
  background: var(--green-light);
  color: #166534;
}

.job-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--gray-100);
}

/* ===========================
   Empty State
   =========================== */

.empty-state {
  text-align: center;
  color: var(--gray-400);
  font-size: 14px;
  padding: 48px 16px;
}

/* ===========================
   Modal
   =========================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  padding: 0;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  animation: slideUp 0.2s ease;
  box-shadow: var(--shadow-lg);
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--gray-900);
}

.modal-close {
  background: var(--gray-100);
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--gray-500);
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  background: var(--gray-200);
}

/* ===========================
   Paywall Modal
   =========================== */

.modal-paywall {
  text-align: center;
  border-radius: var(--radius-lg);
  margin: 16px;
  max-width: 360px;
  width: calc(100% - 32px);
  padding: 32px 24px;
}

.modal-overlay.centered {
  align-items: center;
  justify-content: center;
}

.paywall-icon {
  font-size: 40px;
  margin-bottom: 16px;
}

.paywall-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 8px;
}

.paywall-text {
  font-size: 14px;
  color: var(--gray-500);
  margin-bottom: 24px;
  line-height: 1.6;
}

/* ===========================
   Confirm Modal
   =========================== */

.modal-confirm {
  border-radius: var(--radius-lg);
  margin: 16px;
  max-width: 320px;
  width: calc(100% - 32px);
  padding: 24px;
}

.confirm-text {
  font-size: 14px;
  color: var(--gray-500);
  margin-bottom: 20px;
  margin-top: 8px;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ===========================
   Forms
   =========================== */

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.optional {
  font-weight: 400;
  color: var(--gray-400);
}

.form-input {
  width: 100%;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 15px;
  font-family: var(--font);
  color: var(--gray-900);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

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

.form-textarea {
  resize: vertical;
  min-height: 72px;
}

select.form-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.form-actions .btn {
  flex: 1;
}

/* ===========================
   Settings
   =========================== */

.settings-form {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  border: 1px solid var(--gray-200);
}

.settings-saved {
  text-align: center;
  color: var(--green);
  font-size: 14px;
  font-weight: 500;
  margin-top: 12px;
}

/* ===========================
   Tablet / Desktop
   =========================== */

@media (min-width: 480px) {
  .modal {
    border-radius: var(--radius-lg);
    max-width: 480px;
    margin: auto;
    align-self: center;
  }

  .modal-overlay {
    align-items: center;
    justify-content: center;
    padding: 16px;
  }

  .modal-paywall,
  .modal-confirm {
    margin: 0;
  }
}
