/* ============================================
   Server Status – Riddl.ai theme
   Dark background, purple accents, clean typography
   ============================================ */

:root {
  --bg-deep: #0a0112;
  --bg-card: #12061c;
  --bg-elevated: #160a22;
  --accent: #832AB3;
  --accent-bright: #a855f7;
  --accent-glow: rgba(131, 42, 179, 0.4);
  --accent-subtle: rgba(131, 42, 179, 0.15);
  --text: #ffffff;
  --text-muted: #a78bfa;
  --text-secondary: #94a3b8;
  --border: rgba(167, 139, 250, 0.2);
  --success: #22c55e;
  --warning: #eab308;
  --critical: #ef4444;
  --radius: 12px;
  --radius-pill: 9999px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --transition: 0.2s ease;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg-deep);
  min-height: 100vh;
  overflow-x: hidden;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ----- Animated glow background ----- */
.glow-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.glow-bg::before,
.glow-bg::after {
  content: '';
  position: absolute;
  width: 120%;
  height: 80%;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.35;
  animation: glowPulse 8s ease-in-out infinite;
}

.glow-bg::before {
  top: -20%;
  left: -10%;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  animation-delay: 0s;
}

.glow-bg::after {
  bottom: -20%;
  right: -10%;
  background: radial-gradient(circle, var(--accent-bright) 0%, transparent 70%);
  animation-delay: -4s;
}

@keyframes glowPulse {
  0%, 100% { opacity: 0.25; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.05); }
}

/* ----- Layout ----- */
main {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

@media (min-width: 640px) {
  main {
    padding: 2rem 1.25rem 4rem;
  }
}

@media (min-width: 1024px) {
  main {
    padding: 2rem 1.5rem 4rem;
  }
}

/* ----- Header ----- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  background: rgba(10, 1, 18, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

@media (min-width: 640px) {
  .header {
    padding: 1rem 1.25rem;
  }
}

@media (min-width: 768px) {
  .header {
    padding: 1rem 1.5rem;
  }
}

.logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.logo img {
  height: 32px;
  width: auto;
  display: block;
}

@media (min-width: 640px) {
  .logo img {
    height: 36px;
  }
}

.nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Pill container for section links – fully rounded, light border */
.nav-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 4px;
  background: var(--bg-elevated);
  border: 1px solid rgba(167, 139, 250, 0.25);
  border-radius: var(--radius-pill);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
}

.nav-tab {
  padding: 0.5rem 1rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  border-radius: var(--radius-pill);
  transition: color var(--transition), background var(--transition), box-shadow var(--transition), border-color var(--transition);
  border: 1px solid transparent;
}

.nav-tab:hover {
  color: var(--text);
  background: rgba(167, 139, 250, 0.08);
}

.nav-tab.active {
  color: var(--text);
  background: rgba(167, 139, 250, 0.18);
  border-color: rgba(167, 139, 250, 0.35);
  box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.2);
}

.nav a:not(.nav-tab) {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9375rem;
  transition: color var(--transition);
}

.nav a:not(.nav-tab):hover {
  color: var(--text-muted);
}

.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px;
  min-width: 44px;
  min-height: 44px;
  color: var(--text);
  border-radius: var(--radius);
  transition: background var(--transition);
}

.menu-toggle:hover,
.menu-toggle:focus-visible {
  background: var(--accent-subtle);
}

.menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
}

@media (max-width: 767px) {
  .nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.5rem 1rem 1rem;
    background: var(--bg-deep);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  }

  .nav.is-open {
    display: flex;
  }

  .nav-tabs {
    flex-direction: column;
    padding: 4px;
    width: 100%;
  }

  .nav-tab {
    display: block;
    padding: 0.75rem 1rem;
    min-height: 44px;
    line-height: 1.4;
    text-align: center;
  }

  .nav a:not(.nav-tab) {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    min-height: 44px;
    line-height: 1.4;
  }

  .nav a:not(.nav-tab):hover {
    background: var(--accent-subtle);
  }

  .nav .btn {
    margin-top: 0.25rem;
    justify-content: center;
    min-height: 44px;
  }

  .menu-toggle {
    display: flex;
  }
}

/* ----- Buttons (Riddl style) ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  font-family: var(--font);
  font-size: 0.9375rem;
  font-weight: 500;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  border: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--text);
  box-shadow: 0 0 20px var(--accent-glow);
}

.btn-primary:hover {
  background: var(--accent-bright);
  box-shadow: 0 0 28px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--accent);
}

.btn-secondary:hover {
  background: var(--accent-subtle);
  border-color: var(--accent-bright);
}

/* ----- Hero ----- */
.hero {
  text-align: center;
  padding: 2rem 0.75rem 3rem;
}

