/* ============================================================
   Estate2Look Prospector - studiofive18 Design System
   ============================================================ */

:root {
  --bg-page: #0F172A;
  --bg-card: #1E293B;
  --bg-card-hover: #243044;
  --bg-subtle: #162032;
  --bg-input: #0F172A;
  --border: #334155;
  --border-light: #293548;
  --teal: #4D9B8F;
  --teal-dark: #3E8579;
  --teal-bg: rgba(77, 155, 143, 0.08);
  --teal-border: rgba(77, 155, 143, 0.2);
  --terra: #C4654A;
  --terra-bg: rgba(196, 101, 74, 0.08);
  --terra-border: rgba(196, 101, 74, 0.2);
  --text-heading: #FFFFFF;
  --text-body: #E2E8F0;
  --text-muted: #94A3B8;
  --text-dim: #64748B;
  --success: #22C55E;
  --warning: #EAB308;
  --error: #EF4444;
  --radius: 10px;
  --radius-sm: 6px;
}

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

body {
  background: var(--bg-page);
  font-family: 'Sora', sans-serif;
  color: var(--text-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ---- Logo ---- */
.logo {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
  color: var(--text-heading);
  line-height: 1;
  user-select: none;
}
.logo em { font-style: italic; }

/* ---- Auth Gate ---- */
.auth-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  max-width: 400px;
  width: 100%;
  text-align: center;
}

.auth-card .logo { font-size: 28px; margin-bottom: 24px; }

.auth-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 20px;
  color: var(--text-heading);
  margin-bottom: 8px;
}

.auth-sub {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.auth-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-body);
  font-family: 'Sora', sans-serif;
  font-size: 14px;
  margin-bottom: 16px;
  transition: border-color 0.2s;
}

.auth-input:focus {
  outline: none;
  border-color: var(--teal);
}

.auth-error {
  color: var(--error);
  font-size: 13px;
  margin-top: 12px;
  min-height: 20px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Sora', sans-serif;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--teal);
  color: #FFFFFF;
}
.btn-primary:hover { background: var(--teal-dark); }
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-lg { padding: 14px 32px; font-size: 15px; }

.btn-icon { font-size: 12px; }

/* ---- Header ---- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
}

.header-product {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: var(--teal);
  letter-spacing: 0.02em;
}

/* ---- Main ---- */
.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ---- Cards ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.card-search .card-header {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.card-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 18px;
  color: var(--text-heading);
}

.card-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---- Search Form ---- */
.search-form {
  padding: 24px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.form-grid-3col {
  grid-template-columns: 1fr 1fr 1fr;
}

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  height: 32px;
  line-height: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-dim);
}

.form-group select,
.form-group input[type="text"] {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-body);
  font-family: 'Sora', sans-serif;
  font-size: 14px;
  transition: border-color 0.2s;
  appearance: none;
  -webkit-appearance: none;
}

.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394A3B8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.form-group select:focus,
.form-group input[type="text"]:focus {
  outline: none;
  border-color: var(--teal);
}

.range-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.range-group input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}

.range-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: var(--teal);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--bg-card);
}

.range-value {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 18px;
  color: var(--teal);
  min-width: 40px;
  text-align: right;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
}

/* ---- History Table ---- */
.card-history #history-content {
  overflow-x: auto;
}

.history-table {
  width: 100%;
  min-width: 700px;
  border-collapse: collapse;
}

.history-table thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}

.history-table tbody td {
  padding: 14px 16px;
  font-size: 13.5px;
  color: var(--text-body);
  border-bottom: 1px solid var(--border-light);
}

.history-table tbody tr:hover {
  background: var(--bg-card-hover);
}

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

/* Status badges */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
}

.status-running {
  background: rgba(234, 179, 8, 0.1);
  color: var(--warning);
}
.status-running::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--warning);
  animation: pulse 1.5s ease-in-out infinite;
}

.status-complete {
  background: rgba(34, 197, 94, 0.1);
  color: var(--success);
}
.status-complete::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.status-partial {
  background: rgba(196, 101, 74, 0.1);
  color: var(--terra);
}
.status-partial::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--terra);
}

.status-error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
}
.status-error::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--error);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Count badges */
.count-free {
  color: var(--teal);
  font-weight: 600;
}
.count-restricted {
  color: var(--terra);
  font-weight: 600;
}

/* Link in table */
.link-btn {
  color: var(--teal);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid var(--teal-border);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}
.link-btn:hover {
  background: var(--teal-bg);
}

/* ---- Loading & Empty States ---- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 14px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 14px;
}
.empty-state .text-muted { color: var(--text-dim); margin-top: 4px; }

/* ---- Footer ---- */
.footer {
  text-align: center;
  padding: 24px;
  font-size: 12px;
  color: var(--text-dim);
}
.footer em { font-style: italic; }
.footer-sep { margin: 0 8px; }
.text-muted { color: var(--text-muted); }

/* ---- Toast Notification ---- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: #FFFFFF;
  z-index: 1000;
  animation: slideIn 0.3s ease;
  max-width: 400px;
}

.toast-success { background: var(--teal-dark); }
.toast-error { background: var(--error); }

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

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .header { padding: 12px 16px; }
  .header-product { display: none; }
  .header-sep { display: none; }
  .main { padding: 16px 12px 48px; }
  .card-header { padding: 16px; flex-direction: column; align-items: flex-start; gap: 4px; }
  .card-search .card-header .card-sub { font-size: 12px; }
  .search-form { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; gap: 16px; }
  .form-grid-3col { grid-template-columns: 1fr; }
  .form-actions { justify-content: stretch; }
  .form-actions .btn { width: 100%; }
  .card-history #history-content { overflow-x: hidden; }
  .history-table { font-size: 12px; min-width: unset; width: 100%; }
  .history-table thead th,
  .history-table tbody td { padding: 10px 8px; }
  .history-table thead th:nth-child(4),
  .history-table tbody td:nth-child(4),
  .history-table thead th:nth-child(5),
  .history-table tbody td:nth-child(5),
  .history-table thead th:nth-child(6),
  .history-table tbody td:nth-child(6),
  .history-table thead th:nth-child(8),
  .history-table tbody td:nth-child(8) { display: none; }
  .status { font-size: 11px; padding: 3px 8px; }
  .auth-card { padding: 32px 24px; }
}
