/* ============================================================
   Whitfield IT Client Portal — Design System
   ============================================================ */

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

:root {
  --bg:          #080612;
  --surface:     rgba(255,255,255,0.04);
  --border:      rgba(244,240,234,0.08);
  --amber:       #faac5c;
  --amber-hover: #e89840;
  --text:        #f4f0ea;
  --muted:       rgba(244,240,234,0.5);
  --radius:      8px;
  --radius-lg:   12px;
  --font:        system-ui, -apple-system, 'Segoe UI', sans-serif;
}

html { font-size: 15px; }
body { background: var(--bg); color: var(--text); font-family: var(--font); min-height: 100vh; line-height: 1.5; }

a { color: var(--amber); text-decoration: none; }
a:hover { color: var(--amber-hover); }

/* ── Typography ───────────────────────────────────────────── */
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }

/* ── Layout ───────────────────────────────────────────────── */
.portal-wrap { display: flex; flex-direction: column; min-height: 100vh; }

.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem;
  height: 56px;
  background: rgba(8,6,18,0.95);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(8px);
}

.header-logo { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.5px; }
.header-logo .dot { color: var(--amber); }
.header-right { display: flex; align-items: center; gap: 1rem; }
.header-user { color: var(--muted); font-size: 0.875rem; }

.main-content { flex: 1; padding: 1.5rem; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

/* ── Stats row ────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  text-align: center;
}

.stat-value { font-size: 2rem; font-weight: 700; color: var(--amber); line-height: 1; margin-bottom: 0.25rem; }
.stat-label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Dashboard grid ───────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem; font-weight: 500;
  cursor: pointer; border: none; transition: all 0.15s;
  text-decoration: none;
}
.btn-primary {
  background: var(--amber); color: #080612;
}
.btn-primary:hover { background: var(--amber-hover); color: #080612; }
.btn-ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--amber); color: var(--amber); }
.btn-danger { background: rgba(220,50,50,0.15); color: #ff6b6b; border: 1px solid rgba(220,50,50,0.3); }
.btn-danger:hover { background: rgba(220,50,50,0.25); }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.4rem; text-transform: uppercase; letter-spacing: 0.05em; }
.form-control {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.6rem 0.85rem;
  font-size: 0.9rem;
  font-family: var(--font);
  transition: border-color 0.15s;
}
.form-control:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 2px rgba(250,172,92,0.15); }
.form-control::placeholder { color: var(--muted); }
select.form-control option { background: #1a1530; color: var(--text); }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

.form-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }

.checkbox-label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-size: 0.875rem; }
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--amber); }

/* ── Login ────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 1rem;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%; max-width: 400px;
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo-text {
  font-size: 1.5rem; font-weight: 700; letter-spacing: -0.5px;
}

.login-logo-text .dot { color: var(--amber); }
.login-subtitle { color: var(--muted); font-size: 0.85rem; margin-top: 0.25rem; }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th {
  text-align: left; padding: 0.75rem 1rem;
  color: var(--muted); font-weight: 500; font-size: 0.75rem;
  text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(244,240,234,0.04);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; transition: background 0.1s; }
tbody tr:hover { background: rgba(255,255,255,0.03); }

/* ── Pills / Badges ───────────────────────────────────────── */
.pill {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}
.pill-grey   { background: rgba(120,120,130,0.2); color: #b0afc0; }
.pill-blue   { background: rgba(59,130,246,0.2);  color: #93c5fd; }
.pill-indigo { background: rgba(99,102,241,0.2);  color: #a5b4fc; }
.pill-green  { background: rgba(34,197,94,0.2);   color: #86efac; }
.pill-amber  { background: rgba(250,172,92,0.2);  color: #faac5c; }
.pill-orange { background: rgba(251,146,60,0.2);  color: #fdba74; }
.pill-red    { background: rgba(239,68,68,0.2);   color: #fca5a5; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius);
  font-size: 0.75rem;
  background: rgba(250,172,92,0.15);
  color: var(--amber);
  border: 1px solid rgba(250,172,92,0.3);
}

/* ── Flash messages ───────────────────────────────────────── */
.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.875rem;
}
.flash-success { background: rgba(34,197,94,0.15); border: 1px solid rgba(34,197,94,0.3); color: #86efac; }
.flash-error   { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }

/* ── Page header ──────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem;
}

/* ── Search / filters ─────────────────────────────────────── */
.filter-bar {
  display: flex; gap: 0.75rem; align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.search-input {
  flex: 1; min-width: 200px;
}

.filter-select { width: auto; min-width: 140px; }

/* ── Client view responsive grid ─────────────────────────────── */
/* Mobile first: single column */
.client-view-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  align-items: stretch;
}

/* Tablet+: 3 columns directly — no 2-column intermediate */
@media (min-width: 769px) {
  .client-view-grid { grid-template-columns: 260px 1fr 260px; }
  .client-panel-right { grid-column: auto; }
}

.client-panel { min-height: 400px; height: 100%; box-sizing: border-box; display: flex; flex-direction: column; }
.client-panel.client-panel-right { min-height: 400px; height: 100%; box-sizing: border-box; display: flex; flex-direction: column; }

.info-row { display: flex; flex-direction: column; gap: 0.1rem; margin-bottom: 0.85rem; }
.info-label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.info-value { word-break: break-word; overflow-wrap: break-word;  font-size: 0.9rem; }

/* ── Activity feed ────────────────────────────────────────── */
.activity-item {
  display: flex; gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
.activity-item:last-child { border-bottom: none; }
.activity-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 0.1rem; }
.activity-body { flex: 1; }
.activity-meta { color: var(--muted); font-size: 0.78rem; margin-top: 0.2rem; }

/* ── Note items ───────────────────────────────────────────── */
.note-item {
  padding: 0.75rem;
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}
.note-meta { color: var(--muted); font-size: 0.75rem; margin-top: 0.4rem; }
.note-visible-badge { font-size: 0.7rem; color: var(--amber); margin-left: 0.5rem; }

/* ── Project items ────────────────────────────────────────── */
.project-item {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
}
.project-item-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.25rem; }
.project-name { font-weight: 600; font-size: 0.9rem; }
.project-meta { color: var(--muted); font-size: 0.78rem; }

/* ── Inline form ──────────────────────────────────────────── */
.inline-form {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 0.75rem;
  display: none;
}
.inline-form.open { display: block; }

/* ── Pipeline summary ─────────────────────────────────────── */
.pipeline-row {
  display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem;
}
.pipeline-item {
  flex: 1; min-width: 100px;
  text-align: center;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.5rem;
}
.pipeline-num { font-size: 1.5rem; font-weight: 700; color: var(--amber); }
.pipeline-label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* ── Quick actions ────────────────────────────────────────── */
.quick-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.75rem; }

/* ── Loading spinner ──────────────────────────────────────── */
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(250,172,92,0.3); border-top-color: var(--amber); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-loading { opacity: 0.7; pointer-events: none; }

/* ── Empty state ──────────────────────────────────────────── */
.empty-state { text-align: center; color: var(--muted); padding: 2rem; font-size: 0.875rem; border: 1px dashed rgba(244,240,234,0.1); border-radius: var(--radius); margin: 0.5rem 0; }

/* ── Section spacing ──────────────────────────────────────── */
.section { margin-bottom: 1.25rem; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.section-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(244,240,234,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(244,240,234,0.25); }

/* ── Document items ──────────────────────────────────────── */
.doc-item {
  padding: 0.75rem;
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}
.doc-meta {
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 0.25rem;
  min-height: 1rem;
}

/* ── Status pill inline select (clients list) ─────────────── */
.status-inline-select {
  width: auto;
  min-width: 130px;
  padding: 0.2rem 0.5rem;
  font-size: 0.78rem;
}
.pill-clickable { cursor: pointer; }
.pill-clickable:hover { opacity: 0.8; }

/* ── Responsive utilities ─────────────────────────────────── */
@media (max-width: 600px) {
  .main-content { padding: 1rem; }
  .hide-mobile { display: none; }
  .header { padding: 0 1rem; }
}

/* ── Mobile / Phone — Global responsive overhaul ─────────── */

/* Hamburger menu button — hidden on desktop */
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.35rem 0.6rem;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

@media (max-width: 768px) {

  /* Show hamburger, hide nav links by default */
  .nav-toggle { display: block; }

  .header-right {
    display: none;
    position: fixed;
    top: 56px;
    left: 0; right: 0;
    background: rgba(8,6,18,0.98);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.5rem 0;
    display: none;
    z-index: 200;
    backdrop-filter: blur(12px);
  }

  .header-right.open { display: flex; }

  .header-right .btn {
    border-radius: 0;
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 1.25rem;
    font-size: 0.9rem;
    justify-content: flex-start;
    text-align: left;
    width: 100%;
  }

  .header-right .btn:last-child { border-bottom: none; }
  .header-right .btn:hover { background: rgba(250,172,92,0.1); color: var(--amber); }

  .header-user {
    padding: 0.85rem 1.25rem;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
  }

  /* Main content */
  .main-content { padding: 0.85rem; }

  /* Page header stacks vertically */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  /* Stats row — 2 columns on phone */
  .stats-row { grid-template-columns: 1fr 1fr; }

  /* Dashboard grid — single column */
  .dashboard-grid { grid-template-columns: 1fr; }

  /* Client view handled by min-width rules above */

  /* Filter bar wraps */
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar form { flex-wrap: wrap; }
  .search-input { max-width: 100% !important; width: 100%; }

  /* Form rows collapse */
  .form-row { grid-template-columns: 1fr !important; }

  /* Tables scroll horizontally */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Cards full width */
  .card { border-radius: var(--radius); }

  /* Pipeline items — 2 columns */
  .pipeline-row { grid-template-columns: 1fr 1fr; display: grid; }

  /* Buttons in rows wrap */
  .form-actions { flex-wrap: wrap; }

  /* Template library — stack card actions */
  .template-card-actions { flex-direction: column; align-items: stretch; }
  .template-card-actions .btn { text-align: center; justify-content: center; }

  /* Hide less important columns on mobile */
  .hide-mobile { display: none !important; }

  /* Headings scale down */
  h1 { font-size: 1.3rem; }
  h2 { font-size: 1.1rem; }

  /* Pre blocks scroll */
  pre { overflow-x: auto; -webkit-overflow-scrolling: touch; font-size: 0.8rem; }

  /* Kanban — scroll horizontally */
  .kanban-board { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Stat cards */
  .stat-value { font-size: 1.6rem; }
}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; }
  .pipeline-row { grid-template-columns: 1fr 1fr; }
}

/* ── Dashboard mobile fixes ────────────────────────────────── */
@media (max-width: 768px) {
  /* Action bar — 2 columns on phone */
  .action-bar { grid-template-columns: 1fr 1fr !important; gap: 0.5rem !important; }
  .action-card { padding: 0.75rem 0.85rem; }
  .action-card .ac-count { font-size: 1.5rem; }

  /* Stats row — 2 columns */
  .stats-row { grid-template-columns: 1fr 1fr !important; gap: 0.5rem !important; }
  .stat-value { font-size: 1.4rem !important; }

  /* Dashboard main — single column */
  .dashboard-main { grid-template-columns: 1fr !important; }

  /* Funnel — scroll horizontally on very small screens */
  .funnel-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .funnel-stage { min-width: 64px; padding: 0.75rem 0.4rem; }
  .funnel-count { font-size: 1.2rem; }
  .funnel-label { font-size: 0.62rem; }
  .funnel-arrow { display: none; }

  /* Hot leads table — hide notes col on mobile */
  .hot-leads-table th:nth-child(2),
  .hot-leads-table td:nth-child(2) { display: none; }

  /* Quick actions list — 2 column grid on phone */
  .quick-actions-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }

  /* Admin grid */
  .admin-grid { grid-template-columns: 1fr !important; }

  /* Modal full-width */
  .modal-box { margin: 0.5rem; }
}

@media (max-width: 420px) {
  /* Very small — action bar single column */
  .action-bar { grid-template-columns: 1fr !important; }
  .quick-actions-list { grid-template-columns: 1fr !important; }
}

/* Global overflow fix */
html, body { overflow-x: hidden; max-width: 100%; }
.portal-wrap { overflow-x: hidden; max-width: 100vw; }


/* ── Tools dropdown ── */
.nav-dropdown { position: relative; }
.nav-dropdown-btn { cursor: pointer; background: none; font-family: var(--font); }

@media (max-width: 900px) {
  .nav-dropdown { width: 100%; }
  .nav-dropdown-btn {
    width: 100%; text-align: left; border-radius: 0;
    border: none; border-bottom: 1px solid var(--border);
    padding: 0.85rem 1.25rem;
  }
  .nav-dropdown-menu {
    position: static !important;
    display: block !important;
    background: rgba(255,255,255,0.03) !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .nav-dropdown-menu a {
    padding-left: 2rem !important;
    border-bottom: 1px solid rgba(244,240,234,0.05) !important;
  }
}

/* ── Print: show only proposal content ─────────────────────── */
@media print {
  nav, header, .portal-nav, .main-content, .container, .page-header,
  .steps-indicator, .step-panel, h1, .card:not(#print-proposal-wrapper .card),
  .proposal-modal-bar, .print-bar, .modal-top-bar { display: none !important; }
  .proposal-modal { display: block !important; position: static !important;
    background: none !important; padding: 0 !important; overflow: visible !important; }
  .proposal-modal-inner { box-shadow: none !important; border-radius: 0 !important;
    max-width: 100% !important; width: 100% !important; }
  #proposal-content { display: block !important; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}

/* Prevent content overflowing client panel columns */
.client-panel { overflow: hidden; }
.client-panel .section { overflow: hidden; }
.client-panel .info-value { word-break: break-word; overflow-wrap: anywhere; max-width: 100%; }
.section-header { flex-wrap: wrap; gap: 0.3rem; }
.section-header div { flex-wrap: wrap; gap: 0.3rem; }

