/*
  Agents Attestation Dashboard Styles
  - Responsive sidebar with mobile toggle
  - Two-tab layout (Agents, Settings)
  - Clean, accessible components
*/

:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #fafafa;
  --text: #111827;
  --muted: #6b7280;
  --primary: #4f8cff;
  --primary-600: #3f74d4;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #ef4444;
  --border: #e5e7eb;
  --badge-bg: #eef2ff;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: 100vh;
}

/* Sidebar */
.sidebar {
  background: linear-gradient(180deg, var(--panel), #f6f8fb);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 16px;
}

.sidebar__header { display: flex; align-items: center; gap: 12px; }

.sidebar__toggle {
  display: none;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand__logo { font-size: 20px; }
.brand__text { display: flex; flex-direction: column; }
.brand__title { font-weight: 700; letter-spacing: 0.3px; }
.brand__subtitle { color: var(--muted); font-size: 12px; }

.sidebar__nav { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }

.nav__item {
  background: transparent;
  color: var(--text);
  text-align: left;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}
.nav__item:hover { border-color: #274059; }
.nav__item.is-active {
  background: transparent;
  border-color: var(--primary);
}

.sidebar__footer { margin-top: auto; }
.status-pill {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--badge-bg);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

/* Content */
.content { padding: 24px; overflow: auto; }
.content__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.content__header h1 { margin: 0; font-size: 20px; }

.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 8px 16px;
  gap: 12px;
}
.card__title { margin: 0; font-size: 18px; }
.card__subtitle { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.card__actions { display: flex; gap: 8px; }

.table-wrapper { width: 100%; overflow: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 16px; border-top: 1px solid var(--border); }
.table thead th { position: sticky; top: 0; background: #f6f8fb; z-index: 1; text-align: left; font-weight: 600; color: var(--muted); }
.table tbody tr:hover { background: #f9fafb; }

.agent__identity { display: flex; flex-direction: column; gap: 4px; }
.agent__name { font-weight: 600; }
.agent__id { color: var(--muted); font-size: 12px; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--border);
}
.badge--ok { background: rgba(33, 192, 139, 0.15); color: var(--success); border-color: rgba(33, 192, 139, 0.4); }
.badge--fail { background: rgba(239, 71, 111, 0.15); color: var(--danger); border-color: rgba(239, 71, 111, 0.4); }
.badge--unknown { background: rgba(79, 140, 255, 0.15); color: var(--primary); border-color: rgba(79, 140, 255, 0.4); }

/* Buttons */
.btn { background: #f3f4f6; border: 1px solid #d1d5db; color: var(--text); padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.btn:hover { border-color: #9ca3af; }
.btn--primary { background: var(--primary); border-color: var(--primary-600); color: #0c1220; font-weight: 700; }
.btn--ghost { background: transparent; }
.btn--small { padding: 6px 10px; font-size: 12px; }
.btn--secondary { background: #e0e7ff; border-color: #a5b4fc; color: #3730a3; }
.btn--secondary:hover { border-color: #6366f1; background: #c7d2fe; }

/* Slider */
.slider { display: flex; align-items: center; gap: 12px; }
.cgroup-slider { width: 180px; }
.slider__value { color: var(--muted); font-size: 12px; width: 40px; }

/* Form */
.form { padding: 16px; }
.form__row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.form input, .form select {
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

/* Row actions */
.row-actions { display: flex; gap: 8px; }

/* Attestation State */
.attestation-state {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.attestation-state:not(:empty) {
  border: 1px solid var(--border);
}

/* Attestation Status Colors */
.attestation-state.status-running {
  background: #e3f2fd;
  color: #1976d2;
  border-color: #1976d2;
}

.attestation-state.status-stopped {
  background: #ffebee;
  color: #d32f2f;
  border-color: #d32f2f;
}

/* Tabs */
.tab.is-hidden { display: none; }

/* CPU Usage Meter */
.cpu-usage { display: flex; align-items: center; gap: 8px; }
.meter {
  width: 140px;
  height: 8px;
  background: #eef2f7;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.meter__bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--success) 0%, var(--warning) 55%, var(--danger) 100%);
  transition: width 200ms ease;
}
.cpu__value { color: var(--muted); font-size: 12px; width: 42px; text-align: right; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal.is-hidden { display: none; }

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.modal__content {
  position: relative;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}

.modal__title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.modal__close {
  background: transparent;
  border: none;
  font-size: 28px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 0 8px;
}
.modal__close:hover { color: var(--text); }

.modal__body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* Metrics Sections */
.metrics-section {
  margin-bottom: 24px;
}
.metrics-section:last-child { margin-bottom: 0; }

.metrics-section h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
}

.metrics-desc {
  margin: 0 0 12px 0;
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
}

.metrics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.metrics-table th,
.metrics-table td {
  padding: 10px 12px;
  border: 1px solid var(--border);
  text-align: left;
}

.metrics-table thead th {
  background: var(--panel-2);
  font-weight: 600;
  color: var(--muted);
}

.metrics-table tbody tr:hover {
  background: #f9fafb;
}

.metric-value {
  font-family: "SF Mono", Monaco, Consolas, monospace;
  font-weight: 500;
  color: var(--text);
}

/* Categorized metrics table */
.metrics-table--categorized {
  font-size: 13px;
}

.metrics-table--categorized th:nth-child(1),
.metrics-table--categorized td:nth-child(1) {
  width: 160px;
}

.metrics-table--categorized th:nth-child(4),
.metrics-table--categorized td.metric-value {
  width: 80px;
  text-align: right;
}

.metrics-table--categorized th:nth-child(5),
.metrics-table--categorized td:last-child {
  width: 60px;
}

.category-cell {
  background: var(--panel-2);
  font-weight: 600;
  color: var(--primary);
  vertical-align: top;
  border-right: 2px solid var(--primary);
}

/* Details Page */
.app--details .content {
  background: var(--bg);
}

.details-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.agent-summary {
  background: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 100%);
}

.agent-status {
  display: flex;
  align-items: center;
  gap: 12px;
}

.agent-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  padding: 16px;
  border-top: 1px solid var(--border);
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-value {
  font-family: "SF Mono", Monaco, Consolas, monospace;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  word-break: break-all;
}

/* Nav link style */
a.nav__item {
  text-decoration: none;
  color: var(--text);
}
a.nav__item:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* DLT Configuration Table */
.dlt-table {
  max-width: 600px;
}

.dlt-input {
  width: 120px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}

.dlt-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.15);
}

.dlt-result-row {
  background: var(--panel-2);
}

.dlt-result {
  font-family: "SF Mono", Monaco, Consolas, monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

.dlt-fixed-value {
  font-family: "SF Mono", Monaco, Consolas, monospace;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

.dlt-formula {
  padding: 16px;
  border-top: 1px solid var(--border);
  background: var(--panel-2);
}

.dlt-formula p {
  margin: 0 0 8px 0;
  font-size: 13px;
  color: var(--muted);
}

.dlt-formula p:last-child {
  margin-bottom: 0;
}

.formula-details {
  font-family: "SF Mono", Monaco, Consolas, monospace;
  font-size: 12px;
  color: var(--text);
  background: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* Responsive */
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; transform: translateX(-100%); transition: transform 220ms ease; z-index: 20; }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar__toggle { display: inline-block; }
  .content { padding-top: 64px; }
}
