/*
 * This is a manifest file that'll be compiled into application.css.
 */

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg: #f8f9fa;
  --color-sidebar: #1a1d23;
  --color-sidebar-hover: #2a2d35;
  --color-sidebar-active: #3b5bdb;
  --color-primary: #3b5bdb;
  --color-primary-hover: #2f4ac5;
  --color-success: #2f9e44;
  --color-warning: #e67700;
  --color-danger: #c92a2a;
  --color-info: #1971c2;
  --color-muted: #868e96;
  --color-text: #212529;
  --color-border: #dee2e6;
  --color-card: #ffffff;
  --sidebar-width: 220px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body { font-family: var(--font); color: var(--color-text); background: var(--color-bg); font-size: 14px; line-height: 1.5; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Admin Layout ===== */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar);
  color: #c1c7d0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-brand { padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.brand-link { color: #fff; font-size: 18px; font-weight: 700; letter-spacing: -0.3px; text-decoration: none; }

.nav-items { list-style: none; padding: 12px 0; flex: 1; }
.nav-items li a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; color: #c1c7d0; text-decoration: none;
  transition: background 0.15s, color 0.15s; font-size: 13.5px;
}
.nav-items li a:hover { background: var(--color-sidebar-hover); color: #fff; }
.nav-items li.active a { background: var(--color-sidebar-active); color: #fff; }
.nav-icon { font-size: 12px; opacity: 0.7; }

.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,0.08); font-size: 12px; }
.user-email { display: block; color: #8899aa; margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-signout {
  background: none; border: 1px solid rgba(255,255,255,0.2); color: #c1c7d0;
  padding: 5px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; width: 100%;
}
.btn-signout:hover { background: rgba(255,255,255,0.1); }

.main-content { margin-left: var(--sidebar-width); flex: 1; padding: 24px; max-width: 1400px; }

