/* ══════════════════════════════════════════
   Docker Monitor — Telegram Mini App Styles
   Dark theme, mobile-first
   ══════════════════════════════════════════ */

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #1e2a4a;
  --bg-card-hover: #243356;
  --bg-modal: #0f1629;
  --text-primary: #e8e8f0;
  --text-secondary: #8892b0;
  --text-muted: #5a6380;
  --accent: #64ffda;
  --accent-dim: rgba(100, 255, 218, 0.15);
  --danger: #ff6b6b;
  --danger-dim: rgba(255, 107, 107, 0.15);
  --warning: #ffd93d;
  --success: #6bcb77;
  --border: rgba(255, 255, 255, 0.06);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Screens ── */
.screen {
  display: none;
}
.screen.active {
  display: block;
}

/* ── Auth screen ── */
.auth-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  text-align: center;
}
.auth-icon {
  font-size: 64px;
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
.auth-wrap h1 {
  font-size: 24px;
  margin-bottom: 8px;
  color: var(--accent);
}
.auth-wrap p {
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* ── Spinner ── */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Error ── */
.error {
  color: var(--danger);
  font-size: 14px;
  margin-top: 12px;
}
.hidden {
  display: none !important;
}

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-icon {
  font-size: 24px;
}
.header h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── Ping indicator ── */
.ping {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.ping-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  transition: background var(--transition);
}
.ping-dot.slow {
  background: var(--warning);
}
.ping-dot.dead {
  background: var(--danger);
}

/* ── Icon buttons ── */
.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover {
  color: var(--accent);
  background: var(--accent-dim);
}
.btn-icon:active {
  transform: scale(0.92);
}

/* ── Refresh spin ── */
.btn-icon.spinning svg {
  animation: spin 0.6s linear infinite;
}

/* ── Summary bar ── */
.summary-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}
.summary-item {
  flex: 1;
  text-align: center;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
}
.summary-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.summary-value {
  display: block;
  font-size: 20px;
  font-weight: 700;
}
.summary-item.running .summary-value {
  color: var(--success);
}
.summary-item.stopped .summary-value {
  color: var(--danger);
}

/* ── Container list ── */
.container-list {
  padding: 12px 16px;
  padding-bottom: 60px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.loading-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  gap: 16px;
}

/* ── Container card ── */
.container-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: all var(--transition);
}
.container-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.1);
}

.card-main {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
}

/* Status indicator */
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background var(--transition);
}
.status-dot.running {
  background: var(--success);
  box-shadow: 0 0 8px rgba(107, 203, 119, 0.4);
}
.status-dot.stopped,
.status-dot.exited,
.status-dot.dead {
  background: var(--danger);
  box-shadow: 0 0 8px rgba(255, 107, 107, 0.3);
}
.status-dot.paused,
.status-dot.restarting,
.status-dot.created {
  background: var(--warning);
  box-shadow: 0 0 8px rgba(255, 217, 61, 0.3);
}

.card-info {
  flex: 1;
  min-width: 0;
}
.card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-image {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.card-toggle {
  color: var(--text-muted);
  transition: transform var(--transition);
  flex-shrink: 0;
}
.card-toggle.open {
  transform: rotate(180deg);
}

/* ── Card details (expanded) ── */
.card-details {
  display: none;
  padding: 0 16px 14px;
  border-top: 1px solid var(--border);
}
.card-details.open {
  display: block;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}
.detail-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.detail-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.detail-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.detail-value.cpu {
  color: var(--accent);
}
.detail-value.mem {
  color: var(--warning);
}

/* Progress bar for memory */
.mem-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}
.mem-bar-fill {
  height: 100%;
  background: var(--warning);
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* ── Action buttons ── */
.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.btn-action {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-action:active {
  transform: scale(0.96);
}
.btn-action:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-start {
  background: rgba(107, 203, 119, 0.15);
  color: var(--success);
}
.btn-start:hover:not(:disabled) {
  background: rgba(107, 203, 119, 0.25);
}

.btn-stop {
  background: var(--danger-dim);
  color: var(--danger);
}
.btn-stop:hover:not(:disabled) {
  background: rgba(255, 107, 107, 0.25);
}

.btn-restart {
  background: rgba(255, 217, 61, 0.12);
  color: var(--warning);
}
.btn-restart:hover:not(:disabled) {
  background: rgba(255, 217, 61, 0.22);
}

.btn-logs {
  background: rgba(100, 255, 218, 0.1);
  color: var(--accent);
}
.btn-logs:hover:not(:disabled) {
  background: rgba(100, 255, 218, 0.2);
}

/* ── WebSocket status bar ── */
.ws-status {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  z-index: 100;
}
.ws-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  transition: background var(--transition);
}
.ws-status.connected .ws-dot {
  background: var(--success);
}
.ws-status.disconnected .ws-dot {
  background: var(--danger);
}

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal-content {
  background: var(--bg-modal);
  width: 100%;
  max-height: 80vh;
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
}
.btn-close {
  font-size: 24px;
  width: 32px;
  height: 32px;
}
.logs-content {
  flex: 1;
  overflow: auto;
  padding: 16px 20px;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Toast notifications ── */
#toast-container {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  animation: toastIn 0.3s ease;
  pointer-events: auto;
}
.toast.success {
  background: rgba(107, 203, 119, 0.2);
  color: var(--success);
  border: 1px solid rgba(107, 203, 119, 0.3);
}
.toast.error {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 107, 0.3);
}
.toast.info {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(100, 255, 218, 0.3);
}
@keyframes toastIn {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.toast.removing {
  animation: toastOut 0.3s ease forwards;
}
@keyframes toastOut {
  to { transform: translateY(-20px); opacity: 0; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 2px;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
}
