/* ============================================================
   TC West Invoicing — Client Portal Stylesheet
   Designed to work within any WordPress theme without conflict.
   All selectors are scoped to .tcwi-portal.
   ============================================================ */

/* ── Reset scope ─────────────────────────────────────────────── */
.tcwi-portal *,
.tcwi-portal *::before,
.tcwi-portal *::after { box-sizing: border-box; }

/* ── Design tokens ───────────────────────────────────────────── */
.tcwi-portal {
  --p-navy:       #0d1b2a;
  --p-red:        #c8102e;
  --p-gold:       #d4a017;
  --p-green:      #10b981;
  --p-amber:      #f59e0b;
  --p-blue:       #3b82f6;
  --p-bg:         #f4f1eb;
  --p-surface:    #ffffff;
  --p-border:     #e5e7eb;
  --p-text:       #1f2937;
  --p-muted:      #6b7280;
  --p-radius:     6px;
  --p-shadow:     0 1px 4px rgba(0,0,0,.08);
  --p-shadow-md:  0 4px 20px rgba(0,0,0,.12);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--p-text);
  line-height: 1.6;
}

/* ── Login gate ──────────────────────────────────────────────── */
.tcwi-portal-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
}
.tcwi-gate-card {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-top: 4px solid var(--p-navy);
  border-radius: var(--p-radius);
  padding: 48px 40px;
  text-align: center;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--p-shadow-md);
}
.tcwi-gate-icon { font-size: 2.5rem; margin-bottom: 16px; }
.tcwi-gate-card h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--p-navy);
  margin: 0 0 8px;
}
.tcwi-gate-card p { color: var(--p-muted); margin: 0 0 24px; }

/* ── Buttons ─────────────────────────────────────────────────── */
.tcwi-btn {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 10px 20px;
  border-radius: var(--p-radius);
  text-decoration: none;
  transition: background .2s, opacity .2s;
  cursor: pointer;
  border: none;
  line-height: 1;
}
.tcwi-btn-primary { background: var(--p-red); color: #fff; }
.tcwi-btn-primary:hover { background: #a50d26; color: #fff; }
.tcwi-btn-ghost {
  background: transparent;
  color: var(--p-navy);
  border: 1px solid var(--p-border);
}
.tcwi-btn-ghost:hover { background: var(--p-bg); }
.tcwi-btn-sm { padding: 6px 12px; font-size: 0.75rem; }
.tcwi-btn-pay { background: var(--p-green); color: #fff; }
.tcwi-btn-pay:hover { background: #0d9468; color: #fff; }

/* ── Portal header ───────────────────────────────────────────── */
.tcwi-portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--p-navy);
}
.tcwi-portal-greeting h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--p-navy);
  margin: 0 0 2px;
}
.tcwi-portal-company {
  font-size: 0.88rem;
  color: var(--p-muted);
  margin: 0;
}
.tcwi-portal-invoice-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Back link */
.tcwi-back-link {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--p-muted);
  text-decoration: none;
  transition: color .2s;
}
.tcwi-back-link:hover { color: var(--p-red); }

/* ── Summary strip ───────────────────────────────────────────── */
.tcwi-summary-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}
.tcwi-summary-card {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-top: 3px solid var(--p-navy);
  border-radius: var(--p-radius);
  padding: 18px 20px;
  box-shadow: var(--p-shadow);
}
.tcwi-summary-overdue { border-top-color: var(--p-amber); }
.tcwi-summary-paid    { border-top-color: var(--p-green); }
.tcwi-summary-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--p-muted);
  margin-bottom: 6px;
}
.tcwi-summary-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--p-navy);
  line-height: 1;
}

/* ── Portal section ──────────────────────────────────────────── */
.tcwi-portal-section { margin-bottom: 40px; }
.tcwi-section-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--p-navy);
  margin: 0 0 16px;
}

/* ── Invoice table ───────────────────────────────────────────── */
.tcwi-invoice-table-wrap { overflow-x: auto; }

