/* Homelab Mini Apps — unified theme */
:root {
  --bg: var(--tg-theme-bg-color, #1c1c1e);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #2c2c2e);
  --text: var(--tg-theme-text-color, #fff);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --link: var(--tg-theme-link-color, #0a84ff);
  --btn: var(--tg-theme-button-color, #0a84ff);
  --btn-text: var(--tg-theme-button-text-color, #fff);
  --destructive: var(--tg-theme-destructive-text-color, #ff453a);
  --accent: var(--tg-theme-accent-text-color, #0a84ff);
  --section-bg: var(--tg-theme-section-bg-color, #1c1c1e);
  --section-header: var(--tg-theme-section-header-text-color, #8e8e93);
  --separator: var(--tg-theme-section-separator-color, #38383a);
  --radius: 12px;
  --gap: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, 'Inter', BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Navigation tabs */
#nav {
  display: flex;
  overflow-x: auto;
  gap: 4px;
  padding: 8px 12px;
  background: var(--secondary-bg);
  position: sticky;
  top: 0;
  z-index: 100;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#nav::-webkit-scrollbar { display: none; }

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  color: var(--hint);
  transition: all 0.15s;
  flex-shrink: 0;
  min-width: 64px;
}
.nav-tab .icon { font-size: 20px; }
.nav-tab .label { font-size: 10px; font-weight: 500; }
.nav-tab.active { color: var(--accent); background: var(--bg); }

/* Loading */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--hint);
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--separator);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Main content */
#content { padding: var(--gap); padding-bottom: 80px; }

/* Card */
.card {
  background: var(--section-bg);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: var(--gap);
}
.card-header {
  font-size: 13px;
  color: var(--section-header);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  font-weight: 600;
}

/* Status indicators */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot.green { background: #30d158; }
.status-dot.yellow { background: #ffd60a; }
.status-dot.red { background: var(--destructive); }
.status-dot.gray { background: var(--hint); }

/* Host grid */
.host-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--gap);
}
.host-card {
  background: var(--section-bg);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.host-card:active { opacity: 0.7; }
.host-card .name { font-weight: 600; font-size: 14px; }
.host-card .ip { font-size: 11px; color: var(--hint); }
.host-card .metrics { display: flex; gap: 8px; margin-top: 8px; }
.host-card .metric {
  font-size: 11px;
  color: var(--hint);
}
.host-card .metric span { color: var(--text); font-weight: 500; }

/* List items */
.list-item {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--separator);
}
.list-item:last-child { border-bottom: none; }
.list-item .info { flex: 1; }
.list-item .title { font-weight: 500; font-size: 14px; }
.list-item .subtitle { font-size: 12px; color: var(--hint); }
.list-item .action {
  background: var(--btn);
  color: var(--btn-text);
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* Buttons */
.btn {
  background: var(--btn);
  color: var(--btn-text);
  border: none;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-bottom: 8px;
}
.btn:active { transform: scale(0.98); }
.btn.secondary { background: var(--secondary-bg); color: var(--text); }
.btn.danger { background: var(--destructive); }

/* Kanban */
.kanban-board { display: flex; gap: var(--gap); overflow-x: auto; padding-bottom: 12px; }
.kanban-col { flex: 0 0 280px; }
.kanban-col-header {
  font-size: 12px;
  color: var(--section-header);
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 8px;
  padding: 4px 8px;
}
.kanban-card {
  background: var(--section-bg);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
}
.kanban-card .key { font-size: 11px; color: var(--accent); font-weight: 600; }
.kanban-card .summary { font-size: 14px; margin-top: 4px; }
.kanban-card .meta { font-size: 11px; color: var(--hint); margin-top: 4px; }

/* Diff viewer */
.diff-file {
  background: var(--section-bg);
  border-radius: var(--radius);
  margin-bottom: var(--gap);
  overflow: hidden;
}
.diff-file-header {
  padding: 8px 12px;
  background: var(--secondary-bg);
  font-family: monospace;
  font-size: 12px;
  font-weight: 600;
}
.diff-content {
  padding: 8px 12px;
  overflow-x: auto;
  font-family: monospace;
  font-size: 12px;
  line-height: 1.4;
  white-space: pre;
}
.diff-add { color: #30d158; }
.diff-del { color: var(--destructive); }
.diff-ctx { color: var(--hint); }

/* Search */
.search-bar {
  background: var(--secondary-bg);
  border: none;
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  font-size: 15px;
  width: 100%;
  margin-bottom: var(--gap);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--secondary-bg);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 1000;
  animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; transform: translate(-50%, 10px); } }

/* Collapsible sections */
.section { margin-bottom: var(--gap); }
.section-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}
.section-desc { font-size: 13px; color: var(--hint); margin-bottom: 8px; }

/* Detail view */
.detail-back {
  color: var(--accent);
  font-size: 15px;
  margin-bottom: 12px;
  cursor: pointer;
}

/* Progress bars */
.progress-bar {
  height: 4px;
  background: var(--separator);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}
.progress-bar .fill { height: 100%; border-radius: 2px; transition: width 0.3s; }

/* Badge */
.badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge.success { background: rgba(48,209,88,0.2); color: #30d158; }
.badge.warning { background: rgba(255,214,10,0.2); color: #ffd60a; }
.badge.danger { background: rgba(255,69,58,0.2); color: var(--destructive); }
.badge.info { background: rgba(10,132,255,0.2); color: var(--accent); }

/* Empty state */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--hint);
}
.empty .icon { font-size: 48px; opacity: 0.3; margin-bottom: 8px; }

/* Action grid for ops remote */
.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--gap);
}
.action-btn {
  background: var(--section-bg);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: opacity 0.15s;
}
.action-btn:active { opacity: 0.7; }
.action-btn .icon { font-size: 24px; margin-bottom: 4px; }
.action-btn .label { font-size: 12px; color: var(--hint); }

/* Output log */
.output-log {
  background: #000;
  color: #0f0;
  padding: 12px;
  border-radius: 8px;
  font-family: monospace;
  font-size: 12px;
  overflow-x: auto;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
}
