/* ITG Agent Mobile — Base Stylesheet
   Mobile-first, touch-friendly, dark-by-default.
   No framework dependency. */

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

:root {
  --bg:           #0f172a;
  --surface:      #1e293b;
  --surface-2:    #334155;
  --border:       #475569;
  --text:         #f1f5f9;
  --text-muted:   #94a3b8;
  --accent:       #3b82f6;
  --accent-hover: #2563eb;
  --success:      #22c55e;
  --warn:         #f59e0b;
  --error:        #ef4444;
  --radius:       0.75rem;
  --gap:          1rem;
  --font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --min-tap:      44px;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
}

/* ── Layout ─────────────────────────────────────────────── */
.page {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--gap);
}

/* ── Header ─────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-bottom: var(--gap);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--gap);
}

.page-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

.page-subtitle {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  min-height: var(--min-tap);
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover,
.btn-primary:focus-visible {
  background: var(--accent-hover);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
}
.btn-ghost:hover { background: var(--border); }

/* ── File-pick zone ─────────────────────────────────────── */
.file-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.file-zone:hover,
.file-zone.drag-over {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.06);
}
.file-zone input[type="file"] {
  display: none;
}
.file-zone-label {
  color: var(--text-muted);
  font-size: 0.9375rem;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap);
  margin-bottom: 0.75rem;
}

.card-name {
  font-size: 1.0625rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.card-field {
  display: flex;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  align-items: flex-start;
}

.card-field-key {
  min-width: 4.5rem;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}

.card-field-value {
  color: var(--text);
  word-break: break-word;
}

.badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-active  { background: rgba(34,197,94,0.15);  color: var(--success); }
.badge-inactive { background: rgba(239,68,68,0.15); color: var(--error); }
.badge-default { background: var(--surface-2);      color: var(--text-muted); }

/* ── Meta strip ─────────────────────────────────────────── */
.meta-strip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.625rem var(--gap);
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: var(--gap);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.meta-strip span b {
  color: var(--text);
}

/* ── Messages ────────────────────────────────────────────── */
.msg-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid var(--error);
  color: var(--error);
  border-radius: var(--radius);
  padding: var(--gap);
  font-size: 0.9375rem;
}

.msg-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
  font-size: 0.9375rem;
}

/* ── Search bar ─────────────────────────────────────────── */
.search-bar {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  padding: 0.625rem 0.875rem;
  margin-bottom: var(--gap);
  min-height: var(--min-tap);
  outline: none;
  transition: border-color 0.15s;
}
.search-bar:focus {
  border-color: var(--accent);
}

/* ── Utilities ───────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.hidden { display: none !important; }

/* ── Info rows (system-status / updater-status views) ─── */
.info-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.375rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  flex-wrap: wrap;
}
.info-row:last-child { border-bottom: none; }
.info-row .label {
  color: var(--text-muted);
  min-width: 5.5rem;
  flex-shrink: 0;
}
.info-row .value {
  color: var(--text);
  word-break: break-word;
}
.info-row code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8125rem;
  background: var(--surface-2);
  border-radius: 0.25rem;
  padding: 0 0.25rem;
  word-break: break-all;
}

/* ── Status badges ───────────────────────────────────────── */
.badge-ok   { background: rgba(34,197,94,0.15);  color: var(--success); border-color: rgba(34,197,94,0.3); }
.badge-warn { background: rgba(245,158,11,0.15); color: var(--warn);    border-color: rgba(245,158,11,0.3); }
.badge-err  { background: rgba(239,68,68,0.15);  color: var(--error);   border-color: rgba(239,68,68,0.3); }

/* ── Card title ──────────────────────────────────────────── */
.card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.625rem;
  letter-spacing: 0.01em;
}

/* ── Nav list (index.html) ───────────────────────────────── */
.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  min-height: var(--min-tap);
  transition: background 0.15s, border-color 0.15s;
}
.nav-link:hover,
.nav-link:focus-visible {
  background: var(--surface-2);
  border-color: var(--accent);
  outline: none;
}
.nav-icon {
  font-size: 1.5rem;
  line-height: 1;
  flex-shrink: 0;
}
.nav-label {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

/* ── Error message ───────────────────────────────────────── */
.msg-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius);
  color: var(--error);
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  margin-bottom: var(--gap);
}

/* ── Mode tabs ───────────────────────────────────────────── */
.mode-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: var(--gap);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.25rem;
}
.tab-btn {
  background: none;
  border: none;
  border-radius: var(--radius) var(--radius) 0 0;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  transition: color 0.15s, background 0.15s;
}
.tab-btn:hover { background: var(--surface-2); color: var(--text); }
.tab-btn.tab-active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  margin-bottom: -1px;
}

/* ── Cloud settings ──────────────────────────────────────── */
.cloud-settings {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--gap);
}
.cloud-settings-summary {
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.625rem 0.875rem;
  user-select: none;
}
.cloud-settings-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0 0.875rem 0.875rem;
}
.field-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: -0.25rem;
}
.field-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  min-height: var(--min-tap);
  padding: 0.5rem 0.75rem;
  width: 100%;
  box-sizing: border-box;
}
.field-input:focus { border-color: var(--accent); outline: none; }

/* ── Cloud status ────────────────────────────────────────── */
.cloud-status {
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: var(--gap);
  padding: 0.5rem 0.75rem;
}
.cloud-status-loading { background: var(--surface-2); color: var(--text-muted); }
.cloud-status-ok      { background: rgba(34,197,94,0.1); color: var(--success); }
.cloud-status-error   { background: rgba(239,68,68,0.1); color: var(--error); }
.cloud-status-warn    { background: rgba(245,158,11,0.12); color: var(--warn); }
.cloud-status-info    { background: var(--surface-2); color: var(--text-muted); }

/* ── Debug toggle button (header top-right) ─────────────────────────────── */
.debug-toggle {
  flex-shrink: 0;
  padding: 0.3rem 0.55rem;
  border-radius: 0.4rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  line-height: 1;
  align-self: flex-start;
}
.debug-toggle-on {
  background: rgba(234, 179, 8, 0.12);
  border-color: #d97706;
  color: #d97706;
}

/* ── Debug panel (only visible when debug mode is active) ───────────────── */
.dbg-toggle-btn {
  position: fixed;
  bottom: 1.25rem;
  right: 1rem;
  z-index: 9999;
  padding: 0.35rem 0.75rem;
  background: #1f2937;
  color: #f9fafb;
  border: none;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.dbg-panel {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(10, 10, 10, 0.95);
  padding: 1rem;
  overflow-y: auto;
}
.dbg-toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.dbg-btn {
  padding: 0.35rem 0.7rem;
  background: #374151;
  color: #f9fafb;
  border: none;
  border-radius: 0.4rem;
  font-size: 0.75rem;
  cursor: pointer;
}
.dbg-btn-danger { background: #dc2626; }
.dbg-log-pre {
  font-size: 0.7rem;
  line-height: 1.5;
  color: #d1fae5;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
  font-family: monospace;
}
