/*
 * YouGile Command Center — UI Theme (Unslopped)
 * Crafted according to the principles of https://github.com/heydamir/unslop
 * - Graphite neutral ramp, quiet chrome, zero neon glows, zero hue gradients
 * - Strict 4px spacing rhythm, nested radii, tabular numbers, clean SVG iconography
 */

:root {
  /* Graphite neutral scale */
  --bg-base: #090a0d;
  --bg-surface: #12141a;
  --bg-surface-raised: #181a22;
  --bg-surface-hover: #1e212b;
  --bg-active: #262936;

  /* Quiet Hairlines */
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --border-focus: rgba(255, 255, 255, 0.28);

  /* Three text roles */
  --text-primary: #f4f5f7;
  --text-secondary: #9aa1b2;
  --text-muted: #656c7d;

  /* Single restrained accent */
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-subtle: rgba(59, 130, 246, 0.1);
  --accent-text: #60a5fa;

  /* Toned down semantics */
  --success: #10b981;
  --success-subtle: rgba(16, 185, 129, 0.1);
  --success-text: #34d399;

  --danger: #ef4444;
  --danger-subtle: rgba(239, 68, 68, 0.1);
  --danger-text: #f87171;

  --warning: #f59e0b;
  --warning-subtle: rgba(245, 158, 11, 0.1);

  /* Nested radius: outer 14px, card 10px, control 8px, tag 6px */
  --radius-outer: 14px;
  --radius-card: 10px;
  --radius-control: 8px;
  --radius-sm: 6px;

  /* Subtle neutral shadow for floating elements only */
  --shadow-overlay: 0 12px 32px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* App Shell */
.app-container {
  width: 100%;
  max-width: 680px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-outer);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  flex-shrink: 0;
}

.brand-icon svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.75;
}

.brand-text h1 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  color: var(--text-secondary);
}

.status-dot {
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.dot-success { background: var(--success); }
.status-dot.dot-danger { background: var(--danger); }
.status-dot.dot-warning { background: var(--warning); }
.status-dot.dot-muted { background: var(--text-muted); }

/* Navigation: Clean Segmented Control */
.nav-tabs {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 3px;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  flex: 1;
  min-width: fit-content;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-control);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color 120ms ease, background-color 120ms ease;
}

.tab-btn svg {
  width: 14px;
  height: 14px;
  stroke-width: 1.5;
  color: inherit;
  flex-shrink: 0;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface-raised);
}

.tab-btn.active {
  color: var(--text-primary);
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
}

/* Tab Contents */
.tab-content {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.tab-content.active {
  display: flex;
}

/* Section Header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 2px 2px;
}

.section-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.section-header .subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Cards */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Form Controls */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

input[type="text"],
input[type="tel"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  height: 36px;
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  padding: 0 12px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color 120ms ease;
}

textarea {
  height: auto;
  padding: 10px 12px;
  resize: vertical;
  min-height: 80px;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--border-focus);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-control);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease, opacity 120ms ease;
}

.btn svg {
  width: 14px;
  height: 14px;
  stroke-width: 1.75;
}

.btn-primary {
  background: var(--text-primary);
  color: #0b0c0e;
  border-color: transparent;
}

.btn-primary:hover {
  background: #e4e4e7;
}

.btn-primary:active {
  opacity: 0.9;
}

.btn-secondary {
  background: var(--bg-surface-raised);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

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

.btn-danger {
  background: var(--danger-subtle);
  color: var(--danger-text);
  border-color: rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.16);
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

/* Badges */
.badge,
.badge-role {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-raised);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.badge-owner,
.role-owner {
  background: rgba(59, 130, 246, 0.1);
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.2);
}

.badge-manager,
.role-manager {
  background: rgba(16, 185, 129, 0.1);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.2);
}

.badge-intern,
.role-intern {
  background: rgba(161, 161, 170, 0.1);
  color: #a1a1aa;
  border-color: rgba(161, 161, 170, 0.2);
}

.badge-success {
  background: var(--success-subtle);
  color: var(--success-text);
  border-color: rgba(16, 185, 129, 0.25);
}

.badge-warning {
  background: var(--warning-subtle);
  color: var(--warning-text);
  border-color: rgba(245, 158, 11, 0.25);
}

.badge-danger {
  background: var(--danger-subtle);
  color: var(--danger-text);
  border-color: rgba(239, 68, 68, 0.25);
}

.badge-muted {
  background: var(--bg-surface-raised);
  color: var(--text-muted);
  border-color: var(--border-subtle);
}

/* Lists */
.users-list,
.audit-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-card,
.user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  transition: background-color 120ms ease;
}

.user-card:hover,
.user-item:hover {
  background: var(--bg-surface-raised);
}

.user-main,
.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
}

.user-details h4 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.user-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.role-select {
  height: 28px;
  padding: 0 8px;
  font-size: 12px;
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  color: var(--text-primary);
  outline: none;
}

.role-select:focus {
  border-color: var(--border-focus);
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  transition: 150ms ease;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: var(--text-muted);
  border-radius: 50%;
  transition: 150ms ease;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--bg-surface-hover);
  border-color: var(--success);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(16px);
  background-color: var(--success);
}

/* Audit List Items */
.audit-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
}

.audit-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.audit-payload {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.4;
  word-break: break-word;
}

/* DaData Result Box */
.dadata-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dadata-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 12px;
}

.dadata-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.dadata-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dadata-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: none;
}

.dadata-value {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* Funnel Container */
.funnel-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.funnel-step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
}

.funnel-step-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.step-num {
  width: 24px;
  height: 24px;
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.step-info h4 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.step-badge {
  font-size: 11px;
  color: var(--text-muted);
}

/* Modals */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.modal-dialog {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 440px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-outer);
  box-shadow: var(--shadow-overlay);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.modal-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-surface-raised);
}

.modal-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-raised);
}

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

.loading-spinner {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 12px;
}

.tip-text {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.copy-box {
  display: flex;
  gap: 8px;
}

/* Mobile Adjustments */
@media (max-width: 480px) {
  .app-container {
    padding: 12px 10px;
    gap: 12px;
  }

  .nav-tabs {
    padding: 2px;
  }

  .tab-btn {
    padding: 6px 10px;
    font-size: 11px;
  }
}
