/* ============================================================
   AMSB Admin — Stylesheet
   Palette: slate nav, white content, amber accent
   ============================================================ */

:root {
  --color-bg:          #f8f9fa;
  --color-surface:     #ffffff;
  --color-border:      #e2e8f0;
  --color-border-soft: #f1f5f9;

  --color-nav-bg:      #1e293b;
  --color-nav-text:    #94a3b8;
  --color-nav-active:  #f8fafc;
  --color-nav-hover:   #334155;

  --color-text:        #0f172a;
  --color-text-muted:  #64748b;

  --color-accent:      #d97706;
  --color-accent-soft: #fef3c7;

  --color-success:     #16a34a;
  --color-success-soft:#dcfce7;
  --color-error:       #dc2626;
  --color-error-soft:  #fee2e2;

  --color-folder:      #3b82f6;
  --color-leaf:        #0f172a;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;

  --radius:    6px;
  --radius-lg: 10px;
  --shadow:    0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }

/* Nav */
.nav {
  background: var(--color-nav-bg);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-right: 2rem;
  border-right: 1px solid rgba(255,255,255,0.08);
  margin-right: 1.5rem;
}

.nav-logo { font-size: 1.25rem; }
.nav-title { color: #f8fafc; font-weight: 600; font-size: 0.95rem; letter-spacing: -0.01em; }

.nav-links { display: flex; gap: 0.25rem; flex: 1; }

.nav-link {
  color: var(--color-nav-text);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--color-nav-hover); color: #f8fafc; }
.nav-link.active { color: #f8fafc; background: rgba(255,255,255,0.08); }

.nav-user { display: flex; align-items: center; gap: 0.75rem; margin-left: auto; }

.nav-user-meta { display: flex; flex-direction: column; gap: 0.15rem; }

.nav-user-badges { display: flex; gap: 0.35rem; }

.avatar { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,0.2); }
.avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.14);
  color: #f8fafc;
  font-size: 0.8rem;
  font-weight: 600;
}
.username { color: var(--color-nav-text); font-size: 0.875rem; }

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(255,255,255,0.14);
  color: #f8fafc;
}

.pill-muted {
  background: rgba(255,255,255,0.08);
  color: var(--color-nav-text);
}

/* Main */
.main { flex: 1; padding: 2rem 2.5rem; max-width: 1100px; width: 100%; margin: 0 auto; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s, opacity 0.15s;
  line-height: 1;
}
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-primary { background: var(--color-accent); color: #fff; }
.btn-primary:hover { opacity: 0.9; }
.btn-secondary { background: var(--color-border); color: var(--color-text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-block { justify-content: center; width: 100%; }
.btn-ghost { background: rgba(255,255,255,0.08); color: var(--color-nav-text); }
.btn-ghost:hover { background: rgba(255,255,255,0.14); color: #f8fafc; }
.btn-github {
  display: flex; align-items: center; justify-content: center; gap: 0.65rem;
  background: #24292f; color: #fff;
  padding: 0.75rem 1.5rem; border-radius: var(--radius);
  font-size: 0.95rem; font-weight: 500; width: 100%;
  margin: 1.5rem 0 1rem; transition: background 0.15s;
}
.btn-github:hover { background: #393f47; }
.github-icon { width: 20px; height: 20px; flex-shrink: 0; }

/* Alerts */
.alert {
  padding: 0.75rem 1rem; border-radius: var(--radius);
  font-size: 0.875rem; margin-bottom: 1.25rem; border-left: 3px solid;
}
.alert-success { background: var(--color-success-soft); border-color: var(--color-success); color: #14532d; }
.alert-error   { background: var(--color-error-soft);   border-color: var(--color-error);   color: #7f1d1d; }

/* Page header */
.page-header { margin-bottom: 1.75rem; }
.page-header-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.page-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.2; }
.page-subtitle { color: var(--color-text-muted); font-size: 0.875rem; margin-top: 0.25rem; }

.tab-strip {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.tab-link {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 0.875rem;
  font-weight: 600;
}

.tab-link.active {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
  color: #92400e;
}

/* Dashboard cards */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; margin-bottom: 2rem; }

.dash-card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); padding: 1.5rem;
  display: flex; flex-direction: column; gap: 0.75rem;
  transition: box-shadow 0.15s, border-color 0.15s; cursor: pointer;
}
.dash-card:hover { box-shadow: var(--shadow-md); border-color: var(--color-accent); }
.dash-card-icon { font-size: 2rem; }
.dash-card-title { font-size: 1.05rem; font-weight: 600; letter-spacing: -0.02em; }
.dash-card-desc { color: var(--color-text-muted); font-size: 0.875rem; line-height: 1.55; }
.dash-card-cta { color: var(--color-accent); font-size: 0.875rem; font-weight: 500; margin-top: auto; padding-top: 0.5rem; }

/* Info grid */
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.info-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 1.25rem 1.5rem; }
.info-card-title { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-muted); margin-bottom: 1rem; }
.info-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.info-table tr + tr td { border-top: 1px solid var(--color-border-soft); }
.info-table td { padding: 0.45rem 0; }
.info-label { color: var(--color-text-muted); width: 110px; }
.link { color: var(--color-accent); }
.link:hover { text-decoration: underline; }

/* Breadcrumb */
.breadcrumb { display: flex; align-items: center; gap: 0.25rem; font-size: 0.85rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.crumb-link { color: var(--color-accent); font-weight: 500; }
.crumb-link:hover { text-decoration: underline; }
.crumb-sep { color: var(--color-border); margin: 0 0.1rem; }
.crumb-current { color: var(--color-text-muted); font-family: var(--font-mono); font-size: 0.82rem; }

/* Parameter tree */
.param-tree { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; }
.param-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.65rem 1rem; border-bottom: 1px solid var(--color-border-soft); font-size: 0.875rem; transition: background 0.1s; }
.param-row:last-child { border-bottom: none; }
.param-row:hover { background: var(--color-bg); }
.param-icon { flex-shrink: 0; font-size: 1rem; }
.param-name { flex: 1; font-family: var(--font-mono); font-size: 0.84rem; }
.param-name--folder { color: var(--color-folder); font-weight: 500; }
.param-name--folder:hover { text-decoration: underline; }
.param-name--leaf { color: var(--color-leaf); }
.param-name--leaf:hover { color: var(--color-accent); }
.param-meta { display: flex; align-items: center; gap: 0.5rem; }
.badge { background: var(--color-accent-soft); color: #92400e; font-size: 0.72rem; font-weight: 600; padding: 0.1rem 0.4rem; border-radius: 3px; text-transform: uppercase; letter-spacing: 0.04em; }
.text-muted { color: var(--color-text-muted); }

/* Parameter detail */
.detail-meta { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 1rem 1.25rem; margin-bottom: 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; }
.meta-row { display: flex; align-items: center; gap: 1rem; font-size: 0.875rem; }
.meta-label { color: var(--color-text-muted); width: 120px; flex-shrink: 0; font-size: 0.82rem; }
.meta-value { font-family: var(--font-mono); font-size: 0.84rem; }

/* Edit form */
.edit-form { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 1.5rem; }
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-size: 0.82rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); margin-bottom: 0.5rem; }
.form-input, .form-select {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.7rem 0.75rem;
  font-size: 0.9rem;
  background: var(--color-bg);
  color: var(--color-text);
  outline: none;
  transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus { border-color: var(--color-accent); }
.form-textarea { width: 100%; border: 1px solid var(--color-border); border-radius: var(--radius); padding: 0.75rem; font-size: 0.82rem; line-height: 1.6; resize: vertical; background: var(--color-bg); color: var(--color-text); outline: none; transition: border-color 0.15s; }
.form-textarea:focus { border-color: var(--color-accent); }
.code-textarea { font-family: var(--font-mono); }
.form-hint { font-size: 0.8rem; color: var(--color-text-muted); margin-top: 0.4rem; }
.form-actions { display: flex; gap: 0.75rem; align-items: center; }
.stack-form { display: flex; flex-direction: column; gap: 0.9rem; }
.text-left { text-align: left; }

/* S3 table */
.table-wrapper { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 0.75rem; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th { background: var(--color-bg); padding: 0.65rem 1rem; text-align: left; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); border-bottom: 1px solid var(--color-border); }
.data-table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--color-border-soft); }
.data-table tfoot td { border-bottom: none; border-top: 2px solid var(--color-border); background: var(--color-bg); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--color-bg); }
.text-right { text-align: right; }
.bucket-name { display: flex; align-items: center; gap: 0.5rem; font-family: var(--font-mono); font-size: 0.84rem; }
.bucket-icon { flex-shrink: 0; }
.table-note { font-size: 0.8rem; color: var(--color-text-muted); }
.table-note code { font-family: var(--font-mono); background: var(--color-border-soft); padding: 0.1rem 0.3rem; border-radius: 3px; }