.tcwi-invoice-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.tcwi-invoice-table thead th {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--p-muted);
  padding: 8px 12px;
  border-bottom: 2px solid var(--p-navy);
  text-align: left;
  white-space: nowrap;
}
.tcwi-invoice-table tbody tr {
  border-bottom: 1px solid var(--p-border);
  transition: background .15s;
}
.tcwi-invoice-table tbody tr:hover { background: var(--p-bg); }
.tcwi-invoice-table tbody td {
  padding: 14px 12px;
  vertical-align: middle;
}
.tcwi-row-overdue { background: #fff8f0; }
.tcwi-row-overdue:hover { background: #fef3c7 !important; }

.tcwi-invoice-number a {
  font-weight: 700;
  color: var(--p-navy);
  text-decoration: none;
}
.tcwi-invoice-number a:hover { color: var(--p-red); }
.tcwi-invoice-total { font-weight: 700; color: var(--p-navy); }
.tcwi-invoice-actions { white-space: nowrap; display: flex; gap: 6px; align-items: center; }

.tcwi-overdue-date { color: var(--p-amber); font-weight: 600; }
.tcwi-overdue-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  background: #fef3c7;
  color: #92400e;
  padding: 2px 7px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ── Status pill ─────────────────────────────────────────────── */
.tcwi-status-pill {
  display: inline-block;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

/* ── Empty state ─────────────────────────────────────────────── */
.tcwi-empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--p-muted);
  background: var(--p-surface);
  border: 1px dashed var(--p-border);
  border-radius: var(--p-radius);
}
.tcwi-empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.tcwi-empty-state p { font-size: 0.95rem; margin: 0; }

/* ── Pagination ──────────────────────────────────────────────── */
.tcwi-pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 24px;
}
.tcwi-page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--p-navy);
  text-decoration: none;
  transition: background .15s, border-color .15s;
}
.tcwi-page-btn:hover { background: var(--p-bg); }
.tcwi-page-current { background: var(--p-navy); color: #fff; border-color: var(--p-navy); }

/* ── Notices ─────────────────────────────────────────────────── */
.tcwi-portal-notice {
  padding: 12px 16px;
  border-radius: var(--p-radius);
  font-size: 0.9rem;
  margin-bottom: 20px;
}
.tcwi-notice-error { background: #fef2f2; border-left: 4px solid var(--p-red); color: #991b1b; }
.tcwi-notice-success { background: #ecfdf5; border-left: 4px solid var(--p-green); color: #065f46; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .tcwi-summary-strip { grid-template-columns: repeat(2, 1fr); }
  .tcwi-invoice-table thead th:nth-child(2),
  .tcwi-invoice-table tbody td:nth-child(2) { display: none; } /* hide date col */
}
@media (max-width: 520px) {
  .tcwi-summary-strip { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tcwi-summary-card { padding: 14px 16px; }
  .tcwi-summary-value { font-size: 1.15rem; }
  .tcwi-portal-header { flex-direction: column; align-items: flex-start; }
  .tcwi-invoice-table thead th:nth-child(4),
  .tcwi-invoice-table tbody td:nth-child(4) { display: none; } /* hide total col */
}

/* ============================================================
   Quote portal additions
   ============================================================ */

/* Tab navigation */
.tcwi-portal-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 28px;
  border-bottom: 2px solid var(--p-border);
}
.tcwi-tab-link {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--p-muted);
  padding: 11px 20px;
  text-decoration: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color .2s, border-color .2s;
}
.tcwi-tab-link:hover { color: var(--p-navy); }
.tcwi-tab-active {
  color: var(--p-navy);
  border-bottom-color: var(--p-green);
}

/* Approve / decline / revision buttons */
.tcwi-btn-revision {
  border: 1px solid var(--p-border) !important;
  color: var(--p-navy) !important;
}
.tcwi-btn-revision:hover { background: var(--p-bg) !important; }

/* Revision modal */
.tcwi-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13,27,42,.55);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.tcwi-modal-inner {
  background: #fff;
  border-radius: var(--p-radius);
  padding: 32px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--p-shadow-md);
}
.tcwi-modal-inner h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--p-navy);
  margin: 0 0 8px;
}
.tcwi-modal-inner p {
  font-size: .88rem;
  color: var(--p-muted);
  margin: 0 0 16px;
}
.tcwi-revision-textarea {
  width: 100%;
  font-family: inherit;
  font-size: .9rem;
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius);
  padding: 10px 12px;
  resize: vertical;
  margin-bottom: 16px;
  transition: border-color .2s;
}
.tcwi-revision-textarea:focus {
  border-color: var(--p-green);
  outline: 2px solid var(--p-green);
  outline-offset: 2px;
}
.tcwi-modal-actions {
  display: flex;
  gap: 10px;
}

