/* ════════════════════════════════════════════════════════════════════════
   LFC DockerFlow — Admin UI
   ════════════════════════════════════════════════════════════════════════ */

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

:root {
  --bg:           #0d1117;
  --bg-2:         #161b22;
  --bg-3:         #21262d;
  --bg-4:         #30363d;
  --border:       #30363d;
  --border-light: #21262d;

  --text:         #e6edf3;
  --text-muted:   #8b949e;
  --text-dim:     #484f58;

  --accent:       #238636;
  --accent-hover: #2ea043;
  --accent-text:  #aff5b4;

  --blue:         #1f6feb;
  --blue-hover:   #388bfd;
  --blue-dim:     #1c2d41;

  --danger:       #da3633;
  --danger-dim:   #3d1c1c;
  --danger-text:  #ffa198;

  --warn:         #d29922;
  --warn-dim:     #3d2b00;

  --info:         #1f6feb;
  --info-dim:     #1c2d41;

  --radius-sm:    4px;
  --radius:       8px;
  --radius-lg:    12px;

  --sidebar-w:    240px;
  --transition:   0.15s ease;

  --font-mono:    'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ── Screens ──────────────────────────────────────────────────────────── */
.screen { display: none; height: 100%; }
.screen.active { display: flex; }

/* ── AUTH SCREEN ─────────────────────────────────────────────────────── */
#screen-auth {
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(31,111,235,.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 10%, rgba(35,134,54,.06) 0%, transparent 50%);
}

.auth-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 48px rgba(0,0,0,.4);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: .875rem;
  margin-bottom: 2rem;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--blue), var(--accent));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(31,111,235,.3);
}
.logo-icon svg { width: 22px; height: 22px; color: #fff; }
.logo-icon.small { width: 28px; height: 28px; border-radius: 6px; }
.logo-icon.small svg { width: 16px; height: 16px; }

.logo-title { display: block; font-weight: 700; font-size: 1.1rem; color: var(--text); }
.logo-sub   { display: block; font-size: .75rem; color: var(--text-muted); }

.auth-card h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: .375rem;
}

.auth-hint {
  color: var(--text-muted);
  margin-bottom: 1.75rem;
  font-size: .875rem;
}

/* ── ADMIN SCREEN ────────────────────────────────────────────────────── */
#screen-admin {
  flex-direction: row;
  height: 100vh;
  overflow: hidden;
}

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

.sidebar-header {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: 1rem 1rem .875rem;
  border-bottom: 1px solid var(--border-light);
  font-weight: 600;
  font-size: .875rem;
  color: var(--text);
}

.sidebar-section-label {
  padding: .875rem 1rem .375rem;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.project-list {
  flex: 1;
  overflow-y: auto;
  padding: .25rem .5rem;
}

.project-item {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .5rem .625rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  font-size: .875rem;
  transition: background var(--transition), color var(--transition);
  border: 1px solid transparent;
  user-select: none;
}

.project-item:hover { background: var(--bg-3); color: var(--text); }

.project-item.active {
  background: var(--blue-dim);
  color: var(--blue-hover);
  border-color: rgba(31,111,235,.3);
}

.project-item-icon {
  width: 20px;
  height: 20px;
  background: var(--bg-4);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: .65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  font-family: var(--font-mono);
}
.project-item.active .project-item-icon {
  background: var(--blue-dim);
  color: var(--blue-hover);
}

.project-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer {
  padding: .75rem 1rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}

.server-info {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-width: 0;
}

.server-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.server-dot.online  { background: var(--accent-hover); box-shadow: 0 0 6px var(--accent-hover); }
.server-dot.offline { background: var(--danger); }

.server-url-text {
  font-size: .7rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Main content */
.main {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* Empty state */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 3rem;
  color: var(--text-muted);
  text-align: center;
}

.empty-state svg {
  width: 64px;
  height: 64px;
  color: var(--text-dim);
}

.empty-state h3 { font-size: 1.125rem; color: var(--text); }
.empty-state p  { font-size: .875rem; max-width: 340px; }

/* Build panel */
.build-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 2rem;
  gap: 1.75rem;
  max-width: 900px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.panel-header h2 {
  font-size: 1.375rem;
  font-weight: 700;
  margin-bottom: .375rem;
}

.panel-subtitle { display: flex; align-items: center; gap: .5rem; }

/* ── Build form ───────────────────────────────────────────────────────── */
.build-form {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem 1.5rem;
}

@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* ── Fields ───────────────────────────────────────────────────────────── */
.field-group {
  display: flex;
  flex-direction: column;
  gap: .375rem;
}

.field-group label {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: .375rem;
}

.field-group.required label::after {
  content: '*';
  color: var(--danger-text);
  font-size: .75rem;
}

.field-hint {
  font-size: .72rem;
  color: var(--text-dim);
  line-height: 1.4;
}

.optional-badge {
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: .6rem;
  font-weight: 500;
  padding: 1px 6px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

input[type="text"],
input[type="url"],
input[type="password"] {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
  font-size: .875rem;
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input[type="text"]:focus,
input[type="url"]:focus,
input[type="password"]:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(31,111,235,.15);
}

input::placeholder { color: var(--text-dim); }

.input-password-wrap {
  position: relative;
}

.input-password-wrap input {
  padding-right: 2.5rem;
}

.btn-toggle-pw {
  position: absolute;
  right: .5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 4px;
  transition: color var(--transition);
}
.btn-toggle-pw:hover { color: var(--text-muted); }
.btn-toggle-pw svg { width: 16px; height: 16px; }

/* Toggle switch */
.field-group-inline { flex-direction: row; align-items: center; }

.toggle-label {
  display: flex;
  align-items: center;
  gap: .75rem;
  cursor: pointer;
  user-select: none;
  font-size: .875rem;
  color: var(--text-muted);
}
.toggle-label input[type="checkbox"] { display: none; }

.toggle-track {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: 100px;
  transition: background var(--transition), border-color var(--transition);
  flex-shrink: 0;
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform var(--transition), background var(--transition);
}

input[type="checkbox"]:checked + .toggle-track {
  background: var(--accent);
  border-color: var(--accent);
}
input[type="checkbox"]:checked + .toggle-track .toggle-thumb {
  transform: translateX(16px);
  background: #fff;
}

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: .875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition), opacity var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent-hover);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--bg-3); color: var(--text); }