.log-table th,
.log-table td {
  vertical-align: top;
}

.log-time,
.log-mono {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.log-request {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  word-break: break-word;
}

.log-detail-row td {
  background: #fbfcfe;
  padding-top: 0;
}

.log-detail {
  padding: 0.75rem 0;
}

.log-detail summary {
  cursor: pointer;
  color: var(--color-accent);
  font-weight: 600;
}

.log-detail-grid {
  display: grid;
  gap: 0.6rem;
  margin: 0.75rem 0;
}

.log-raw {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--color-nav-bg);
  color: #e2e8f0;
  padding: 0.85rem;
  border-radius: var(--radius);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.status-2xx { background: var(--color-success-soft); color: #166534; }
.status-3xx { background: #dbeafe; color: #1d4ed8; }
.status-4xx { background: #fef3c7; color: #92400e; }
.status-5xx { background: var(--color-error-soft); color: #991b1b; }

/* Empty state */
.empty-state { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 3rem; text-align: center; color: var(--color-text-muted); display: flex; flex-direction: column; align-items: center; gap: 1rem; }

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 1.25rem;
  align-items: start;
}

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.panel-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.auth-callout {
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  gap: 0.5rem;
}

.auth-form { margin-top: 1.25rem; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  margin: 1rem 0;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--color-border);
}

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--color-nav-bg); }
.login-card { background: var(--color-surface); border-radius: var(--radius-lg); padding: 2.5rem 2rem; width: 100%; max-width: 420px; text-align: center; box-shadow: var(--shadow-md); }
.login-logo { font-size: 3rem; margin-bottom: 0.75rem; }
.login-title { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.03em; }
.login-subtitle { color: var(--color-text-muted); font-size: 0.875rem; margin-top: 0.25rem; }
.login-note { color: var(--color-text-muted); font-size: 0.78rem; line-height: 1.5; }

@media (max-width: 860px) {
  .split-layout { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .page-header-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav {
    height: auto;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
  }

  .nav-brand {
    margin-right: 0;
    padding-right: 0;
    border-right: none;
  }

  .nav-links {
    order: 3;
    width: 100%;
    flex-wrap: wrap;
  }

  .nav-user {
    width: 100%;
    justify-content: space-between;
  }

  .main {
    padding: 1.5rem 1rem;
  }

  .login-card {
    margin: 1rem;
    padding: 2rem 1.25rem;
  }
}
