/* Command Center — Telegram Mini App Styles */
/* Uses Telegram CSS variables for native look */

:root {
  --cc-bg: var(--tg-theme-bg-color, #1a1a2e);
  --cc-text: var(--tg-theme-text-color, #e0e0e0);
  --cc-hint: var(--tg-theme-hint-color, #8a8a9a);
  --cc-link: var(--tg-theme-link-color, #64b5f6);
  --cc-btn: var(--tg-theme-button-color, #5288c1);
  --cc-btn-text: var(--tg-theme-button-text-color, #ffffff);
  --cc-secondary: var(--tg-theme-secondary-bg-color, #16213e);
  --cc-section-bg: var(--tg-theme-section-bg-color, var(--cc-secondary));
  --cc-section-header: var(--tg-theme-section-header-text-color, var(--cc-hint));

  --cc-green: #4caf50;
  --cc-yellow: #ffc107;
  --cc-red: #ef5350;
  --cc-orange: #ff9800;

  --cc-radius: 12px;
  --cc-gap: 12px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--cc-bg);
  color: var(--cc-text);
  line-height: 1.5;
  padding: 0 var(--cc-gap) var(--cc-gap);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Loading State ─────────────────────────────────── */

.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 80vh;
  gap: 16px;
}

.loading-screen .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--cc-secondary);
  border-top-color: var(--cc-btn);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-screen .label {
  color: var(--cc-hint);
  font-size: 14px;
}

/* ── Briefing Header ──────────────────────────────── */

.briefing {
  padding: 16px 4px 8px;
}

.briefing .greeting {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.briefing .summary {
  font-size: 16px;
  color: var(--cc-hint);
  line-height: 1.6;
}

.briefing .timestamp {
  font-size: 13px;
  color: var(--cc-hint);
  opacity: 0.6;
  margin-top: 6px;
}

/* ── Pulse Bar ────────────────────────────────────── */

.pulse-bar {
  display: flex;
  gap: 8px;
  padding: 10px 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.pulse-bar::-webkit-scrollbar { display: none; }

.pulse-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--cc-section-bg);
  border-radius: 20px;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
  user-select: none;
}

.pulse-chip:active {
  transform: scale(0.96);
  opacity: 0.8;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.pulse-dot.green { background: var(--cc-green); box-shadow: 0 0 6px var(--cc-green); }
.pulse-dot.yellow { background: var(--cc-yellow); box-shadow: 0 0 6px var(--cc-yellow); }
.pulse-dot.red { background: var(--cc-red); box-shadow: 0 0 6px var(--cc-red); }

/* ── Section Headers ──────────────────────────────── */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px 8px;
}

.section-header h2 {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--cc-section-header);
}

.section-header .badge {
  font-size: 13px;
  color: var(--cc-hint);
  background: var(--cc-section-bg);
  padding: 2px 8px;
  border-radius: 10px;
}

/* ── Cards ────────────────────────────────────────── */

.card-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card {
  background: var(--cc-section-bg);
  border-radius: var(--cc-radius);
  padding: 16px;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.card:active {
  transform: scale(0.98);
  opacity: 0.85;
}

.card .card-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card .card-icon {
  font-size: 24px;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
}

.card .card-content {
  flex: 1;
  min-width: 0;
}

.card .card-title {
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card .card-subtitle {
  font-size: 15px;
  color: var(--cc-hint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.card .card-snippet {
  font-size: 14px;
  color: var(--cc-hint);
  opacity: 0.7;
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.card .card-meta {
  font-size: 13px;
  color: var(--cc-hint);
  flex-shrink: 0;
  text-align: right;
}

.card .card-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--cc-bg);
}

.card .card-tag.email { color: var(--cc-link); }
.card .card-tag.project { color: var(--cc-green); }
.card .card-tag.server { color: var(--cc-orange); }
.card .card-tag.calendar { color: #ce93d8; }
.card .card-tag.spend { color: var(--cc-yellow); }

/* ── Action Sheet (bottom overlay) ────────────────── */

.action-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.action-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.action-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--cc-section-bg);
  border-radius: 16px 16px 0 0;
  padding: 12px 16px calc(env(safe-area-inset-bottom, 16px) + 16px);
  z-index: 101;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.action-overlay.visible .action-sheet {
  transform: translateY(0);
}

.action-sheet .handle {
  width: 36px;
  height: 4px;
  background: var(--cc-hint);
  opacity: 0.3;
  border-radius: 2px;
  margin: 0 auto 14px;
}

.action-sheet .context {
  font-size: 15px;
  color: var(--cc-hint);
  margin-bottom: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 16px;
  background: var(--cc-bg);
  border: none;
  border-radius: 10px;
  color: var(--cc-text);
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 6px;
  transition: transform 0.1s, opacity 0.15s;
  text-align: left;
}

.action-btn:active {
  transform: scale(0.97);
  opacity: 0.8;
}

.action-btn .action-icon {
  font-size: 18px;
  width: 28px;
  text-align: center;
}

.action-btn.primary {
  background: var(--cc-btn);
  color: var(--cc-btn-text);
}

/* ── Calendar Strip ───────────────────────────────── */

.calendar-strip {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cal-event {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--cc-section-bg);
  border-radius: var(--cc-radius);
  border-left: 3px solid #ce93d8;
}

.cal-event .cal-time {
  font-size: 15px;
  font-weight: 600;
  color: #ce93d8;
  min-width: 65px;
}

.cal-event .cal-title {
  font-size: 16px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Server Detail Panel ──────────────────────────── */

.server-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.server-stat {
  background: var(--cc-section-bg);
  border-radius: var(--cc-radius);
  padding: 12px;
  text-align: center;
}

.server-stat .stat-value {
  font-size: 20px;
  font-weight: 700;
}

.server-stat .stat-label {
  font-size: 13px;
  color: var(--cc-hint);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 2px;
}

/* ── Empty State ──────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 24px;
  color: var(--cc-hint);
  font-size: 14px;
}

.empty-state .empty-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

/* ── Quick Actions Bar ────────────────────────────── */

.quick-actions {
  display: flex;
  gap: 8px;
  padding: 8px 0 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.quick-actions::-webkit-scrollbar { display: none; }

.quick-action {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 18px;
  background: var(--cc-btn);
  color: var(--cc-btn-text);
  border: none;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
}

.quick-action:active {
  transform: scale(0.95);
  opacity: 0.85;
}

/* ── Refresh indicator ────────────────────────────── */

.refresh-indicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--cc-btn);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s;
  z-index: 200;
}

.refresh-indicator.active {
  animation: progress 2s ease-in-out infinite;
}

@keyframes progress {
  0% { transform: scaleX(0); transform-origin: left; }
  50% { transform: scaleX(1); transform-origin: left; }
  51% { transform: scaleX(1); transform-origin: right; }
  100% { transform: scaleX(0); transform-origin: right; }
}

/* ── Utility ──────────────────────────────────────── */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.fade-in {
  animation: fadeIn 0.3s ease-out;
}

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