/* ═══════════════════════════════════════════════════════
   Claude Code Control Panel — Pebble Theme
   Warm, premium dashboard aesthetic
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── Tokens ─────────────────────────────────────────── */
:root {
  --bg:        #f5f0e8;
  --surface:   #fff;
  --surface2:  #f7f3ed;
  --surface3:  #ede8e0;
  --border:    rgba(0,0,0,0.08);
  --border-hi: rgba(0,0,0,0.13);
  --accent:    #059669;
  --accent2:   #10b981;
  --accent-soft: rgba(5,150,105,0.10);
  --text:      #1c1917;
  --text-2:    #57534e;
  --muted:     #a8a29e;
  --red:       #dc2626;
  --amber:     #d97706;
  --white:     #fff;

  --r-sm:  6px;
  --r-md:  10px;
  --r-lg:  14px;
  --r-xl:  20px;

  --shadow-sm: 0 1px 4px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.14);
  --shadow-glow: 0 0 40px rgba(5,150,105,0.12);

  --font:      'Plus Jakarta Sans', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --topbar-h:  52px;
  --sidebar-w: 220px;
  --footer-h:  36px;
  --action-h:  52px;
}

/* ── Reset ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

/* ── Body atmosphere ────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 600px 400px at 70% 60%, rgba(5,150,105,0.06), transparent 70%),
    radial-gradient(ellipse 400px 300px at 20% 30%, rgba(217,119,6,0.03), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  background-size: 200px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.7;
}

/* ── Login Screen ───────────────────────────────────── */
.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  background: var(--bg);
}

.login-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 500px 400px at 50% 45%, rgba(5,150,105,0.08), transparent 70%);
  pointer-events: none;
}

.login-card {
  position: relative;
  width: 360px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 40px 32px 32px;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  animation: loginAppear 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes loginAppear {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.login-logo .logo-dot {
  width: 10px;
  height: 10px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(5,150,105,0.4);
}

.login-logo h1 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.login-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 28px;
  padding-left: 20px;
}

.login-field {
  position: relative;
  margin-bottom: 16px;
}

.login-field input {
  width: 100%;
  padding: 12px 16px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.login-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-field input::placeholder {
  color: var(--muted);
  font-weight: 400;
}

.login-error {
  font-size: 12px;
  color: var(--red);
  margin-bottom: 12px;
  min-height: 18px;
  font-weight: 500;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: none;
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
  white-space: nowrap;
  user-select: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  width: 100%;
  padding: 12px 20px;
  background: var(--accent);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(5,150,105,0.25);
}

.btn-primary:hover {
  background: #047857;
  box-shadow: 0 4px 14px rgba(5,150,105,0.3);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  padding: 8px 14px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface3);
  border-color: var(--border-hi);
}

.btn-danger {
  padding: 8px 14px;
  background: rgba(220,38,38,0.08);
  color: var(--red);
  border: 1px solid rgba(220,38,38,0.15);
}

.btn-danger:hover {
  background: rgba(220,38,38,0.14);
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--r-md);
  background: var(--surface2);
  color: var(--text-2);
  border: 1px solid var(--border);
  font-size: 15px;
}

.btn-icon:hover {
  background: var(--surface3);
  color: var(--text);
}

/* ── App Shell ──────────────────────────────────────── */
.app {
  display: none;
  flex-direction: column;
  height: 100vh;
  position: relative;
  z-index: 1;
}

.app.active {
  display: flex;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Topbar ─────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-dot {
  width: 9px;
  height: 9px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(5,150,105,0.35);
  flex-shrink: 0;
}

.topbar-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.topbar-title span {
  font-weight: 500;
  color: var(--text-2);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.user-pill:hover {
  background: var(--surface3);
  border-color: var(--border-hi);
}

.user-avatar {
  width: 24px;
  height: 24px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 11px;
  font-weight: 700;
}

.user-pill svg {
  width: 12px;
  height: 12px;
  color: var(--muted);
  margin-left: 2px;
}

/* ── Main Layout ────────────────────────────────────── */
.main {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ── Sidebar ────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-header {
  padding: 14px 14px 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.server-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
}

.server-list::-webkit-scrollbar { width: 4px; }
.server-list::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 2px; }

.server-group {
  margin-bottom: 16px;
}

.server-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0 8px;
  margin-bottom: 4px;
}

.server-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all 0.12s;
  margin-bottom: 2px;
}

.server-item:hover {
  background: var(--surface2);
}

.server-item.active {
  background: var(--accent-soft);
}

.server-item.active .server-name {
  color: var(--accent);
  font-weight: 700;
}

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

.status-dot.online {
  background: var(--accent2);
  box-shadow: 0 0 6px rgba(16,185,129,0.5);
  animation: pulse 2s ease-in-out infinite;
}

.status-dot.offline {
  background: var(--muted);
}

.status-dot.error {
  background: var(--red);
  box-shadow: 0 0 6px rgba(220,38,38,0.4);
}

