/* ═══════════════════════════════════════════════════
   Index CLI — Web UI Styles
   Dark theme, glassmorphism, modern design
   ═══════════════════════════════════════════════════ */

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

:root {
  /* Colors */
  --bg-dark: #0b0e14;
  --bg-surface: #131720;
  --bg-card: #1a1f2e;
  --bg-card-hover: #222839;
  --bg-input: #0f1219;
  --border: #2a3042;
  --border-light: #353d54;

  --text-primary: #e4e8f1;
  --text-secondary: #8a93a8;
  --text-muted: #5c6478;

  --accent: #6c5ce7;
  --accent-light: #8577ed;
  --accent-glow: rgba(108, 92, 231, 0.25);

  --green: #00d68f;
  --green-bg: rgba(0, 214, 143, 0.12);
  --red: #ff6b6b;
  --red-bg: rgba(255, 107, 107, 0.12);
  --yellow: #ffc048;
  --yellow-bg: rgba(255, 192, 72, 0.12);
  --blue: #4fc3f7;

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Sidebar */
  --sidebar-width: 260px;
  --header-height: 60px;

  /* Transitions */
  --transition: 0.2s ease;
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-dark);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ── Header ─────────────────────────────────────── */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  background: rgba(19, 23, 32, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.header__logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.header__icon {
  font-size: 24px;
}

.header__title {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-light), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header__badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--accent-glow);
  color: var(--accent-light);
}

.header__quota {
  display: flex;
  gap: var(--space-lg);
  font-size: 13px;
  color: var(--text-secondary);
}

.quota-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.quota-item__bar {
  width: 80px;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}

.quota-item__fill {
  height: 100%;
  border-radius: 3px;
  transition: width var(--transition);
}

.quota-item__fill--insp { background: var(--green); }
.quota-item__fill--idx { background: var(--blue); }

/* ── Layout ─────────────────────────────────────── */
.main {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}

/* ── Sidebar ────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  padding: var(--space-md);
  overflow-y: auto;
}

.sidebar__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.sidebar__title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.sidebar__list {
  list-style: none;
}

.sidebar__item {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 2px;
}

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

.sidebar__item.active {
  background: var(--accent-glow);
  border: 1px solid rgba(108, 92, 231, 0.3);
}

.sidebar__item-name {
  font-weight: 600;
  font-size: 14px;
}

.sidebar__item-url {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Content ────────────────────────────────────── */
.content {
  flex: 1;
  padding: var(--space-xl);
  overflow-y: auto;
  max-height: calc(100vh - var(--header-height));
}

/* ── Empty State ────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  text-align: center;
  color: var(--text-secondary);
}

.empty-state__icon {
  font-size: 64px;
  margin-bottom: var(--space-lg);
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.empty-state h2 {
  font-size: 20px;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

/* ── Dashboard ──────────────────────────────────── */
.dashboard__header {
  margin-bottom: var(--space-xl);
}

.dashboard__title {
  font-size: 24px;
  font-weight: 700;
}

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

/* ── Action Cards ───────────────────────────────── */
.actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.action-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.action-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--blue));
  opacity: 0;
  transition: opacity 0.25s ease;
}

.action-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.action-card:hover::before {
  opacity: 1;
}

.action-card__icon {
  font-size: 32px;
  margin-bottom: var(--space-sm);
}

.action-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.action-card p {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Panel ──────────────────────────────────────── */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-xl);
  animation: slideIn 0.3s ease;
}

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

.panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.panel__header h3 {
  font-size: 16px;
  font-weight: 600;
}

.panel__body {
  padding: var(--space-lg);
}

/* ── Form Elements ──────────────────────────────── */
.form-group {
  margin-bottom: var(--space-md);
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.form-group small {
  font-size: 12px;
  color: var(--text-muted);
}

.input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  transition: border-color var(--transition);
}

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

.input--small {
  width: 120px;
}

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

.input--code {
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.5;
}

.radio-group {
  display: flex;
  gap: var(--space-lg);
  margin-top: var(--space-xs);
}

.radio {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
}

.radio input[type="radio"] {
  accent-color: var(--accent);
}

/* ── Buttons ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: white;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--accent-glow);
}

.btn--primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn--accent {
  background: linear-gradient(135deg, #00b894, #00d68f);
  color: white;
  box-shadow: 0 4px 12px rgba(0, 214, 143, 0.25);
}

.btn--accent:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 214, 143, 0.3);
}

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

.btn--ghost:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.btn--icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-glow);
  color: var(--accent-light);
  border-radius: var(--radius-sm);
  font-size: 18px;
  font-weight: 700;
  border: 1px solid rgba(108, 92, 231, 0.3);
}

.btn--icon:hover {
  background: var(--accent);
  color: white;
}

/* ── Progress ───────────────────────────────────── */
.progress-section {
  margin-bottom: var(--space-xl);
}

.progress-bar {
  height: 8px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: var(--space-sm);
}

.progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-text {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ── Results ────────────────────────────────────── */
.results {
  animation: slideIn 0.3s ease;
}

.results__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.results__header h3 {
  font-size: 18px;
  font-weight: 700;
}

.results__stats {
  display: flex;
  gap: var(--space-md);
}

.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

.stat-badge--indexed { background: var(--green-bg); color: var(--green); }
.stat-badge--not-indexed { background: var(--red-bg); color: var(--red); }
.stat-badge--unknown { background: var(--yellow-bg); color: var(--yellow); }

.results__filters {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.filter-btn {
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
}

.filter-btn:hover {
  border-color: var(--border-light);
  color: var(--text-primary);
}

.filter-btn.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent-light);
}

.results__table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}

.results__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.results__table th {
  background: var(--bg-card);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}

.results__table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.results__table tr:last-child td {
  border-bottom: none;
}

.results__table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.results__table .url-cell {
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--blue);
}

.status-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.status-tag--indexed { background: var(--green-bg); color: var(--green); }
.status-tag--not-indexed { background: var(--red-bg); color: var(--red); }
.status-tag--unknown { background: var(--yellow-bg); color: var(--yellow); }

.results__actions {
  margin-top: var(--space-md);
}

/* ── Modal ──────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 480px;
  max-width: 90vw;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal__header h3 {
  font-size: 18px;
  font-weight: 700;
}

.modal__body {
  padding: var(--space-lg);
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border);
}

/* ── Toast ──────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  font-size: 14px;
  z-index: 300;
  animation: toastIn 0.3s ease;
  max-width: 400px;
}

.toast--success { border-color: var(--green); color: var(--green); }
.toast--error { border-color: var(--red); color: var(--red); }

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

/* ── Header User ────────────────────────────────── */
.header__user {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

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

/* ── Button variants ────────────────────────────── */
.btn--secondary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn--secondary:hover {
  border-color: var(--border-light);
  background: var(--bg-card-hover);
}

.btn--secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--danger {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(255, 107, 107, 0.3);
}

.btn--danger:hover {
  background: var(--red);
  color: white;
}

.btn--small {
  padding: 5px 12px;
  font-size: 12px;
}

.btn--full {
  width: 100%;
  justify-content: center;
}

/* ── Results export / actions ───────────────────── */
.results__actions-row {
  margin-bottom: var(--space-md);
}

.results__export {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.results__export h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: var(--space-sm);
  color: var(--text-secondary);
}

.results__export .input {
  margin-bottom: var(--space-sm);
}

/* ── Sheets import count ────────────────────────── */
.sheets-import-count {
  font-size: 13px;
  color: var(--green);
  margin-top: var(--space-sm);
}

/* ── Admin modal ────────────────────────────────── */
.modal--wide {
  width: 760px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.modal--wide .modal__body {
  overflow-y: auto;
  flex: 1;
}

.admin-section {
  margin-bottom: var(--space-xl);
}

.admin-section:last-child {
  margin-bottom: 0;
}

.admin-section h4 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: var(--space-md);
  color: var(--text-primary);
}

.admin-section__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.admin-section__header h4 {
  margin-bottom: 0;
}

.invite-code-result {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--green-bg);
  border: 1px solid rgba(0, 214, 143, 0.3);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-md);
  font-size: 14px;
  color: var(--green);
}

.invite-code-result code {
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.admin-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  max-height: 300px;
  overflow-y: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th {
  background: var(--bg-card);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}

.admin-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.admin-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.role-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.role-tag--admin {
  background: var(--accent-glow);
  color: var(--accent-light);
}

.role-tag--user {
  background: var(--bg-input);
  color: var(--text-secondary);
}

/* ── Error log panel ────────────────────────────── */
.log-wrap {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  font-size: 12px;
  font-family: 'Cascadia Code', 'Fira Code', monospace;
}

.log-empty {
  padding: var(--space-md);
  color: var(--text-muted);
  text-align: center;
  font-family: var(--font);
}

.log-entry {
  display: grid;
  grid-template-columns: 140px 160px 140px 1fr;
  gap: 8px;
  align-items: baseline;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  line-height: 1.4;
}

.log-entry:last-child { border-bottom: none; }
.log-entry--error { border-left: 3px solid var(--red); }

.log-ts    { color: var(--text-muted); white-space: nowrap; }
.log-route { color: var(--blue); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-user  { color: var(--yellow); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-msg   { color: var(--red); word-break: break-word; }
.log-stack { grid-column: 1 / -1; color: var(--text-muted); font-size: 11px; padding-left: 4px; }

/* ── Auth page (login.html) ─────────────────────── */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-dark);
  background-image: radial-gradient(ellipse at 50% 0%, rgba(108, 92, 231, 0.12) 0%, transparent 60%);
}

.auth-container {
  width: 100%;
  max-width: 420px;
  padding: var(--space-lg);
}

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
}

.auth-logo__icon {
  font-size: 32px;
}

.auth-logo__title {
  font-size: 24px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-light), var(--blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-tabs {
  display: flex;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: var(--space-lg);
}

.auth-tab {
  flex: 1;
  padding: 8px;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.auth-tab.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.auth-error {
  padding: 10px 14px;
  background: var(--red-bg);
  border: 1px solid rgba(255, 107, 107, 0.3);
  border-radius: var(--radius-sm);
  color: var(--red);
  font-size: 13px;
}

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    width: 200px;
    min-width: 200px;
  }

  .actions {
    grid-template-columns: 1fr;
  }

  .header__quota {
    display: none;
  }

  .modal--wide {
    width: 95vw;
  }
}
