/* ── kadosei portal shell — shared styles ── */

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

:root {
  --tiber: #013932;
  --tiber-dark: #012a25;
  --tiber-deeper: #011f1b;
  --spring-bud: #CDFC54;
  --mint: #78BE21;
  --mint-light: #f2faeb;
  --steel: #F0F3F7;
  --pearl: #CED9E5;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border: #e5e7eb;
  --border-mid: #d1d5db;
  --amber-light: #fffbeb;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --sidebar-width: 220px;
  /* Change this to --tiber-dark or --tiber-deeper to compare */
  --sidebar-bg: var(--tiber-deeper);
}

html {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

body {
  background: var(--steel);
  min-height: 100vh;
  display: flex;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow: hidden;
}

.nav-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  padding: 1.5rem 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 0.75rem;
}

.sidebar-logo svg {
  height: 22px;
  width: auto;
  display: block;
}

.nav-section { margin-bottom: 0.25rem; }

.nav-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: rgba(255,255,255,0.28);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.625rem 1.25rem 0.3rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0.5rem 1.25rem;
  font-size: 0.875rem;
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  position: relative;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.85);
}

.nav-item.active {
  background: rgba(255,255,255,0.09);
  color: #fff;
  font-weight: 500;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 5px;
  bottom: 5px;
  width: 3px;
  background: var(--spring-bud);
  border-radius: 0 2px 2px 0;
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.65;
}

.nav-item.active svg,
.nav-item:hover svg { opacity: 1; }

.nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.07);
  margin: 0.625rem 1.25rem;
}

/* Setup progress in sidebar */
.sidebar-progress {
  margin: 0 0.875rem 0;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.875rem;
}

.sidebar-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.sidebar-progress-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: rgba(255,255,255,0.55);
}

.sidebar-progress-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--spring-bud);
}

.sidebar-progress-track {
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 0.625rem;
}

.sidebar-progress-fill {
  height: 100%;
  background: var(--spring-bud);
  border-radius: 2px;
  transition: width 0.4s ease;
}

.sidebar-progress-steps {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-progress-step {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.4);
  text-decoration: none;
  padding: 2px 0;
}

.sidebar-progress-step.done {
  color: rgba(255,255,255,0.3);
  text-decoration: line-through;
  text-decoration-color: rgba(255,255,255,0.2);
}

.sidebar-progress-step.current {
  color: rgba(255,255,255,0.75);
  font-weight: 500;
}

.step-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-dot.done {
  background: var(--mint);
  border-color: var(--mint);
}

.step-dot.current {
  border-color: var(--spring-bud);
}

.step-dot svg {
  width: 8px;
  height: 8px;
  color: #fff;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.sidebar-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--spring-bud);
  color: var(--tiber);
  font-size: 0.6875rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.6875rem;
  color: rgba(255,255,255,0.35);
}

/* ── Main content ── */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  padding: 2rem 2rem 3rem;
}

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.page-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--tiber);
  letter-spacing: -0.01em;
}

.page-header p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Cards ── */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

/* ── Buttons ── */
.btn-primary {
  height: 38px;
  padding: 0 18px;
  background: var(--tiber);
  color: var(--spring-bud);
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
  white-space: nowrap;
}

.btn-primary:hover { background: var(--tiber-dark); }

.btn-secondary {
  height: 38px;
  padding: 0 16px;
  background: #fff;
  color: var(--text-secondary);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn-secondary:hover {
  background: var(--steel);
  color: var(--text-primary);
}

/* ── Form fields ── */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 1rem;
}

.field label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #374151;
}

.field input,
.field select {
  font-family: inherit;
  font-size: 0.875rem;
  height: 40px;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  padding: 0 12px;
  color: var(--text-primary);
  background: #fff;
  width: 100%;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--tiber);
  box-shadow: 0 0 0 3px rgba(1,57,50,0.08);
}

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

.field .hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.field .hint a { color: var(--tiber); text-decoration: underline; }

.select-wrap { position: relative; }
.select-wrap::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text-muted);
  pointer-events: none;
}
.select-wrap select { padding-right: 32px; }

/* ── Setup banner ── */
.setup-banner {
  background: var(--amber-light);
  border: 1px solid #fde68a;
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 1.5rem;
}

.setup-banner-icon {
  width: 34px;
  height: 34px;
  background: #fef3c7;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #92400e;
}

.setup-banner-icon svg { width: 17px; height: 17px; }

.setup-banner-content { flex: 1; min-width: 0; }

.setup-banner-content h3 {
  font-size: 0.9375rem;
  font-weight: 500;
  color: #92400e;
  margin-bottom: 2px;
}

