/* ============================================================
   XConsole - Global Styles
   ============================================================ */

:root {
  --primary: #1a1a2e;
  --primary-light: #16213e;
  --accent: #4f6ef7;
  --accent-hover: #3a57e8;
  --danger: #e53e3e;
  --danger-hover: #c53030;
  --success: #38a169;
  --sidebar-bg: #1a1a2e;
  --sidebar-text: #a0aec0;
  --sidebar-text-active: #fff;
  --sidebar-item-hover: rgba(255,255,255,0.07);
  --sidebar-item-active: rgba(79,110,247,0.18);
  --content-bg: #f7f8fc;
  --card-bg: #fff;
  --border: #e2e8f0;
  --text: #2d3748;
  --text-muted: #718096;
  --sidebar-width: 220px;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.14);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--content-bg);
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   App Shell Layout
   ============================================================ */

.app-shell {
  display: flex;
  height: 100vh;
}

/* ============================================================
   Sidebar
   ============================================================ */

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-title {
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  color: var(--sidebar-text);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
  background: var(--sidebar-item-hover);
  color: var(--sidebar-text-active);
}

.nav-item.active {
  background: var(--sidebar-item-active);
  color: var(--sidebar-text-active);
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-label { flex: 1; }

/* ============================================================
   Content Area
   ============================================================ */

.content-area {
  flex: 1;
  overflow-y: auto;
  background: var(--content-bg);
}

#module-content {
  min-height: 100%;
}

/* ============================================================
   Loading Spinner
   ============================================================ */

.loading-spinner {
  display: flex;
  justify-content: center;
  padding: 80px 0;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Module Header (shared)
   ============================================================ */

.module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.module-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.module-body {
  padding: 24px 28px;
}

/* ============================================================
   Cards
   ============================================================ */

.card-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s;
}

.card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1); }

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-info { min-width: 0; flex: 1; }

.card-app-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: #eef2ff;
  color: var(--accent);
  letter-spacing: 0.03em;
}

.badge-ios     { background: #dbeafe; color: #1d4ed8; }
.badge-android { background: #dcfce7; color: #15803d; }

.card-date {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 2px;
}

.card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.card-urls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-url-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--content-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  border-left-width: 3px;
}

.card-url-row:has(.url-label-terms)   { border-left-color: #a5b4fc; }
.card-url-row:has(.url-label-privacy) { border-left-color: #86efac; }

.url-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  width: 52px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.url-label-terms   { color: #4338ca; }
.url-label-privacy { color: #15803d; }

.url-text {
  flex: 1;
  font-size: 12px;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: "SF Mono", "Fira Code", monospace;
  text-decoration: none;
  cursor: pointer;
}

.url-text:hover { text-decoration: underline; }

.url-copy-btn {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.url-copy-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.url-copy-btn.copied {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

/* ============================================================
   Empty State
   ============================================================ */

.empty-state {
  text-align: center;
  padding: 80px 24px;
}

.empty-state-icon {
  width: 56px;
  height: 56px;
  color: var(--border);
  margin: 0 auto 16px;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
}

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

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

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

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

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

.btn-danger {
  background: var(--danger);
  color: #fff;
}

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

.btn-icon {
  padding: 6px 10px;
  background: var(--content-bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-icon:hover { background: var(--border); color: var(--text); }

.btn-icon svg {
  width: 15px;
  height: 15px;
}

/* ============================================================
   Form Panel (slide-in from right)
   ============================================================ */

.form-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.form-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.form-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 520px;
  max-width: 100vw;
  background: var(--card-bg);
  z-index: 101;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-lg);
}

.form-panel.open { transform: translateX(0); }

.form-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.form-panel-title {
  font-size: 16px;
  font-weight: 700;
}

.form-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.form-panel-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ============================================================
   Wizard Steps
   ============================================================ */

.wizard-steps {
  display: flex;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--content-bg);
  flex-shrink: 0;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.step-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
}

.wizard-step.active .step-dot {
  background: var(--accent);
  color: #fff;
}

.wizard-step.done .step-dot {
  background: var(--success);
  color: #fff;
}

.step-info { line-height: 1.3; }

.step-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  transition: color 0.2s;
}

.wizard-step.active .step-title { color: var(--text); }

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

.wizard-divider {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 12px;
  border-radius: 1px;
}

.wizard-content { }
.wizard-content.hidden { display: none; }
.hidden { display: none !important; }

/* ============================================================
   Form Elements
   ============================================================ */

.form-section {
  margin-bottom: 28px;
}

.form-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 4px;
}

.section-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 99px;
  letter-spacing: 0.03em;
  text-transform: none;
}

.section-badge.terms   { background: #e0e7ff; color: #4338ca; }
.section-badge.privacy { background: #dcfce7; color: #15803d; }

.form-group {
  margin-bottom: 16px;
}

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

.form-group label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,110,247,0.12);
}

.form-control.error { border-color: var(--danger); }

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.form-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-error {
  font-size: 11.5px;
  color: var(--danger);
  margin-top: 4px;
}

/* Checkboxes */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  transition: all 0.15s;
}

.checkbox-item input[type="checkbox"] { display: none; }

.checkbox-item.checked {
  background: #eef2ff;
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* Radio (platform) */
.radio-group {
  display: flex;
  gap: 8px;
}

.radio-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: all 0.15s;
}

.radio-item input[type="radio"] { display: none; }

.radio-item.checked {
  background: #eef2ff;
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* Toggle (boolean fields) */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.toggle-row:last-child { border-bottom: none; }

.toggle-label {
  font-size: 13px;
  color: var(--text);
}

.toggle-switch {
  position: relative;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
}

.toggle-switch input { display: none; }

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 99px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-track { background: var(--accent); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(16px); }

/* ============================================================
   Modal
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
}

.modal h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.modal p {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.6;
}

.modal-note {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12.5px !important;
  color: #92400e !important;
  margin-bottom: 20px !important;
}

.modal-note code {
  background: rgba(0,0,0,0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: monospace;
}

.settings-info {
  font-size: 13px !important;
  color: var(--text) !important;
  margin-bottom: 0 !important;
}

.settings-info code {
  background: var(--content-bg);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* ============================================================
   Toast
   ============================================================ */

#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 380px;
  animation: toast-in 0.25s ease;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.info    { border-left: 4px solid var(--accent); }

.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast-icon svg { width: 16px; height: 16px; }
.toast.success .toast-icon { color: var(--success); }
.toast.error   .toast-icon { color: var(--danger); }
.toast.info    .toast-icon { color: var(--accent); }

.toast-body { flex: 1; }
.toast-title { font-weight: 700; font-size: 13px; margin-bottom: 2px; }
.toast-msg   { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }

.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ============================================================
   Saving overlay (full-screen progress)
   ============================================================ */

.saving-progress {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 400;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 600;
}

.saving-progress.hidden { display: none; }
.saving-progress .spinner { border-color: rgba(255,255,255,0.3); border-top-color: #fff; width: 18px; height: 18px; border-width: 2px; }
.saving-progress-text { flex: 1; }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 640px) {
  :root { --sidebar-width: 56px; }

  .sidebar-title,
  .nav-label { display: none; }

  .sidebar-header { justify-content: center; padding: 16px 8px; }
  .sidebar-logo { margin: 0; }

  .nav-item { justify-content: center; padding: 10px; }

  .form-panel { width: 100vw; }

  .module-header { padding: 16px; }
  .module-body   { padding: 16px; }
}
