/* ===================== RESET & BASE ===================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --bg-card: #1a1f2e;
  --bg-card-hover: #1f2640;
  --bg-input: #0d1117;
  --border: #2a3040;
  --border-focus: #3d5a80;
  --text: #e2e8f0;
  --text-muted: #718096;
  --text-dim: #4a5568;
  --accent: #2496ed;
  --accent-hover: #1a7dc4;
  --green: #38a169;
  --green-bg: #1a2e1a;
  --red: #e53e3e;
  --red-bg: #2e1a1a;
  --yellow: #d69e2e;
  --yellow-bg: #2e281a;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --transition: 0.2s ease;
}

html { font-size: 16px; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ===================== UTILITIES ===================== */
.hidden { display: none !important; }
.ml-auto { margin-left: auto; }
.text-muted { color: var(--text-muted); font-size: 0.8rem; }

/* ===================== SPINNER ===================== */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== BUTTONS ===================== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border: none; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 0.875rem; font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); }
.btn-full { width: 100%; justify-content: center; padding: 12px; font-size: 1rem; }
.btn-icon { background: transparent; color: var(--text-muted); padding: 6px; border-radius: var(--radius-sm); }
.btn-icon:hover { background: var(--bg-card); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-outline-danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn-outline-danger:hover { background: var(--red-bg); }
.btn-green { background: var(--green-bg); color: var(--green); border: 1px solid rgba(56,161,105,0.3); }
.btn-green:hover:not(:disabled) { background: rgba(56,161,105,0.25); }
.btn-red { background: var(--red-bg); color: var(--red); border: 1px solid rgba(229,62,62,0.3); }
.btn-red:hover:not(:disabled) { background: rgba(229,62,62,0.25); }
.btn-yellow { background: var(--yellow-bg); color: var(--yellow); border: 1px solid rgba(214,158,46,0.3); }
.btn-yellow:hover:not(:disabled) { background: rgba(214,158,46,0.25); }
.btn-blue { background: rgba(36,150,237,0.1); color: var(--accent); border: 1px solid rgba(36,150,237,0.3); }
.btn-blue:hover:not(:disabled) { background: rgba(36,150,237,0.2); }
.btn-command { padding: 10px 20px; border-radius: var(--radius-sm); }

/* ===================== BADGE ===================== */
.badge {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.8rem;
}

/* ===================== LOGIN ===================== */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at top, #0d1929 0%, var(--bg) 60%);
  padding: 20px;
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%; max-width: 400px;
  box-shadow: var(--shadow);
  animation: fadeInUp 0.4s ease;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.login-logo {
  display: flex; justify-content: center;
  margin-bottom: 20px;
  animation: pulse 2s ease infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
.login-title {
  text-align: center; font-size: 1.75rem; font-weight: 700;
  color: var(--text); margin-bottom: 6px;
}
.login-subtitle {
  text-align: center; color: var(--text-muted); font-size: 0.9rem;
  margin-bottom: 28px;
}
.login-form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.85rem; font-weight: 500; color: var(--text-muted); }
.form-group input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 14px;
  font-size: 0.95rem;
  transition: border-color var(--transition);
  outline: none;
}
.form-group input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(61,90,128,0.2); }
.form-group input::placeholder { color: var(--text-dim); }
.login-error {
  background: var(--red-bg); border: 1px solid rgba(229,62,62,0.3);
  color: var(--red); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 0.875rem;
}

