/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --green:   #27ae60;
  --yellow:  #f39c12;
  --orange:  #e67e22;
  --red:     #e74c3c;
  --blue:    #2980b9;
  --gray:    #bdc3c7;
  --dark:    #2c3e50;
  --light:   #f4f6f9;
  --white:   #ffffff;
  --border:  #e0e6ed;
  --text:    #34495e;
  --muted:   #7f8c8d;
}

/* ── Logo heartbeat ─────────────────────────────────────────────────────────── */
@keyframes logo-beat {
  0%   { transform: scale(1); }
  14%  { transform: scale(1.2); }
  28%  { transform: scale(1); }
  42%  { transform: scale(1.12); }
  56%  { transform: scale(1); }
  100% { transform: scale(1); }
}
.logo-beat {
  display: inline-block;
  animation: logo-beat 1.6s ease-in-out infinite;
  transform-origin: center;
  line-height: 0;
  vertical-align: middle;
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::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(--light); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Public Layout ──────────────────────────────────────────────────────────── */
.pub-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
}
.pub-header .container { display: flex; align-items: center; justify-content: space-between; }
.pub-header h1 { font-size: 22px; font-weight: 700; color: var(--dark); }
.pub-header .admin-link { font-size: 12px; color: var(--muted); }

.container { max-width: 860px; margin: 0 auto; padding: 0 20px; }

