/* =========================================
   ContractorSource — App Styles
   Lead capture form, admin pages, dashboard
   ========================================= */

/* =========== SUBMIT FORM =========== */
.submit-page {
  min-height: 100vh;
  background: var(--bg);
  padding: 2rem 1.5rem 5rem;
}

.submit-page .container {
  max-width: 680px;
  margin: 0 auto;
}

.submit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2.5rem;
}

.back-link {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.back-link:hover { color: var(--fg); }

.submit-badge {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-subtle);
  padding: 0.3rem 0.75rem;
  border-radius: 100px;
}

.submit-hero {
  margin-bottom: 2.5rem;
}

.submit-hero .eyebrow {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 0.5rem;
  font-family: 'DM Sans', sans-serif;
}

.submit-hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  margin-bottom: 0.75rem;
}

.submit-hero .sub {
  font-size: 0.95rem;
  color: var(--fg-muted);
  line-height: 1.65;
}

.lead-form {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.form-section {
  padding: 2rem 2rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.form-section:last-of-type { border-bottom: none; }

.section-title {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
  margin-bottom: 1.25rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group:last-child { margin-bottom: 0; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

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

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 0.4rem;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: 'DM Sans', sans-serif;
  color: var(--fg);
  background: var(--bg);
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

input::placeholder, textarea::placeholder {
  color: var(--fg-muted);
  opacity: 0.6;
}

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

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

.field-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--fg-muted);
  margin-top: 0.3rem;
}

.form-error {
  margin: 0 2rem 0;
  padding: 0.75rem 1rem;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  color: #dc2626;
  font-size: 0.875rem;
  font-weight: 500;
}

.btn-submit {
  display: block;
  width: calc(100% - 4rem);
  margin: 1.5rem 2rem;
  padding: 1rem;
  background: var(--accent);
  color: var(--fg);
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  text-align: center;
}

.btn-submit:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-submit:active { transform: translateY(0); }
.btn-submit:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }

.btn-text { display: inline; }
.btn-loading {
  display: none;
  align-items: center;
  gap: 0.5rem;
}

.spinner {
  width: 18px;
  height: 18px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.form-legal {
  text-align: center;
  font-size: 0.8rem;
  color: var(--fg-muted);
  margin: 0 2rem 2rem;
}

.success-message {
  text-align: center;
  padding: 4rem 2rem;
}

.success-icon { margin-bottom: 1.5rem; }

.success-message h2 {
  font-size: 1.8rem;
  margin-bottom: 0.75rem;
}

.success-message p {
  color: var(--fg-muted);
  margin-bottom: 2rem;
}

.btn-home {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background: var(--fg);
  color: white;
  border-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.15s;
}
.btn-home:hover { opacity: 0.85; color: white; }

/* =========== ADMIN PAGES =========== */
.admin-page {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
}

.admin-container { width: 100%; max-width: 400px; }

.admin-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow);
}

.admin-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--fg);
  margin-bottom: 2rem;
}

.admin-card h1 {
  font-size: 1.5rem;
  margin-bottom: 0.35rem;
}

.admin-subtitle {
  color: var(--fg-muted);
  font-size: 0.9rem;
  margin-bottom: 1.75rem;
}

.btn-admin-submit {
  width: 100%;
  padding: 0.85rem;
  background: var(--fg);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: opacity 0.15s;
  margin-top: 0.5rem;
}
.btn-admin-submit:hover { opacity: 0.85; }
.btn-admin-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.setup-prompt {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--fg-muted);
  text-align: center;
}

/* =========== DASHBOARD =========== */
.dashboard-page { min-height: 100vh; background: var(--bg); }

.dash-header {
  background: var(--fg);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: sticky;
  top: 0;
  z-index: 20;
}

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

.dash-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1rem;
  color: white;
}

.dash-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--accent);
  color: var(--fg);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.dash-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.875rem;
  color: rgba(255,255,255,0.6);
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: none;
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.6);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.btn-logout:hover { color: white; border-color: rgba(255,255,255,0.35); }