/* Action feedback banner */
#tcwi-quote-action-feedback {
  margin-bottom: 20px;
}
.tcwi-notice-success { background: #ecfdf5; border-left: 4px solid var(--p-green); color: #065f46; }
.tcwi-notice-error   { background: #fef2f2; border-left: 4px solid var(--p-red);   color: #991b1b; }

/* Quote cart shortcode */
.tcwi-quote-cart {
  max-width: 760px;
  margin: 0 auto;
}
.tcwi-qc-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--p-navy);
  margin-bottom: 20px;
}
.tcwi-qc-empty {
  padding: 40px;
  text-align: center;
  background: var(--p-surface);
  border: 1px dashed var(--p-border);
  border-radius: var(--p-radius);
  color: var(--p-muted);
  font-size: .9rem;
}
.tcwi-qc-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}
.tcwi-qc-table thead th {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--p-muted);
  padding: 8px 12px;
  border-bottom: 2px solid var(--p-navy);
  text-align: left;
}
.tcwi-qc-table tbody td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--p-border);
  font-size: .9rem;
  vertical-align: middle;
}
.tcwi-qc-remove {
  background: none;
  border: none;
  color: var(--p-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 6px;
  border-radius: 50%;
  transition: color .15s, background .15s;
}
.tcwi-qc-remove:hover { color: var(--p-red); background: #fef2f2; }

.tcwi-qc-form { margin-top: 24px; }
.tcwi-qc-field { margin-bottom: 18px; }
.tcwi-qc-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--p-navy);
  margin-bottom: 6px;
}
.tcwi-qc-field .input-text {
  width: 100%;
  font-family: inherit;
  font-size: .95rem;
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  padding: 10px 14px;
  border-radius: var(--p-radius);
  transition: border-color .2s;
}
.tcwi-qc-field .input-text:focus {
  border-color: var(--p-green);
  outline: 2px solid var(--p-green);
  outline-offset: 2px;
}
.tcwi-qc-actions { margin-top: 8px; }
.tcwi-qc-feedback {
  margin-top: 14px;
  padding: 10px 16px;
  border-radius: var(--p-radius);
  font-size: .88rem;
  display: none;
}
.tcwi-qc-feedback.success { background: #ecfdf5; border-left: 4px solid var(--p-green); color: #065f46; display: block; }
.tcwi-qc-feedback.error   { background: #fef2f2; border-left: 4px solid var(--p-red);   color: #991b1b; display: block; }

/* "Add to Quote" product button */
.tcwi-atq-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}
.tcwi-add-to-quote-btn {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  background: var(--p-navy);
  color: #fff;
  border: none;
  padding: 11px 22px;
  border-radius: var(--p-radius);
  cursor: pointer;
  transition: background .2s;
}
.tcwi-add-to-quote-btn:hover { background: var(--p-green); }
.tcwi-atq-feedback {
  font-size: .82rem;
  color: var(--p-green);
  font-weight: 600;
  min-height: 20px;
}

@media (max-width: 520px) {
  .tcwi-portal-tabs { overflow-x: auto; }
  .tcwi-tab-link    { white-space: nowrap; }
  .tcwi-modal-inner { padding: 20px; }
  .tcwi-modal-actions { flex-direction: column; }
}