.setup-banner-content p {
  font-size: 0.8125rem;
  color: #b45309;
  line-height: 1.5;
}

.setup-banner-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 0.625rem;
}

.setup-step-tag {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 500;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 20px;
  padding: 3px 10px;
  text-decoration: none;
  transition: background 0.1s;
}

.setup-step-tag:hover { background: #fde68a; }
.setup-step-tag svg { width: 11px; height: 11px; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
}

@media (max-width: 600px) {
  .main { padding: 1.25rem 1rem 2rem; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* Anchors progress + footer together at the bottom */
.sidebar-bottom {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  margin-top: auto;
}

.sidebar-bottom .sidebar-progress {
  margin: 0 0.875rem 0.75rem;
}

.sidebar-bottom .sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.07);
  padding: 1rem 1.25rem;
}

/* ── Analytics nav collapsible ── */
#analytics-sub a.nav-item {
  color: rgba(255,255,255,0.4);
}
#analytics-sub a.nav-item:hover {
  color: rgba(255,255,255,0.75);
  background: rgba(255,255,255,0.05);
}
#analytics-chevron.open {
  transform: rotate(180deg);
}

/* Analytics sub-menu always visible */
#analytics-sub {
  display: block !important;
}

/* ── Application picker ── */
.app-picker-wrap {
  flex-shrink: 0;
  padding: 0.75rem 0.875rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 0.5rem;
}

.app-picker {
  position: relative;
}

.app-picker-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
  text-align: left;
}

.app-picker-btn:hover {
  background: rgba(255,255,255,0.11);
}

.app-icon {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  background: var(--spring-bud);
  color: var(--tiber);
  font-size: 0.625rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.app-picker-label {
  flex: 1;
  min-width: 0;
}

.app-picker-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-picker-hint {
  font-size: 0.6875rem;
  color: rgba(255,255,255,0.35);
}

.app-picker-chevron {
  color: rgba(255,255,255,0.4);
  flex-shrink: 0;
  transition: transform 0.2s;
}

.app-picker-chevron svg {
  width: 14px;
  height: 14px;
  display: block;
}

.app-picker-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 200;
  overflow: hidden;
}

.app-picker-dropdown.open {
  display: block;
}

.app-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.625rem 0.875rem;
  cursor: pointer;
  transition: background 0.1s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.app-option:hover { background: var(--steel); }

.app-option.selected { background: var(--mint-light); }

.app-option-icon {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  font-size: 0.625rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.app-option-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
}

.app-option-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.app-option-check {
  margin-left: auto;
  color: var(--mint);
  flex-shrink: 0;
}

.app-option-check svg { width: 14px; height: 14px; display: block; }

.app-divider {
  height: 1px;
  background: var(--border);
  margin: 2px 0;
}

.app-new-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.625rem 0.875rem;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--tiber);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  transition: background 0.1s;
}

.app-new-btn:hover { background: var(--steel); }
.app-new-btn svg { width: 14px; height: 14px; }

/* ── Environment toggle ── */
.env-toggle-wrap {
  flex-shrink: 0;
  padding: 0 0.875rem 0.625rem;
}

.env-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 3px;
}

.env-btn {
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  border: none;
  border-radius: 5px;
  padding: 5px 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  background: transparent;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.01em;
}

.env-btn.active-live {
  background: #dcfce7;
  color: #166534;
}

.env-btn.active-test {
  background: #dbeafe;
  color: #1e40af;
}

.env-btn:not(.active-live):not(.active-test):hover {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.7);
}

/* ── Test mode banner ── */
.test-mode-banner {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-lg);
  padding: 0.75rem 1.125rem;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 1.5rem;
  font-size: 0.8125rem;
  color: #1e40af;
  font-weight: 500;
}

.test-mode-banner svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.test-mode-banner span {
  font-weight: 400;
  color: #3b82f6;
  margin-left: 4px;
}

/* Settings and analytics sub-menus always visible */
#settings-sub {
  display: block !important;
}

#analytics-sub a.nav-item,
#settings-sub a.nav-item {
  color: rgba(255,255,255,0.4);
}

#analytics-sub a.nav-item:hover,
#settings-sub a.nav-item:hover {
  color: rgba(255,255,255,0.75);
  background: rgba(255,255,255,0.05);
}

/* Suppress browser default tab focus indicator that shows as 'tab →' */
.tab:focus {
  outline: none;
}

.tab:focus-visible {
  outline: 2px solid var(--tiber);
  outline-offset: -2px;
  border-radius: 4px 4px 0 0;
}

.settings-tabs .tab:focus {
  outline: none;
}