@media (min-width: 640px) {
  .hero {
    padding: 2.5rem 1rem 3.5rem;
  }
}

@media (min-width: 1024px) {
  .hero {
    padding: 3rem 1rem 4rem;
  }
}

.badge {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
  margin-bottom: 1.25rem;
  animation: fadeInDown 0.6s ease;
}

.badge-success {
  background: rgba(34, 197, 94, 0.2);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.4);
}

.badge-warning {
  background: rgba(234, 179, 8, 0.2);
  color: var(--warning);
  border: 1px solid rgba(234, 179, 8, 0.4);
}

.badge-critical {
  background: rgba(239, 68, 68, 0.2);
  color: var(--critical);
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.hero-title {
  font-size: clamp(1.75rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 0.75rem;
  animation: fadeInUp 0.6s ease 0.1s both;
}

.hero-desc {
  font-size: clamp(0.9375rem, 2.5vw, 1.125rem);
  color: var(--text-secondary);
  max-width: 540px;
  margin: 0 auto;
  padding: 0 0.25rem;
  animation: fadeInUp 0.6s ease 0.2s both;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ----- Sections ----- */
.section {
  margin-bottom: 3rem;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.section-head h2 {
  font-size: clamp(1.25rem, 3vw, 1.5rem);
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
  flex: 1 1 100%;
}

@media (min-width: 640px) {
  .section-head h2 {
    flex: 1 1 auto;
  }
}

/* ----- Search (Riddl style) ----- */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 1rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  pointer-events: none;
}

.search-input {
  width: 100%;
  min-width: 0;
  padding: 0.625rem 1rem 0.625rem 2.25rem;
  font-family: var(--font);
  font-size: 16px; /* prevents zoom on focus in iOS */
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
}

@media (min-width: 640px) {
  .search-input {
    min-width: 200px;
    font-size: 0.9375rem;
  }
}

.search-input::placeholder {
  color: var(--text-secondary);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

/* ----- API / Services grid ----- */
.api-grid {
  display: grid;
  gap: 1rem;
}

.api-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color var(--transition), transform var(--transition);
  animation: cardIn 0.5s ease both;
}

@media (min-width: 640px) {
  .api-card {
    flex-wrap: nowrap;
    padding: 1.25rem 1.5rem;
  }
}

.api-card:hover {
  border-color: var(--accent-subtle);
}

.api-card.hidden {
  display: none;
}

.api-card-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0; /* allow shrinking so right side has room */
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 12px currentColor;
}

.status-dot.operational {
  background: var(--success);
  color: var(--success);
}

.status-dot.degraded {
  background: var(--warning);
  color: var(--warning);
}

.status-dot.down {
  background: var(--critical);
  color: var(--critical);
}

.api-name {
  font-weight: 600;
  font-size: 1rem;
}

.api-meta {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 0.15rem;
}

.uptime-bar-wrap {
  width: 100%;
  min-width: 0; /* allow flex item to shrink */
  max-width: 100%; /* never exceed card */
  overflow: hidden;
}

@media (min-width: 640px) {
  .api-card .uptime-bar-wrap {
    /* Wide enough for 90 segments + 1px gaps so bars stay visible */
    width: 240px;
    min-width: 240px;
    max-width: 240px;
  }
}

.uptime-bar {
  display: flex;
  gap: 1px;
  height: 20px;
  min-width: 0;
  width: 100%;
}

@media (min-width: 640px) {
  .uptime-bar {
    height: 24px;
  }
}

.uptime-bar span {
  flex: 1 1 0;
  min-width: 0; /* allow segments to shrink so bar fits container */
  border-radius: 2px;
  transition: opacity var(--transition);
}

.uptime-bar span.up {
  background: var(--success);
}

.uptime-bar span.down {
  background: var(--critical);
}

.uptime-bar span.degraded {
  background: var(--warning);
}

.uptime-pct {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 0.25rem;
  text-align: right;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ----- Period tabs ----- */
.period-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 4px;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  width: 100%;
}

@media (min-width: 640px) {
  .period-tabs {
    width: auto;
    flex-wrap: nowrap;
  }
}

.period-tab {
  flex: 1 1 calc(50% - 6px);
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
}

@media (min-width: 640px) {
  .period-tab {
    flex: 0 0 auto;
    min-height: 0;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }
}

.period-tab:hover {
  color: var(--text);
}

.period-tab.active {
  background: var(--accent);
  color: var(--text);
}

/* ----- Uptime cards ----- */
.uptime-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 480px) {
  .uptime-cards {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

@media (min-width: 768px) {
  .uptime-cards {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
}

.uptime-card {
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: cardIn 0.5s ease both;
}

@media (min-width: 640px) {
  .uptime-card {
    padding: 1.25rem;
  }
}

.uptime-card .api-name {
  margin-bottom: 0.5rem;
}

.uptime-card .uptime-bar-wrap {
  width: 100%;
  max-width: 100%;
  margin-top: 0.5rem;
}

.uptime-card .uptime-bar {
  height: 28px;
}

/* ----- Updates timeline ----- */
.updates-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.update-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem 1rem;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  transition: border-color var(--transition);
  animation: cardIn 0.5s ease both;
}

@media (min-width: 640px) {
  .update-item {
    padding: 1.25rem 1.5rem;
    gap: 1rem;
  }
}

.update-item:hover {
  border-color: var(--accent-subtle);
}

.update-item.hidden {
  display: none;
}

.update-item:first-child {
  margin-top: 0;
}

.update-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-top: 0.35rem;
  flex-shrink: 0;
}

.update-dot.resolved {
  background: var(--success);
}

.update-dot.investigating {
  background: var(--warning);
}

.update-dot.incident {
  background: var(--critical);
}

.update-dot.maintenance {
  background: var(--accent);
}

.update-content h3 {
  font-size: clamp(0.875rem, 2vw, 0.9375rem);
  font-weight: 600;
  margin: 0 0 0.25rem;
  line-height: 1.35;
}

.update-meta {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.update-body {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

/* ----- Logs ----- */
.log-filters {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  flex-wrap: wrap;
}

@media (min-width: 640px) {
  .log-filters {
    flex-direction: row;
  }
}

.select-input {
  width: 100%;
  min-height: 44px;
  padding: 0.625rem 2.25rem 0.625rem 1rem;
  font-family: var(--font);
  font-size: 16px;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='%2394a3b8'%3E%3Cpath d='M6 8L2 4h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
}

@media (min-width: 640px) {
  .select-input {
    width: auto;
    min-height: 0;
    padding: 0.6rem 2rem 0.6rem 1rem;
    font-size: 0.9375rem;
  }
}

.logs-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  box-shadow: var(--shadow);
  margin: 0 -0.25rem;
}

@media (min-width: 640px) {
  .logs-table-wrap {
    margin: 0;
  }
}

.logs-table {
  width: 100%;
  min-width: 420px;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

@media (min-width: 640px) {
  .logs-table {
    font-size: 0.875rem;
  }
}

.logs-table th,
.logs-table td {
  padding: 0.625rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

@media (min-width: 640px) {
  .logs-table th,
  .logs-table td {
    padding: 0.75rem 1rem;
  }
}

.logs-table th {
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-elevated);
}

.logs-table tbody tr {
  transition: background var(--transition);
}

.logs-table tbody tr:hover {
  background: var(--accent-subtle);
}

.logs-table tbody tr.hidden {
  display: none;
}

.logs-table .level {
  font-weight: 500;
  text-transform: capitalize;
}

.logs-table .level.info {
  color: var(--text-muted);
}

.logs-table .level.warning {
  color: var(--warning);
}

.logs-table .level.critical {
  color: var(--critical);
}

.empty-state,
.empty-cell {
  color: var(--text-secondary);
  text-align: center;
  padding: 2rem 1rem !important;
}

.empty-state {
  grid-column: 1 / -1;
}

/* ----- Responsive: prevent overflow on very small screens ----- */
@media (max-width: 380px) {
  .api-name,
  .api-meta {
    word-break: break-word;
  }

  .period-tab {
    flex: 1 1 100%;
  }
}

/* ----- Footer ----- */
.footer {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.25rem 1rem 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  text-align: center;
}

@media (min-width: 640px) {
  .footer {
    flex-direction: row;
    justify-content: space-between;
    padding: 1.5rem 1.5rem 2rem;
    font-size: 0.875rem;
    text-align: left;
  }
}

.footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer a:hover {
  color: var(--accent-bright);
}

.footer nav {
  display: flex;
  gap: 1.25rem;
}

.footer nav a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.25rem;
}

/* ----- Canvas for glow lines (used by JS) ----- */
.glow-lines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}
