/* =====================================================
   DeskFree App CSS — dashboard, forms, invoices
   Extends theme.css tokens. Never duplicates them.
   ===================================================== */

/* === NAV === */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 15, 26, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-border);
  padding: 0 24px;
}

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

.nav-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-link {
  font-size: 0.9rem;
  color: var(--fg-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.nav-link:hover,
.nav-link.active {
  color: var(--fg);
}

/* === APP MAIN === */
.app-main {
  min-height: calc(100vh - 60px);
  padding: 32px 24px 64px;
}

.app-container {
  max-width: 1200px;
  margin: 0 auto;
}

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #0a0f1a;
}

.btn-primary:hover {
  background: #38e6ff;
  box-shadow: 0 0 20px rgba(34, 211, 238, 0.3);
}

.btn-ghost {
  background: transparent;
  color: var(--fg-muted);
  border: 1px solid var(--card-border);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.82rem;
}

.btn-full {
  width: 100%;
  padding: 14px 20px;
  font-size: 1rem;
}

/* === STAT CARDS === */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
}

.stat-card--accent { border-color: var(--accent); }
.stat-card--green { border-color: #4ade80; }

.stat-card-number {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-card--green .stat-card-number { color: #4ade80; }

.stat-card-label {
  font-size: 0.8rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* === DASHBOARD SECTIONS === */
.dash-section {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

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

.dash-section-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
}

/* === TABLES === */
.jobs-table-wrap {
  overflow-x: auto;
}

.jobs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.jobs-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  border-bottom: 1px solid var(--card-border);
}

.jobs-table td {
  padding: 12px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.4);
  vertical-align: top;
}

.jobs-table tr:last-child td { border-bottom: none; }

.customer-name { font-weight: 500; }
.customer-phone { font-size: 0.8rem; color: var(--fg-muted); }
.td-address { color: var(--fg-muted); font-size: 0.88rem; max-width: 180px; }
.td-desc { max-width: 200px; font-size: 0.88rem; }
.td-actions { white-space: nowrap; }

.ai-row td { padding: 0 12px 10px; }
.ai-summary {
  background: rgba(34, 211, 238, 0.05);
  border: 1px solid rgba(34, 211, 238, 0.15);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--fg-muted);
}

.ai-badge {
  display: inline-block;
  background: var(--accent);
  color: #0a0f1a;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  margin-right: 6px;
  font-family: var(--font-display);
  letter-spacing: 0.05em;
}

/* === STATUS BADGES === */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
  font-family: var(--font-display);
}

.status-pending    { background: rgba(250, 204, 21, 0.15); color: #facc15; border: 1px solid rgba(250,204,21,0.3); }
.status-confirmed  { background: rgba(34, 211, 238, 0.15); color: var(--accent); border: 1px solid rgba(34,211,238,0.3); }
.status-in_progress { background: rgba(129, 140, 248, 0.15); color: var(--accent-secondary); border: 1px solid rgba(129,140,248,0.3); }
.status-completed  { background: rgba(74, 222, 128, 0.15); color: #4ade80; border: 1px solid rgba(74,222,128,0.3); }
.status-cancelled  { background: rgba(248, 113, 113, 0.1); color: #f87171; border: 1px solid rgba(248,113,113,0.2); }
.status-sent  { background: rgba(34, 211, 238, 0.15); color: var(--accent); border: 1px solid rgba(34,211,238,0.3); }
.status-paid  { background: rgba(74, 222, 128, 0.15); color: #4ade80; border: 1px solid rgba(74,222,128,0.3); }
.status-void  { background: rgba(100,116,139,0.15); color: var(--fg-muted); border: 1px solid var(--card-border); }

/* === ACTION BUTTONS === */
.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  border: 1px solid var(--card-border);
  background: transparent;
  color: var(--fg-muted);
  margin-right: 4px;
  text-decoration: none;
  transition: all 0.12s;
}

.btn-action:hover { border-color: var(--accent); color: var(--accent); }
.btn-action--complete { border-color: rgba(74,222,128,0.3); color: #4ade80; }
.btn-action--complete:hover { background: rgba(74,222,128,0.1); }
.btn-action--cancel { border-color: rgba(248,113,113,0.3); color: #f87171; }
.btn-action--cancel:hover { background: rgba(248,113,113,0.1); }
.btn-action--invoice { border-color: rgba(129,140,248,0.3); color: var(--accent-secondary); }
.btn-action--invoice:hover { background: rgba(129,140,248,0.1); }

/* === INVOICE TABLE COLUMNS === */
.inv-number { font-family: var(--font-display); font-size: 0.85rem; color: var(--accent); }
.inv-total { font-weight: 600; }
.inv-col-qty, .inv-col-price, .inv-col-total { text-align: right; width: 100px; }

/* === EMPTY STATE === */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--fg-muted);
}

.empty-icon { font-size: 2.5rem; margin-bottom: 12px; }

.empty-state a {
  color: var(--accent);
  text-decoration: none;
}

/* === FORM PAGE === */
.form-page-container {
  max-width: 640px;
  margin: 0 auto;
}

.form-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 40px;
}

.form-card-header {
  margin-bottom: 36px;
  text-align: center;
}

.form-badge {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid rgba(34, 211, 238, 0.25);
  padding: 4px 14px;
  border-radius: 50px;
  margin-bottom: 20px;
}

.form-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.form-subtitle {
  color: var(--fg-muted);
  font-size: 0.95rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--fg-muted);
}

.required { color: var(--accent); }

.form-input {
  width: 100%;
  background: rgba(10, 15, 26, 0.5);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color 0.15s;
  outline: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.08);
}

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

