/* ============================================================
   Ops Portal — Shared Stylesheet
   IT Pro Partner Operations Portal
   ============================================================ */

:root {
  --bg-body: #0f172a;
  --bg-card: #1e293b;
  --bg-elevated: #1e293b;
  --bg-hover: #334155;
  --border-card: #334155;
  --accent: #f59e0b;
  --accent-hover: #d97706;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --green: #22c55e;
  --green-bg: rgba(34,197,94,0.12);
  --amber: #f59e0b;
  --amber-bg: rgba(245,158,11,0.12);
  --red: #ef4444;
  --red-bg: rgba(239,68,68,0.12);
  --gray: #64748b;
  --gray-bg: rgba(100,116,139,0.12);
  --teal: #14b8a6;
  --teal-bg: rgba(20,184,166,0.15);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-family);
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.5;
  padding: 12px;
  min-height: 100dvh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   Header
   ============================================================ */
.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 16px;
}
.header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
  line-height: 1.3;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.last-updated {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.refresh-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  color: var(--text-primary);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.refresh-btn:hover { background: #334155; border-color: var(--accent); }
.refresh-btn:active { transform: scale(0.97); }
.refresh-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.spinning svg { animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Error Banner
   ============================================================ */
.error-banner {
  background: var(--red-bg);
  border: 1px solid var(--red);
  color: #fca5a5;
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.9rem;
  font-weight: 500;
  display: none;
}
.error-banner.show { display: block; }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card-header {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-card);
}

/* ============================================================
   Grids
   ============================================================ */
.grid {
  display: grid;
  gap: 10px;
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.grid-auto-wide { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

/* ============================================================
   Health Bar
   ============================================================ */
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}
.health-item {
  text-align: center;
  padding: 12px 6px;
  border-radius: 8px;
  background: rgba(15,23,42,0.4);
}
.health-item .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.health-item .value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
}
.health-item .sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 2px;
}
.color-green { color: var(--green); }
.color-amber { color: var(--amber); }
.color-red { color: var(--red); }
.bg-green  { background: rgba(34,197,94,0.08); }
.bg-amber  { background: rgba(245,158,11,0.08); }
.bg-red    { background: rgba(239,68,68,0.08); }

/* ============================================================
   Status Dots
   ============================================================ */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-green  { background: var(--green); }
.dot-red    { background: var(--red); }
.dot-amber  { background: var(--amber); }
.dot-gray   { background: var(--gray); }

/* ============================================================
   Tables
   ============================================================ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
th {
  text-align: left;
  padding: 8px 10px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-card);
  white-space: nowrap;
}
td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(51,65,85,0.4);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-ok    { background: var(--green-bg); color: var(--green); }
.badge-error { background: var(--red-bg); color: var(--red); }
.badge-teal  { background: var(--teal-bg); color: var(--teal); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-gray  { background: var(--gray-bg); color: var(--text-muted); }
.badge-green { background: var(--green-bg); color: var(--green); }

/* ============================================================
   Service / API Grid Cards
   ============================================================ */
.service-grid, .api-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.service-card, .api-card {
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(15,23,42,0.3);
  border: 1px solid var(--border-card);
  display: flex;
  align-items: center;
  gap: 8px;
}
.service-card .name, .api-card .name {
  font-size: 0.82rem;
  font-weight: 500;
  word-break: break-all;
}
.service-card .version {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ============================================================
   S3 Rows
   ============================================================ */
.s3-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(51,65,85,0.3);
  gap: 4px 12px;
}
.s3-row:last-child { border-bottom: none; }
.s3-row .bucket-name { font-weight: 500; font-size: 0.85rem; min-width: 120px; }
.s3-row .bucket-meta { font-size: 0.78rem; color: var(--text-secondary); display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

/* ============================================================
   Placeholder & Empty State
   ============================================================ */
.placeholder {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--amber-bg);
  border: 1px solid rgba(245,158,11,0.3);
  border-radius: 8px;
  color: #fcd34d;
  font-size: 0.85rem;
}
.empty-state {
  text-align: center;
  padding: 20px 10px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ============================================================
   Versions Bar
   ============================================================ */
.versions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.versions-bar span { white-space: nowrap; }
.versions-bar .ver-val { color: var(--text-primary); font-weight: 500; }

/* ============================================================
   Content Area (for template pages)
   ============================================================ */
.content-area {
  max-width: 1400px;
  margin: 0 auto;
}

/* ============================================================
   Page Footer
   ============================================================ */
.page-footer {
  margin-top: 32px;
  padding: 16px 0;
  border-top: 1px solid var(--border-card);
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (min-width: 640px) {
  body { padding: 20px; }
  .header h1 { font-size: 1.5rem; }
  .health-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .service-grid, .api-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
@media (min-width: 1024px) {
  body { padding: 28px; }
  .health-grid { grid-template-columns: repeat(5, 1fr); }
}
