@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap");

/* ========================================
   GENIRI CRM — Professional dual-theme UI
   Light (default) + Dark (data-theme="dark")
   ======================================== */

:root {
  --bg-page: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #ffffff;
  --bg-topbar: #ffffff;
  --bg-nav-active: #eff6ff;
  --border: #e2e8f0;
  --border-input: #cbd5e1;
  --border-input-focus: #2563eb;
  --text: #1e293b;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-placeholder: #94a3b8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #dbeafe;
  --accent-text: #ffffff;
  --ok: #16a34a;
  --ok-bg: #f0fdf4;
  --ok-border: #bbf7d0;
  --ok-text: #166534;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
  --warn-text: #92400e;
  --bad: #dc2626;
  --bad-bg: #fef2f2;
  --bad-border: #fecaca;
  --bad-text: #991b1b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
}

[data-theme="dark"] {
  --bg-page: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #263548;
  --bg-input: #0f172a;
  --bg-topbar: #1e293b;
  --bg-nav-active: rgba(59, 130, 246, 0.15);
  --border: #334155;
  --border-input: #475569;
  --border-input-focus: #3b82f6;
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-placeholder: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: rgba(59, 130, 246, 0.2);
  --accent-text: #ffffff;
  --ok: #22c55e;
  --ok-bg: rgba(34, 197, 94, 0.1);
  --ok-border: rgba(34, 197, 94, 0.3);
  --ok-text: #86efac;
  --warn: #f59e0b;
  --warn-bg: rgba(245, 158, 11, 0.1);
  --warn-border: rgba(245, 158, 11, 0.3);
  --warn-text: #fcd34d;
  --bad: #ef4444;
  --bad-bg: rgba(239, 68, 68, 0.1);
  --bad-border: rgba(239, 68, 68, 0.3);
  --bad-text: #fca5a5;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
}

/* ====== RESET ====== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100vh; }

body {
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg-page);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ====== UTILITY ====== */
.hidden { display: none !important; }

/* ====== AUTH SCREEN ====== */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 32px 32px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 32px;
}

.auth-logo .logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  flex-shrink: 0;
}

.auth-logo h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.auth-title {
  text-align: center;
  margin-bottom: 24px;
}

.auth-title h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.auth-title p {
  font-size: 14px;
  color: var(--text-muted);
}

/* ====== FORMS ====== */
.form { display: grid; gap: 16px; }

.field { display: grid; gap: 6px; }

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.field-input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field-input::placeholder { color: var(--text-placeholder); }