/* ===== Flash Messages ===== */
.flash { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 13.5px; }
.flash-notice { background: #d3f9d8; color: #2b8a3e; border: 1px solid #b2f2bb; }
.flash-alert { background: #ffe3e3; color: #c92a2a; border: 1px solid #ffa8a8; }

/* ===== Page Header ===== */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 22px; font-weight: 700; color: #1a1d23; }
.header-actions { display: flex; gap: 8px; }
.breadcrumb { font-size: 13px; color: var(--color-muted); margin-bottom: 6px; }
.breadcrumb a { color: var(--color-muted); }
.breadcrumb a:hover { color: var(--color-primary); }
.count-badge { background: #e9ecef; color: #495057; padding: 2px 8px; border-radius: 12px; font-size: 13px; font-weight: 600; vertical-align: middle; margin-left: 6px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 6px; border: none; cursor: pointer;
  font-size: 13.5px; font-weight: 500; text-decoration: none; transition: all 0.15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); color: #fff; }
.btn-secondary { background: #fff; color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: #f1f3f5; }
.btn-ghost { background: transparent; color: var(--color-muted); }
.btn-ghost:hover { background: #f1f3f5; color: var(--color-text); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 15px; }

/* ===== Cards ===== */
.card { background: var(--color-card); border: 1px solid var(--color-border); border-radius: 8px; padding: 20px; margin-bottom: 20px; }
.card h2 { font-size: 15px; font-weight: 600; color: #1a1d23; margin-bottom: 16px; }

/* ===== Stats Grid ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--color-card); border: 1px solid var(--color-border); border-radius: 8px; padding: 18px; border-top: 3px solid var(--color-muted); }
.stat-card.stat-active { border-top-color: var(--color-success); }
.stat-card.stat-warning { border-top-color: var(--color-warning); }
.stat-card.stat-info { border-top-color: var(--color-info); }
.stat-card.stat-success { border-top-color: var(--color-primary); }
.stat-value { font-size: 26px; font-weight: 700; color: #1a1d23; line-height: 1; }
.stat-label { font-size: 12px; color: var(--color-muted); margin-top: 6px; text-transform: uppercase; letter-spacing: 0.4px; }

/* ===== Dashboard Grid ===== */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.dashboard-grid .card-wide { grid-column: 1 / -1; }

/* ===== Data Tables ===== */
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th { text-align: left; padding: 8px 12px; border-bottom: 2px solid var(--color-border); font-size: 12px; font-weight: 600; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid #f1f3f5; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f8f9fa; }
.text-center { text-align: center; }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.text-muted { color: var(--color-muted); }

/* ===== Companies Table ===== */
.company-link { font-weight: 500; color: var(--color-text); }
.company-link:hover { color: var(--color-primary); text-decoration: none; }
.company-url { color: var(--color-muted); font-size: 12px; }
.external-link { color: var(--color-muted); font-size: 12px; }
.external-link:hover { color: var(--color-primary); }
.icon-yes { color: var(--color-success); font-size: 16px; font-weight: 700; }
.icon-no { color: var(--color-muted); }

/* ===== Badges ===== */
.badge {
  display: inline-block; padding: 3px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px;
}
.badge-lg { padding: 6px 14px; font-size: 13px; }

/* URL Status badges */
.badge-active { background: #d3f9d8; color: #2b8a3e; }
.badge-inactive { background: #ffe3e3; color: #c92a2a; }
.badge-unverified { background: #fff3bf; color: #795e00; }
.badge-redirect { background: #d0ebff; color: #1864ab; }
.badge-error { background: #ffe3e3; color: #c92a2a; }

/* Lead Stage badges */
.badge-stage-unqualified { background: #f1f3f5; color: #495057; }
.badge-stage-qualified { background: #d3f9d8; color: #2b8a3e; }
.badge-stage-disqualified { background: #ffe3e3; color: #c92a2a; }
.badge-stage-in_progress { background: #d0ebff; color: #1864ab; }

/* Import status badges */
.badge-import-pending { background: #fff3bf; color: #795e00; }
.badge-import-processing { background: #d0ebff; color: #1864ab; }
.badge-import-completed { background: #d3f9d8; color: #2b8a3e; }
.badge-import-failed { background: #ffe3e3; color: #c92a2a; }

/* Email status badges */
.badge-email-valid { background: #d3f9d8; color: #2b8a3e; }
.badge-email-risky { background: #fff3bf; color: #795e00; }
.badge-email-invalid { background: #ffe3e3; color: #c92a2a; }
.badge-email-unknown { background: #f1f3f5; color: #495057; }

/* Enrichment log status badges */
.badge-log-success { background: #d3f9d8; color: #2b8a3e; }
.badge-log-failed { background: #ffe3e3; color: #c92a2a; }

/* ===== Filter Bar ===== */
.filter-bar { margin-bottom: 20px; }
.filter-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-group { display: flex; }
.form-control { padding: 7px 10px; border: 1px solid var(--color-border); border-radius: 6px; font-size: 13.5px; color: var(--color-text); background: #fff; }
.form-control:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 2px rgba(59,91,219,0.15); }
.search-input { min-width: 240px; }

/* ===== Pagination ===== */
nav.pagy.nav {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding-top: 24px;
}
nav.pagy.nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  text-decoration: none;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
  cursor: pointer;
}
nav.pagy.nav a:not([aria-disabled="true"]):hover {
  background: #f1f3f5;
  border-color: #ced4da;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  cursor: pointer;
}
nav.pagy.nav a.current {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(59,91,219,0.35);
  cursor: default;
}
nav.pagy.nav a.gap {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--color-muted);
  cursor: default;
}
nav.pagy.nav a[aria-disabled="true"]:not(.current):not(.gap) {
  color: var(--color-muted);
  background: #f8f9fa;
  box-shadow: none;
  cursor: not-allowed;
}

/* ===== Detail View ===== */
.detail-grid { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
.detail-grid .contacts-section, .detail-grid .enrichment-log-section { grid-column: 2; }
.detail-grid .enrichment-log-section { grid-column: 2; }

/* Full-width sections */
.detail-grid .contacts-section,
.detail-grid .enrichment-log-section { grid-column: 1 / -1; }

.meta-row { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid #f1f3f5; align-items: flex-start; font-size: 13.5px; }
.meta-row:last-child { border-bottom: none; }
.meta-row label { min-width: 140px; color: var(--color-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; padding-top: 2px; flex-shrink: 0; }
.meta-section { margin-top: 20px; }

.inline-form { border-bottom: 1px solid var(--color-border); padding-bottom: 16px; margin-bottom: 8px; }
.inline-form .meta-row { flex-direction: column; gap: 4px; }
.inline-form .meta-row label { min-width: auto; }
.inline-form .form-control { width: 100%; }

/* ===== Tech Tags ===== */
.tech-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { background: #e9ecef; color: #495057; padding: 2px 8px; border-radius: 12px; font-size: 11px; }

/* ===== Import Form ===== */
.import-form-card { max-width: 640px; }
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.form-hint { font-size: 12.5px; color: var(--color-muted); margin-top: 4px; }
.form-actions { display: flex; gap: 10px; padding-top: 8px; }
.file-upload-area { border: 2px dashed var(--color-border); border-radius: 8px; padding: 32px; text-align: center; position: relative; cursor: pointer; transition: border-color 0.15s; }
.file-upload-area:hover { border-color: var(--color-primary); }
.file-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; z-index: 1; }
.file-selected ~ .file-input, .file-upload-area:has(.file-selected:not([hidden])) .file-input { pointer-events: none; }
.upload-icon { font-size: 32px; color: var(--color-muted); }
.file-upload-placeholder p { color: var(--color-muted); margin-top: 8px; font-size: 13.5px; }
.upload-hint { font-size: 12px; }

.file-selected {
  display: flex; align-items: center; gap: 14px;
  padding: 4px 0;
}
.file-selected[hidden] { display: none; }
.file-selected-icon {
  font-size: 28px; color: var(--color-success);
  background: #d3f9d8; border-radius: 50%;
  width: 48px; height: 48px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.file-selected-info { flex: 1; text-align: left; }
.file-selected-name { display: block; font-weight: 600; font-size: 14px; color: var(--color-text); word-break: break-all; }
.file-selected-size { display: block; font-size: 12px; color: var(--color-muted); margin-top: 2px; }
.file-clear-btn {
  background: none; border: 1px solid var(--color-border); border-radius: 5px;
  padding: 5px 10px; font-size: 12px; color: var(--color-muted); cursor: pointer;
  flex-shrink: 0; white-space: nowrap;
}
.file-clear-btn:hover { border-color: var(--color-danger); color: var(--color-danger); background: #fff5f5; }
.code-block { background: #f1f3f5; padding: 12px; border-radius: 6px; font-size: 13px; margin-top: 8px; font-family: monospace; }

/* ===== Import Detail ===== */
.import-status-header { margin-bottom: 20px; }
.processing-note { color: var(--color-info); margin-top: 10px; font-size: 13.5px; }
.meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.meta-item label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: var(--color-muted); margin-bottom: 4px; }
.import-results h2 { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.results-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.result-item { text-align: center; padding: 16px; background: #f8f9fa; border-radius: 8px; }
.result-item.result-success { background: #d3f9d8; }
.result-item.result-warning { background: #fff3bf; }
.result-item.result-danger { background: #ffe3e3; }
.result-value { font-size: 28px; font-weight: 700; }
.result-label { font-size: 12px; color: var(--color-muted); margin-top: 4px; }
.error-message { background: #ffe3e3; border: 1px solid #ffa8a8; border-radius: 6px; padding: 16px; margin-bottom: 20px; }
.error-message h3 { color: var(--color-danger); margin-bottom: 8px; }
.error-message pre { font-size: 12.5px; white-space: pre-wrap; }

/* ===== Empty State ===== */
.empty-state { text-align: center; padding: 48px 24px; color: var(--color-muted); }
.empty-state p { margin-bottom: 16px; }
.empty-state.small { padding: 24px; }

/* ===== Devise Pages ===== */
.devise-layout { display: flex; min-height: 100vh; align-items: center; justify-content: center; background: #f1f3f5; }
.devise-card { background: #fff; border: 1px solid var(--color-border); border-radius: 10px; padding: 40px; width: 100%; max-width: 400px; }
.devise-card h2 { font-size: 22px; font-weight: 700; margin-bottom: 24px; text-align: center; }