/* ── Overall Status Banner ──────────────────────────────────────────────────── */
.overall-status {
  border-radius: 8px;
  padding: 18px 24px;
  margin: 28px 0 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 600;
}
.overall-status.operational { background: #eafaf1; color: #1e8449; border: 1px solid #a9dfbf; }
.overall-status.minor       { background: #fef9e7; color: #b7770d; border: 1px solid #f9e79f; }
.overall-status.major       { background: #fef5e7; color: #ca6f1e; border: 1px solid #fad7a0; }
.overall-status.critical    { background: #fdedec; color: #922b21; border: 1px solid #f5b7b1; }
.overall-status .dot {
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
}
.overall-status.operational .dot { background: var(--green); }
.overall-status.minor .dot       { background: var(--yellow); }
.overall-status.major .dot       { background: var(--orange); }
.overall-status.critical .dot    { background: var(--red); }

/* ── Application Status Card ────────────────────────────────────────────────── */
.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.app-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 10px;
}
.app-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.app-card-header .app-name { font-weight: 600; font-size: 15px; color: var(--dark); }
.app-description { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Status badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-operational { background: #eafaf1; color: #1e8449; }
.badge-minor       { background: #fef9e7; color: #b7770d; }
.badge-major       { background: #fef5e7; color: #ca6f1e; }
.badge-critical    { background: #fdedec; color: #922b21; }
.badge-resolved    { background: #eaf2fb; color: #1a5276; }
.badge-investigating { background: #fdedec; color: #922b21; }
.badge-identified    { background: #fef9e7; color: #b7770d; }
.badge-monitoring    { background: #eafaf1; color: #1e8449; }

/* ── 90-Day History Bars ────────────────────────────────────────────────────── */
.history-bar {
  display: flex;
  gap: 2px;
  align-items: center;
}
.history-bar .bar-wrap {
  position: relative;
  flex: 1;
  height: 28px;
}
.history-bar .bar-wrap .bar {
  width: 100%;
  height: 100%;
  border-radius: 2px;
  cursor: default;
}
.history-bar .bar-wrap .tooltip {
  display: none;
  position: absolute;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(44,62,80,0.92);
  color: #fff;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 10;
  pointer-events: none;
}
.history-bar .bar-wrap:hover .tooltip { display: block; }

.bar.operational { background: var(--green); }
.bar.minor       { background: var(--yellow); }
.bar.major       { background: var(--orange); }
.bar.critical    { background: var(--red); }
.bar.no-data     { background: var(--gray); }

.history-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}
.uptime-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

/* ── Incidents ──────────────────────────────────────────────────────────────── */
.incidents-section { margin-top: 36px; }
.incident-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 12px;
}
.incident-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.incident-id { font-size: 12px; color: var(--muted); font-weight: 600; }
.incident-title { font-size: 15px; font-weight: 700; color: var(--dark); }
.incident-apps {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}
.incident-apps span {
  background: #edf2f7;
  padding: 2px 8px;
  border-radius: 12px;
  margin-right: 4px;
}
.incident-updates { border-left: 3px solid var(--border); padding-left: 16px; }
.incident-update { margin-bottom: 12px; position: relative; }
.incident-update::before {
  content: '';
  position: absolute;
  left: -19px;
  top: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}
.update-time { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.update-status { font-size: 12px; font-weight: 700; text-transform: capitalize; margin-bottom: 2px; }
.update-status.investigating { color: var(--red); }
.update-status.identified    { color: var(--orange); }
.update-status.monitoring    { color: var(--yellow); }
.update-status.resolved      { color: var(--green); }
.update-message { font-size: 13px; line-height: 1.5; }

/* ── Footer ─────────────────────────────────────────────────────────────────── */
.pub-footer {
  text-align: center;
  padding: 32px 0 24px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 48px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   ADMIN
═══════════════════════════════════════════════════════════════════════════════ */
.admin-body { background: #f0f2f5; }

.admin-nav {
  background: var(--dark);
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 24px;
}
.admin-nav .brand { color: #fff; font-weight: 700; font-size: 16px; margin-right: auto; }
.admin-nav a { color: rgba(255,255,255,0.75); font-size: 14px; transition: color 0.15s; }
.admin-nav a:hover, .admin-nav a.active { color: #fff; text-decoration: none; }

.admin-content { max-width: 1000px; margin: 32px auto; padding: 0 24px; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h2 { font-size: 22px; font-weight: 700; color: var(--dark); }

/* Cards */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 20px;
}
.card-title { font-size: 14px; font-weight: 700; color: var(--dark); margin-bottom: 16px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--dark); margin-bottom: 6px; }
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  color: var(--dark);
  background: var(--white);
  transition: border-color 0.15s;
}
.form-control:focus { outline: none; border-color: var(--blue); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

.checkbox-group { display: flex; flex-wrap: wrap; gap: 10px; }
.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: normal;
  cursor: pointer;
  background: #f4f6f9;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.checkbox-group label:hover { border-color: var(--blue); }
.checkbox-group input[type=checkbox] { cursor: pointer; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; text-decoration: none; }
.btn-primary  { background: var(--blue); color: #fff; }
.btn-success  { background: var(--green); color: #fff; }
.btn-danger   { background: var(--red); color: #fff; }
.btn-secondary { background: #ecf0f1; color: var(--dark); }
.btn-sm { padding: 5px 11px; font-size: 13px; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.table th { font-weight: 700; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; background: #f8f9fa; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f8f9fa; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 13px; }
.alert-success { background: #eafaf1; color: #1e8449; border: 1px solid #a9dfbf; }
.alert-error   { background: #fdedec; color: #922b21; border: 1px solid #f5b7b1; }

/* Timeline in admin */
.timeline { border-left: 3px solid var(--border); padding-left: 20px; margin-top: 8px; }
.timeline-item { margin-bottom: 16px; position: relative; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: -24px;
  top: 6px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--blue);
}
.timeline-item .t-time { font-size: 11px; color: var(--muted); }
.timeline-item .t-author { font-size: 11px; color: var(--muted); }
.timeline-item .t-status { font-size: 13px; font-weight: 700; text-transform: capitalize; }
.timeline-item .t-msg { font-size: 13px; line-height: 1.5; margin-top: 2px; }

/* Stats row */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--white); border: 1px solid var(--border); border-radius: 8px; padding: 20px; text-align: center; }
.stat-card .stat-value { font-size: 32px; font-weight: 800; color: var(--dark); }
.stat-card .stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Login page */
.login-wrap { max-width: 380px; margin: 80px auto; }
.login-wrap .card { padding: 36px; }
.login-wrap h2 { font-size: 22px; font-weight: 700; color: var(--dark); margin-bottom: 6px; }
.login-wrap .subtitle { font-size: 13px; color: var(--muted); margin-bottom: 24px; }

/* Severity colors in admin */
.sev-minor    { color: var(--yellow); font-weight: 700; }
.sev-major    { color: var(--orange); font-weight: 700; }
.sev-critical { color: var(--red);    font-weight: 700; }

/* Pagination */
.pagination { display: flex; gap: 6px; margin-top: 16px; justify-content: center; }
.pagination a, .pagination span {
  padding: 6px 12px; border-radius: 4px; border: 1px solid var(--border);
  font-size: 13px; color: var(--dark);
}
.pagination a:hover { background: #f4f6f9; text-decoration: none; }
.pagination .current { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ── Dark Mode ───────────────────────────────────────────────────────────────── */
body.dark {
  --light:   #0f1117;
  --white:   #1a1d27;
  --border:  #2e3347;
  --text:    #c9d1d9;
  --muted:   #6e7681;
  --dark:    #e6edf3;
  background: #0f1117;
}
body.dark .pub-header   { background: #1a1d27; border-color: #2e3347; }
body.dark .pub-header h1 { color: #e6edf3; }
body.dark .app-card     { background: #1a1d27; border-color: #2e3347; }
body.dark .app-card-header .app-name { color: #e6edf3; }
body.dark .incident-card { background: #1a1d27; border-color: #2e3347; }
body.dark .incident-title { color: #e6edf3; }
body.dark .overall-status.operational { background: #0d2818; border-color: #1a5e38; }
body.dark .overall-status.minor       { background: #2b2000; border-color: #6b4e00; }
body.dark .overall-status.major       { background: #2b1800; border-color: #6b3800; }
body.dark .overall-status.critical    { background: #2b0a0a; border-color: #6b1a1a; }
body.dark .incident-apps span         { background: #2e3347; color: #c9d1d9; }
body.dark .pub-footer   { border-color: #2e3347; }
body.dark .btn-secondary { background: #2e3347; color: #c9d1d9; }
body.dark a.app-name-link { color: #e6edf3 !important; }