.field-input:focus {
  outline: none;
  border-color: var(--border-input-focus);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.field-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.field-link {
  font-size: 13px;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
  font-weight: 500;
}

.field-link:hover { text-decoration: underline; }

/* ====== BUTTONS ====== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 20px;
  border: none;
  border-radius: var(--radius);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.1s, opacity 0.15s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) { background: var(--bg-card-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 0 12px;
  height: 36px;
}

.btn-ghost:hover:not(:disabled) { background: var(--bg-card-hover); }

.btn-full { width: 100%; }

/* ====== DIVIDER ====== */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 13px;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ====== AUTH MESSAGE ====== */
.auth-msg {
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  border: 1px solid transparent;
  text-align: center;
}

.auth-msg-ok { color: var(--ok-text); background: var(--ok-bg); border-color: var(--ok-border); }
.auth-msg-warn { color: var(--warn-text); background: var(--warn-bg); border-color: var(--warn-border); }
.auth-msg-bad { color: var(--bad-text); background: var(--bad-bg); border-color: var(--bad-border); }
.auth-msg-hidden { display: none; }

.auth-footer {
  margin-top: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* ====== GOOGLE BUTTON ====== */
.btn-google {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 500;
}

.btn-google:hover:not(:disabled) { background: var(--bg-card-hover); }

.btn-google svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ====== TOPBAR ====== */
.topbar {
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 8px;
  flex-shrink: 0;
}

.topbar-brand .logo-mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
}

.topbar-brand h1 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

/* ====== NAV TABS ====== */
.nav-tabs {
  display: flex;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.nav-tab {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.nav-tab:hover { color: var(--text); background: var(--bg-card-hover); }

.nav-tab-active {
  color: var(--accent);
  background: var(--bg-nav-active);
}

/* ====== TOPBAR RIGHT ====== */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.15s, color 0.15s;
}

.theme-toggle:hover { color: var(--text); background: var(--bg-card-hover); }

.user-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-light);
  border: 1px solid var(--border);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ====== STATUS INDICATOR ====== */
.status-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.status-ok { color: var(--ok-text); background: var(--ok-bg); border-color: var(--ok-border); }
.status-warn { color: var(--warn-text); background: var(--warn-bg); border-color: var(--warn-border); }
.status-bad { color: var(--bad-text); background: var(--bad-bg); border-color: var(--bad-border); }

/* ====== WORKSPACE ====== */
.workspace {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  gap: 20px;
}

/* ====== STATS GRID ====== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.stat-card h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}

.stat-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stat-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.stat-tag-new { color: var(--accent); background: var(--accent-light); }
.stat-tag-qualified, .stat-tag-won { color: var(--ok-text); background: var(--ok-bg); }
.stat-tag-lost { color: var(--bad-text); background: var(--bad-bg); }
.stat-tag-open { color: var(--warn-text); background: var(--warn-bg); }

/* ====== CONTENT GRID ====== */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ====== CARD ====== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

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

.card-header h2 {
  font-size: 15px;
  font-weight: 700;
}

.card-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: 999px;
}

.card-body { padding: 16px 20px; }

/* ====== LIST ITEMS ====== */
.list { display: grid; gap: 8px; }
.list-empty { color: var(--text-muted); font-size: 14px; padding: 12px 0; text-align: center; }

.list-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  transition: background-color 0.15s;
}

.list-item:hover { background: var(--bg-card-hover); }

.list-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.list-item-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
  align-items: center;
}

.list-item-meta .separator { color: var(--border); }

.list-scroll {
  max-height: 320px;
  overflow-y: auto;
}

/* ====== STATUS BADGES (inline) ====== */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.badge-new { color: var(--accent); background: var(--accent-light); }
.badge-qualified { color: var(--ok-text); background: var(--ok-bg); }
.badge-lost { color: var(--bad-text); background: var(--bad-bg); }
.badge-open { color: var(--warn-text); background: var(--warn-bg); }
.badge-won { color: var(--ok-text); background: var(--ok-bg); }

/* ====== PIPELINES ====== */
.pipeline-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.pipeline-name {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
}

.pipeline-stages {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.pipeline-stage {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--accent);
}

.pipeline-arrow {
  color: var(--text-muted);
  font-size: 12px;
}

/* ====== CREATE FORMS (inline) ====== */
.inline-form {
  display: grid;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

.inline-form .field-input { height: 38px; font-size: 13px; }

.inline-form .btn {
  height: 38px;
  font-size: 13px;
}

/* ====== SECTION PAGE ====== */
.section-page { display: grid; gap: 16px; }
.section-full { grid-column: 1 / -1; }

/* ====== ANIMATIONS ====== */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fade-in 0.3s ease both; }

/* ====== RESPONSIVE ====== */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .topbar { padding: 0 16px; gap: 8px; }
  .nav-tabs { overflow-x: auto; }
  .nav-tab { padding: 8px 12px; font-size: 12px; }
  .stats-grid { grid-template-columns: 1fr; }
  .content-grid { grid-template-columns: 1fr; }
  .workspace { padding: 16px; }
  .auth-card { padding: 32px 20px 24px; }
  .user-badge { display: none; }
}

@media (max-width: 480px) {
  .topbar-brand h1 { display: none; }
  .topbar { height: 48px; }
}