/* ===================== HEADER ===================== */
.header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: rgba(15,17,23,0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  height: 60px;
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header-logo { font-size: 1.5rem; }
.header-title { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.header-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }

/* ===================== MAIN ===================== */
.main-content {
  margin-top: 60px;
  margin-bottom: 80px;
  padding: 24px;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

/* ===================== STATS BAR ===================== */
.stats-bar {
  display: flex; align-items: center; gap: 20px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.stat-item { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.stat-dot {
  width: 8px; height: 8px; border-radius: 50%;
}
.stat-dot.running { background: var(--green); box-shadow: 0 0 6px var(--green); }
.stat-dot.stopped { background: var(--red); box-shadow: 0 0 6px var(--red); }
.stat-dot.paused { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }

/* ===================== LOADING / ERROR STATE ===================== */
.loading-state, .error-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.error-icon { font-size: 2rem; margin-bottom: 12px; }

/* ===================== CONTAINER GRID ===================== */
.container-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

/* ===================== CONTAINER CARD ===================== */
.container-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: all var(--transition);
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.container-card:hover { border-color: var(--border-focus); transform: translateY(-2px); box-shadow: var(--shadow); }
.container-card.running { border-left: 3px solid var(--green); }
.container-card.exited, .container-card.stopped { border-left: 3px solid var(--red); }
.container-card.paused { border-left: 3px solid var(--yellow); }
.container-card.created, .container-card.restarting { border-left: 3px solid var(--accent); }

.card-header {
  display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px;
}
.card-status-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 5px;
}
.running .card-status-dot { background: var(--green); box-shadow: 0 0 8px var(--green); animation: blink 2s ease infinite; }
.exited .card-status-dot, .stopped .card-status-dot { background: var(--red); }
.paused .card-status-dot { background: var(--yellow); }
.created .card-status-dot, .restarting .card-status-dot { background: var(--accent); }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.card-name { font-size: 0.95rem; font-weight: 600; color: var(--text); word-break: break-all; }
.card-status-badge {
  margin-left: auto; flex-shrink: 0;
  padding: 2px 8px; border-radius: 12px;
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}
.running .card-status-badge { background: var(--green-bg); color: var(--green); }
.exited .card-status-badge, .stopped .card-status-badge { background: var(--red-bg); color: var(--red); }
.paused .card-status-badge { background: var(--yellow-bg); color: var(--yellow); }
.created .card-status-badge, .restarting .card-status-badge { background: rgba(36,150,237,0.1); color: var(--accent); }

.card-image {
  font-size: 0.78rem; color: var(--text-muted); font-family: monospace;
  background: var(--bg-input); border-radius: 4px; padding: 4px 8px;
  margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-meta {
  display: flex; gap: 12px; margin-bottom: 14px;
  font-size: 0.75rem; color: var(--text-dim);
}
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.card-actions .btn { font-size: 0.78rem; padding: 5px 10px; }

/* ===================== RESULT PANEL ===================== */
.result-panel {
  position: fixed; bottom: 80px; right: 24px;
  width: 500px; max-width: calc(100vw - 48px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 200;
  animation: slideInRight 0.3s ease;
  max-height: 400px;
  display: flex; flex-direction: column;
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
.result-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.result-title { font-size: 0.875rem; font-weight: 600; }
.result-content {
  padding: 14px 16px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.78rem;
  color: #a0c4ff;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.6;
  max-height: 340px;
}

/* ===================== COMMAND BAR ===================== */
.command-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: rgba(15,17,23,0.97);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding: 12px 24px;
}
.command-bar-inner {
  display: flex; align-items: center; gap: 10px;
  max-width: 1400px; margin: 0 auto;
}
.command-icon { font-size: 1.2rem; flex-shrink: 0; }
.command-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 14px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition);
}
.command-input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(61,90,128,0.2); }
.command-input::placeholder { color: var(--text-dim); }

/* ===================== REFRESH ANIMATION ===================== */
.btn-icon.refreshing svg { animation: spin 0.7s linear infinite; }

/* ===================== TOAST ===================== */
.toast-container {
  position: fixed; top: 72px; right: 20px; z-index: 500;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 16px;
  font-size: 0.85rem; box-shadow: var(--shadow);
  animation: slideInRight 0.3s ease;
  max-width: 320px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--accent); }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 640px) {
  .header { padding: 0 16px; }
  .header-title { display: none; }
  .main-content { padding: 16px; margin-top: 60px; margin-bottom: 72px; }
  .command-bar { padding: 10px 12px; }
  .result-panel { width: calc(100vw - 32px); right: 16px; bottom: 72px; }
  .container-grid { grid-template-columns: 1fr; }
}