.dash-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.dash-intro {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.dash-intro h1 { font-size: 1.6rem; }
.dash-intro p { color: var(--fg-muted); font-size: 0.9rem; margin-top: 0.2rem; }

.btn-cta-small {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--accent);
  color: var(--fg);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-cta-small:hover { background: var(--accent-hover); color: var(--fg); }

/* Stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
  .stats-row { grid-template-columns: repeat(3, 1fr); }
}

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

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

.stat-value {
  font-family: 'Fraunces', serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--fg);
  line-height: 1;
  margin-bottom: 0.35rem;
}

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

.stat-new .stat-value { color: #2563eb; }
.stat-contacted .stat-value { color: #7c3aed; }
.stat-quoted .stat-value { color: #d97706; }
.stat-won .stat-value { color: #059669; }
.stat-lost .stat-value { color: #dc2626; }

/* Filters */
.dash-filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.filter-tabs {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.filter-tab {
  padding: 0.4rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  background: white;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  color: var(--fg-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.filter-tab.active {
  background: var(--fg);
  color: white;
  border-color: var(--fg);
}

.filter-tab:hover:not(.active) { border-color: var(--fg-muted); }

.filter-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.9rem;
  color: var(--fg-muted);
}

.filter-search input {
  border: none;
  background: none;
  outline: none;
  font-size: 0.875rem;
  font-family: 'DM Sans', sans-serif;
  color: var(--fg);
  width: 220px;
}

.filter-search input::placeholder { color: var(--fg-muted); opacity: 0.6; }

/* Table */
.leads-table-wrap { background: white; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }

.leads-empty {
  padding: 3rem 2rem;
  text-align: center;
}
.leads-empty p { color: var(--fg-muted); margin-bottom: 0.75rem; }
.leads-empty a { color: var(--accent); font-weight: 600; }

.leads-table { width: 100%; border-collapse: collapse; }

.leads-table thead tr {
  border-bottom: 1.5px solid var(--border);
}

.leads-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  background: var(--bg-alt);
  white-space: nowrap;
}

.leads-table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  vertical-align: middle;
}

.leads-table tr:last-child td { border-bottom: none; }
.leads-table tr:hover td { background: var(--bg); }

.lead-name { font-weight: 600; color: var(--fg); margin-bottom: 0.15rem; }
.lead-email, .lead-phone { font-size: 0.8rem; color: var(--fg-muted); margin-top: 0.1rem; }
.lead-email a, .lead-phone a { color: var(--fg-muted); text-decoration: none; }
.lead-email a:hover, .lead-phone a:hover { color: var(--accent); }

.lead-service { text-transform: capitalize; }
.lead-date { color: var(--fg-muted); white-space: nowrap; }

.status-pill {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.status-new { background: #dbeafe; color: #1d4ed8; }
.status-contacted { background: #ede9fe; color: #6d28d9; }
.status-quoted { background: #fef3c7; color: #b45309; }
.status-won { background: #d1fae5; color: #065f46; }
.status-lost { background: #fee2e2; color: #991b1b; }

.btn-view-lead {
  padding: 0.35rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: white;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  color: var(--fg);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-view-lead:hover { border-color: var(--fg); background: var(--bg); }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.btn-page {
  padding: 0.4rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: white;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-page:hover:not(:disabled) { border-color: var(--fg); }
.btn-page:disabled { opacity: 0.4; cursor: not-allowed; }

#page-info { font-size: 0.85rem; color: var(--fg-muted); }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 31, 46, 0.4);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  background: white;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: white;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-header h2 { font-size: 1.1rem; }

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--fg-muted);
  padding: 0.25rem;
  border-radius: 4px;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--fg); }

.modal-body { padding: 1.5rem; }

.modal-field {
  margin-bottom: 1rem;
}
.modal-field:last-child { margin-bottom: 0; }

.modal-field label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  margin-bottom: 0.2rem;
}

.modal-field > div { font-size: 0.95rem; color: var(--fg); }
.modal-field > div a { color: var(--accent); }
.modal-description { white-space: pre-wrap; line-height: 1.6; }

.modal-footer {
  padding: 1rem 1.5rem 1.5rem;
  border-top: 1px solid var(--border);
}

.modal-status-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-status {
  padding: 0.45rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: white;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  color: var(--fg);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-status:hover { background: var(--bg-alt); border-color: var(--fg-muted); }

/* Responsive table */
@media (max-width: 768px) {
  .leads-table th:nth-child(3),
  .leads-table td:nth-child(3),
  .leads-table th:nth-child(4),
  .leads-table td:nth-child(4) {
    display: none;
  }
}

@media (max-width: 560px) {
  .leads-table th:nth-child(6),
  .leads-table td:nth-child(6) {
    display: none;
  }

  .dash-filters { flex-direction: column; align-items: stretch; }
  .filter-search input { width: 100%; }
}