.status-dot.warning {
  background: var(--amber);
  box-shadow: 0 0 6px rgba(217,119,6,0.4);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

.server-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.server-label {
  font-size: 10px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-weight: 500;
}

.server-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-footer {
  padding: 10px 8px 12px;
  border-top: 1px solid var(--border);
}

.btn-add-server {
  width: 100%;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface2);
  border: 1.5px dashed var(--border-hi);
  border-radius: var(--r-md);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
  letter-spacing: 0.02em;
}

.btn-add-server:hover {
  background: var(--surface3);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Content Area ───────────────────────────────────── */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 12px 14px 0;
  gap: 10px;
}

/* ── Status Card ────────────────────────────────────── */
.status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
}

.status-item .label {
  color: var(--muted);
  font-weight: 500;
}

.status-item .value {
  color: var(--text);
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 12px;
}

.status-item .value.running {
  color: var(--accent);
}

.status-item .value.stopped {
  color: var(--red);
}

.status-item .value.idle {
  color: var(--amber);
}

.status-separator {
  width: 1px;
  height: 20px;
  background: var(--border);
}

/* ── Terminal Area ──────────────────────────────────── */
.terminal-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--border-hi);
  box-shadow: var(--shadow-md), var(--shadow-glow);
  background: #1a1a1a;
}

.terminal-wrap iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.terminal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(26,26,26,0.92);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  z-index: 10;
}

.terminal-overlay.active {
  display: flex;
}

.terminal-overlay .overlay-icon {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(16,185,129,0.3);
  border-top-color: var(--accent2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.terminal-overlay .overlay-text {
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  font-weight: 600;
}

.terminal-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 32px;
  background: linear-gradient(180deg, rgba(26,26,26,0.95), transparent);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 6px;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.terminal-wrap:hover .terminal-header {
  opacity: 1;
}

.terminal-header .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.terminal-header .dot:nth-child(1) { background: #ff5f57; }
.terminal-header .dot:nth-child(2) { background: #ffbd2e; }
.terminal-header .dot:nth-child(3) { background: #28c840; }

.terminal-header .term-label {
  margin-left: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: rgba(255,255,255,0.35);
}

/* ── Action Bar ─────────────────────────────────────── */
.action-bar {
  height: var(--action-h);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 0 2px;
}

.action-bar .dropdown-wrap {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  z-index: 100;
  display: none;
  overflow: hidden;
  animation: dropUp 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.dropdown-menu.open {
  display: block;
}

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

.dropdown-menu .dd-header {
  padding: 8px 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.dropdown-menu .dd-item {
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s;
  font-family: var(--font-mono);
  font-size: 12px;
}

.dropdown-menu .dd-item:hover {
  background: var(--surface2);
}

.dropdown-menu .dd-item.active {
  color: var(--accent);
  font-weight: 600;
}

.action-spacer { flex: 1; }

/* ── Session Tabs ───────────────────────────────────── */
.session-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  flex: 1;
  min-width: 0;
}

.session-tabs::-webkit-scrollbar { display: none; }

.session-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-2);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}

.session-tab:hover {
  background: var(--surface3);
}

.session-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(5,150,105,0.2);
}

.session-tab .tab-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
}

.session-tab.active .tab-dot {
  background: var(--accent);
}

.tab-close {
  margin-left: 4px;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
  color: var(--muted);
  transition: all 0.12s;
}

.tab-close:hover {
  background: rgba(220, 38, 38, 0.12);
  color: #dc2626;
}

/* ── Footer ─────────────────────────────────────────── */
.footer {
  height: var(--footer-h);
  display: flex;
  align-items: center;
  padding: 0 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
  gap: 16px;
  flex-shrink: 0;
  z-index: 50;
}

.footer-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.footer-sep {
  color: var(--border-hi);
}

/* ── Modal ──────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 28px 24px 20px;
  width: 400px;
  max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-lg);
  animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal h2 {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 4px;
}

.modal .modal-sub {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 20px;
}

.modal .form-group {
  margin-bottom: 14px;
}

.modal .form-group label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2);
  margin-bottom: 5px;
}

.modal .form-group input,
.modal .form-group select {
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  outline: none;
  transition: border-color 0.15s;
}

.modal .form-group input:focus,
.modal .form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* ── Loading Skeleton ───────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface2) 30%, var(--surface3) 50%, var(--surface2) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--r-sm);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Tooltip ────────────────────────────────────────── */
[data-tip] {
  position: relative;
}

[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--white);
  background: var(--text);
  border-radius: var(--r-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: all 0.15s;
  z-index: 500;
}

[data-tip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Mobile ─────────────────────────────────────────── */
@media (max-width: 700px) {
  :root {
    --topbar-h: 48px;
    --footer-h: 0px;
  }

  .main {
    flex-direction: column;
  }

  /* Hide sidebar, footer, status card, action bar on mobile — just show terminal */
  .sidebar { display: none !important; }
  .footer { display: none; }
  .status-card { display: none; }
  .action-bar { display: none; }

  .content {
    flex: 1;
    padding: 0;
    gap: 0;
  }

  .terminal-wrap {
    border-radius: 0;
    border: none;
  }

  .topbar-title span { display: none; }
}

/* ── Scrollbar Global ───────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Utility ────────────────────────────────────────── */
.hidden { display: none !important; }
.mono { font-family: var(--font-mono); }