.btn-sm { padding: .3125rem .625rem; font-size: .8125rem; }
.btn-sm svg { width: 14px; height: 14px; }

.btn-full { width: 100%; margin-top: .5rem; padding: .625rem 1rem; }

/* ── Alerts ───────────────────────────────────────────────────────────── */
.alert {
  padding: .625rem .875rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  border: 1px solid transparent;
}
.alert-error {
  background: var(--danger-dim);
  border-color: rgba(218,54,51,.3);
  color: var(--danger-text);
}

/* ── Badges ───────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: .7rem;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: .02em;
  border: 1px solid transparent;
}

.badge-project {
  background: var(--blue-dim);
  border-color: rgba(31,111,235,.3);
  color: var(--blue-hover);
}

.badge-success {
  background: rgba(35,134,54,.15);
  border-color: rgba(35,134,54,.3);
  color: var(--accent-text);
}

.badge-error {
  background: var(--danger-dim);
  border-color: rgba(218,54,51,.3);
  color: var(--danger-text);
}

.badge-running {
  background: var(--warn-dim);
  border-color: rgba(210,153,34,.3);
  color: #e3b341;
}

/* ── Logs section ─────────────────────────────────────────────────────── */
.logs-section {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 240px;
}

.logs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-3);
  gap: 1rem;
}

.logs-title {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.logs-header-right {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.duration-text {
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--text-dim);
}

.logs-output {
  flex: 1;
  overflow-y: auto;
  padding: .875rem 1rem;
  font-family: var(--font-mono);
  font-size: .8rem;
  line-height: 1.7;
  max-height: 480px;
}

.log-line {
  display: flex;
  gap: .75rem;
  align-items: baseline;
}

.log-time {
  color: var(--text-dim);
  flex-shrink: 0;
  font-size: .72rem;
}

.log-level {
  flex-shrink: 0;
  width: 36px;
  text-align: right;
  font-weight: 600;
  font-size: .68rem;
  text-transform: uppercase;
}
.log-level.info  { color: var(--blue-hover); }
.log-level.error { color: var(--danger-text); }
.log-level.warn  { color: var(--warn); }

.log-msg {
  color: var(--text);
  word-break: break-word;
}
.log-msg.error { color: var(--danger-text); }

/* ── Skeletons ────────────────────────────────────────────────────────── */
.skeleton-list { display: flex; flex-direction: column; gap: .375rem; padding: .25rem 0; }

.skeleton {
  height: 32px;
  background: linear-gradient(90deg, var(--bg-3) 25%, var(--bg-4) 50%, var(--bg-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}

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

/* ── Spinner ──────────────────────────────────────────────────────────── */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

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

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