.form-error {
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: 8px;
  padding: 10px 14px;
  color: #f87171;
  font-size: 0.9rem;
  margin-bottom: 16px;
}

/* === SUCCESS STATE === */
.success-card {
  background: var(--card-bg);
  border: 1px solid rgba(74, 222, 128, 0.3);
  border-radius: 16px;
  padding: 48px 40px;
  text-align: center;
}

.success-icon {
  width: 64px;
  height: 64px;
  background: rgba(74, 222, 128, 0.15);
  border: 2px solid #4ade80;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  font-size: 1.5rem;
  color: #4ade80;
}

.success-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.success-text {
  color: var(--fg-muted);
  margin-bottom: 24px;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.success-details {
  background: rgba(10, 15, 26, 0.4);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 24px;
  text-align: left;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  padding: 4px 0;
}

.detail-row span { color: var(--fg-muted); }

.success-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* === MODAL === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 500px;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

.line-item-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.line-item-row .form-input { margin-bottom: 0; }

/* === INVOICE VIEW === */
.invoice-container {
  max-width: 760px;
  margin: 0 auto;
}

.invoice-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 48px;
  margin-bottom: 20px;
}

.invoice-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 40px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--card-border);
}

.invoice-brand-name {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
}

.invoice-brand-tag {
  font-size: 0.8rem;
  color: var(--fg-muted);
  margin-top: 4px;
}

.invoice-meta { text-align: right; }

.invoice-number-label {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  color: var(--fg-muted);
  text-transform: uppercase;
}

.invoice-number {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  margin: 4px 0 8px;
}

.invoice-date { font-size: 0.85rem; color: var(--fg-muted); margin-bottom: 8px; }

.invoice-bill-to {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-bottom: 32px;
}

.bill-label {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--fg-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.bill-name { font-weight: 600; margin-bottom: 4px; }
.bill-detail { font-size: 0.9rem; color: var(--fg-muted); }
.bill-desc { font-size: 0.9rem; color: var(--fg-muted); line-height: 1.5; }

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

.invoice-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  border-bottom: 1px solid var(--card-border);
}

.invoice-table td {
  padding: 12px;
  border-bottom: 1px solid rgba(51,65,85,0.3);
  font-size: 0.9rem;
}

.invoice-totals {
  margin-left: auto;
  width: 280px;
  border-top: 1px solid var(--card-border);
  padding-top: 16px;
  margin-bottom: 24px;
}

.total-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  padding: 5px 0;
  color: var(--fg-muted);
}

.total-row--grand {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--fg);
  border-top: 1px solid var(--card-border);
  margin-top: 8px;
  padding-top: 12px;
}

.invoice-notes {
  background: rgba(10,15,26,0.4);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 24px;
}

.notes-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
  margin-bottom: 6px;
}

.notes-text { font-size: 0.9rem; color: var(--fg-muted); }

.invoice-footer {
  text-align: center;
  font-size: 0.85rem;
  color: var(--fg-muted);
  padding-top: 24px;
  border-top: 1px solid var(--card-border);
}

.invoice-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* === HERO CTA (landing page additions) === */
.hero-cta {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 40px;
}

.btn-hero {
  padding: 14px 32px;
  font-size: 1rem;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  display: inline-block;
}

.btn-hero-primary {
  background: var(--accent);
  color: #0a0f1a;
  border: none;
}

.btn-hero-primary:hover {
  background: #38e6ff;
  box-shadow: 0 0 28px rgba(34, 211, 238, 0.35);
}

.btn-hero-ghost {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--card-border);
}

.btn-hero-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* === PRINT === */
@media print {
  .no-print { display: none !important; }
  body { background: white !important; color: #111 !important; }
  .invoice-card { border: none; padding: 0; background: white; }
  .status-badge { border: 1px solid #ccc; color: #333 !important; background: #f5f5f5 !important; }
}

/* === RESPONSIVE === */
@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
  .form-card { padding: 24px 20px; }
  .invoice-card { padding: 24px 20px; }
  .invoice-header { flex-direction: column; gap: 20px; }
  .invoice-meta { text-align: left; }
  .invoice-bill-to { grid-template-columns: 1fr; }
  .invoice-totals { width: 100%; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .success-actions { flex-direction: column; }
}
