/* =============================================================================
   ProxmoxPanel — Styles spécifiques aux pages
   Chargé sur toutes les pages. Persiste à travers les navigations Swup.
   ============================================================================= */

/* ── Spinners ────────────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-sm {
  display: inline-block;
  width: .875rem;
  height: .875rem;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

.spinner-lg {
  width: 2rem;
  height: 2rem;
  border: 3px solid transparent;
  border-top-color: var(--neu-primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

/* ── États communs ───────────────────────────────────────────────────────────── */
.loading-state {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 2rem;
  color: var(--neu-text-muted);
}

.empty-state {
  color: var(--neu-text-muted);
  font-size: .875rem;
}

.loading {
  color: var(--neu-text-muted);
  font-size: .875rem;
}

/* ── Badge statut ────────────────────────────────────────────────────────────── */
.badge {
  font-size: .7rem;
  padding: .2rem .5rem;
  border-radius: .25rem;
  text-transform: uppercase;
  font-weight: 600;
}
.badge.running, .resource-badge.running {
  background: rgba(34,197,94,.15);
  color: var(--neu-success);
}
.badge.stopped, .resource-badge.stopped {
  background: rgba(239,68,68,.1);
  color: var(--neu-danger);
}
.resource-badge {
  font-size: .7rem;
  padding: .2rem .5rem;
  border-radius: .25rem;
  text-transform: uppercase;
}

/* ── Formulaires ─────────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.form-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--neu-text-muted);
}
.form-error {
  background: rgba(239,68,68,.1);
  border: 1px solid var(--neu-danger);
  border-radius: .5rem;
  padding: .75rem;
  font-size: .875rem;
  color: var(--neu-danger);
}
.form-hint {
  font-size: .75rem;
  color: var(--neu-text-muted);
  margin: 0;
}

/* ── Sections ────────────────────────────────────────────────────────────────── */
.section {
  margin-bottom: 2rem;
}
.section-title {
  font-size: .875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--neu-text-muted);
  margin-bottom: .75rem;
}

/* ── WebSocket status ────────────────────────────────────────────────────────── */
.ws-status {
  padding: .5rem 1rem;
  border-radius: .5rem;
  font-size: .8rem;
  margin-bottom: 1rem;
  background: var(--neu-surface);
}
.ws-status.ok { color: var(--neu-success); }
.ws-status.disconnected,
.ws-status.error { color: var(--neu-warning); }

/* ── Métriques ───────────────────────────────────────────────────────────────── */
.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.resource-card { padding: 1rem; }
.resource-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .75rem;
}
.resource-name {
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.resource-id {
  font-size: .75rem;
  color: var(--neu-text-muted);
}
.resource-metrics { margin-bottom: .75rem; }
.resource-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.metric { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.metric-label { font-size: .7rem; color: var(--neu-text-muted); min-width: 30px; }
.metric-bar {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--neu-surface);
  overflow: hidden;
}
.metric-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--neu-primary);
  transition: width .5s;
}
.metric-val { font-size: .7rem; min-width: 36px; text-align: right; }

/* ── Dashboard — Stats ───────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card { padding: 1.25rem; text-align: center; }
.stat-icon { font-size: 1.5rem; margin-bottom: .5rem; color: var(--neu-primary); }
.stat-value { font-size: 2rem; font-weight: 700; }
.stat-label { font-size: .8rem; color: var(--neu-text-muted); }

/* ── Updates page ────────────────────────────────────────────────────────────── */
.page-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-actions-left,
.page-actions-right { display: flex; align-items: center; gap: .75rem; }
.total-badge { font-size: .875rem; font-weight: 600; color: var(--neu-primary); }
.targets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1rem;
}
.target-card { padding: 1rem; display: flex; flex-direction: column; gap: .75rem; }
.target-header { display: flex; justify-content: space-between; align-items: flex-start; }
.target-info { display: flex; flex-direction: column; gap: .2rem; }
.target-name { font-weight: 700; font-size: .95rem; }
.target-id { font-size: .7rem; color: var(--neu-text-muted); font-family: monospace; }
.target-status {}
.target-actions { display: flex; gap: .5rem; margin-top: auto; }
.package-summary { font-size: .875rem; }
.muted { color: var(--neu-text-muted); }
.up-to-date { color: var(--neu-success); }
.has-updates { color: var(--neu-warning); font-weight: 600; }
.checking-text { display: flex; align-items: center; gap: .4rem; color: var(--neu-text-muted); }
.package-list {
  max-height: 160px;
  overflow-y: auto;
  border-top: 1px solid var(--neu-border);
  padding-top: .5rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.package-row { display: flex; justify-content: space-between; gap: .5rem; font-size: .75rem; }
.pkg-name { font-weight: 600; font-family: monospace; color: var(--neu-primary); }
.pkg-version { display: flex; align-items: center; gap: .25rem; color: var(--neu-text-muted); }
.old-ver { text-decoration: line-through; opacity: .6; }
.arrow { color: var(--neu-primary); }
.new-ver { color: var(--neu-success); font-weight: 600; }
.output-panel { margin-top: 1.5rem; border-radius: .75rem; overflow: hidden; }
.output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--neu-border);
}
.output-title { font-weight: 600; font-size: .875rem; font-family: monospace; }
.job-status { font-size: .75rem; padding: .2rem .5rem; border-radius: .25rem; text-transform: uppercase; }
.job-status.running { background: rgba(99,102,241,.15); color: var(--neu-primary); }
.job-status.success { background: rgba(34,197,94,.15); color: var(--neu-success); }
.job-status.error { background: rgba(239,68,68,.1); color: var(--neu-danger); }
.output-content {
  padding: 1rem;
  font-family: monospace;
  font-size: .75rem;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 400px;
  overflow-y: auto;
  margin: 0;
  color: var(--neu-text);
}

/* ── Settings page ───────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: .5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--neu-border);
  padding-bottom: .5rem;
}
.tab-btn {
  padding: .5rem 1rem;
  border-radius: .375rem .375rem 0 0;
  font-size: .875rem;
  font-weight: 600;
  color: var(--neu-text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all .15s;
}
.tab-btn.active {
  color: var(--neu-primary);
  background: var(--neu-surface);
  border-bottom: 2px solid var(--neu-primary);
}
.tab-btn:hover:not(.active) { color: var(--neu-text); }
.tab-panel { animation: fadeIn .15s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.form-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  margin-bottom: 1.5rem;
}
.save-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--neu-border);
}
.save-feedback { flex: 1; }
.save-success { color: var(--neu-success); font-size: .875rem; }
.save-error { color: var(--neu-danger); font-size: .875rem; }

/* ── Modules page ────────────────────────────────────────────────────────────── */
.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}
.module-card { padding: 1rem; transition: opacity .2s; }
.module-card.disabled { opacity: .6; }
.module-header { display: flex; align-items: center; gap: .75rem; }
.module-icon { font-size: 1.75rem; flex-shrink: 0; }
.module-info { flex: 1; }
.module-name { font-weight: 700; display: block; margin-bottom: .2rem; }
.module-desc { font-size: .8rem; color: var(--neu-text-muted); display: block; }
.core-badge {
  font-size: .65rem;
  padding: .15rem .4rem;
  border-radius: .2rem;
  background: rgba(99,102,241,.15);
  color: var(--neu-primary);
  font-weight: 700;
  text-transform: uppercase;
}
.toggle-btn {
  display: flex;
  align-items: center;
  gap: .4rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--neu-text-muted);
  font-size: .8rem;
}
.toggle-btn:disabled { cursor: not-allowed; opacity: .5; }
.toggle-track {
  width: 2.5rem;
  height: 1.25rem;
  background: var(--neu-surface);
  border-radius: .625rem;
  position: relative;
  transition: background .2s;
  border: 1px solid var(--neu-border);
}
.toggle-thumb {
  position: absolute;
  top: .125rem;
  left: .125rem;
  width: .875rem;
  height: .875rem;
  background: var(--neu-text-muted);
  border-radius: 50%;
  transition: transform .2s, background .2s;
}
.toggle-btn.on .toggle-track { background: var(--neu-primary); border-color: var(--neu-primary); }
.toggle-btn.on .toggle-thumb { transform: translateX(1.25rem); background: #fff; }
.module-toggle { margin-left: auto; }

/* ── Terminal page ───────────────────────────────────────────────────────────── */
.main-layout.terminal-wrapper {
  height: 100vh;
  overflow: hidden;
}
.terminal-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 !important;
  overflow: hidden;
}
.terminal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem 1rem;
  border-bottom: 1px solid var(--neu-border);
  background: var(--neu-surface);
  flex-shrink: 0;
}
.terminal-status { font-size: .8rem; font-family: monospace; }
.terminal-status.connected { color: var(--neu-success); }
.terminal-status.disconnected,
.terminal-status.error { color: var(--neu-danger); }
.terminal-status.connecting { color: var(--neu-text-muted); }
.terminal-container {
  flex: 1;
  overflow: hidden;
  background: #1a1a2e;
  padding: .5rem;
}
.terminal-container .xterm { height: 100%; }

/* ── Auth pages (login + install) ────────────────────────────────────────────── */
.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 2rem;
}
.install-card {
  width: 100%;
  max-width: 560px;
  padding: 2rem;
}
.auth-logo { text-align: center; margin-bottom: 2rem; }
.logo-icon { font-size: 3rem; color: var(--neu-primary); }
.auth-title { font-size: 1.5rem; font-weight: 700; margin: .5rem 0 .25rem; }
.auth-subtitle { font-size: .875rem; color: var(--neu-text-muted); margin: 0; }
.auth-form { display: flex; flex-direction: column; gap: 1.25rem; }
.auth-submit { width: 100%; padding: .875rem; margin-top: .5rem; }

/* ── Install wizard ──────────────────────────────────────────────────────────── */
.stepper { display: flex; gap: .5rem; justify-content: center; margin: 1.5rem 0; }
.step { display: flex; flex-direction: column; align-items: center; gap: .25rem; flex: 1; max-width: 100px; }
.step-dot {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 2px solid var(--neu-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  transition: all .2s;
}
.step.active .step-dot { border-color: var(--neu-primary); background: var(--neu-primary); color: #fff; }
.step.done .step-dot { border-color: var(--neu-success); background: var(--neu-success); color: #fff; }
.step-label { font-size: .7rem; color: var(--neu-text-muted); text-align: center; }
.step-content { display: flex; flex-direction: column; gap: 1rem; min-height: 200px; }
.step-content h2 { margin: 0; font-size: 1.125rem; }
.step-desc { margin: 0; font-size: .875rem; color: var(--neu-text-muted); }
.step-nav { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1.5rem; }
.status-ok {
  padding: .5rem .75rem;
  border-radius: .375rem;
  background: rgba(34,197,94,.1);
  border: 1px solid var(--neu-success);
  color: var(--neu-success);
  font-size: .875rem;
}
.status-error {
  padding: .5rem .75rem;
  border-radius: .375rem;
  background: rgba(239,68,68,.1);
  border: 1px solid var(--neu-danger);
  color: var(--neu-danger);
  font-size: .875rem;
}
.confirm-summary { padding: 1rem; display: flex; flex-direction: column; gap: .5rem; border-radius: .5rem; }
.confirm-row { display: flex; gap: 1rem; font-size: .875rem; }
.confirm-label { font-weight: 600; min-width: 80px; color: var(--neu-text-muted); }

/* ── Page header ─────────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 1rem;
}
.page-title { font-size: 1.25rem; font-weight: 700; }

/* ── Dashboard widgets ───────────────────────────────────────────────────────── */
.widgets-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}
.widget {
  min-height: 160px;
  cursor: grab;
  user-select: none;
  transition: var(--neu-transition);
}
.widget:active { cursor: grabbing; }
.widget:hover { transform: translateY(-2px); }
.widget-title {
  font-size: .875rem;
  font-weight: 700;
  color: var(--neu-text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin: 0 0 .75rem 0;
}

/* Widget config panel */
.widget-config {
  margin-bottom: 1.25rem;
  padding: 1rem;
}
.widget-config-title {
  font-weight: 700;
  margin: 0 0 .75rem 0;
  font-size: .9rem;
}
.widget-config-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem .25rem;
  border-radius: .375rem;
  cursor: grab;
  transition: background .15s;
}
.widget-config-row:hover { background: rgba(108, 142, 244, 0.06); }
.widget-toggle-label {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-left: auto;
  font-size: .8rem;
  color: var(--neu-text-muted);
  cursor: pointer;
}
.drag-handle { color: var(--neu-text-muted); font-size: 1rem; }

/* Widget: status (stats) */
.stat-rows { display: flex; flex-direction: column; gap: .5rem; }
.stat-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .9rem;
}
.stat-icon { font-size: 1.1rem; width: 1.25rem; flex-shrink: 0; }
.stat-num { font-size: 1.5rem; font-weight: 700; min-width: 2rem; }
.stat-label { color: var(--neu-text-muted); }

/* Widget: lxc-list */
.lxc-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .375rem 0;
  border-bottom: 1px solid var(--neu-border);
  font-size: .85rem;
}
.lxc-row:last-child { border-bottom: none; }
.lxc-name { flex: 1; font-weight: 500; }
.lxc-cpu, .lxc-ram { color: var(--neu-text-muted); font-size: .8rem; min-width: 3.5rem; text-align: right; }

/* Widget: links */
.links-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
}
.link-btn {
  flex: 1;
  min-width: 80px;
  justify-content: center;
  gap: .375rem;
}

/* Widget edit mode */
.widget-size-2 { grid-column: span 2; }
@media (max-width: 720px) { .widget-size-2 { grid-column: span 1; } }

.widget.is-dragging { opacity: 0.35; transform: scale(.97); }
.widget.drag-over   { outline: 2px dashed var(--neu-primary); transform: scale(1.02); }

.widget-edit-bar {
  display: flex;
  align-items: center;
  gap: .375rem;
  padding: .25rem 0 .75rem;
  border-bottom: 1px solid var(--neu-border);
  margin-bottom: .75rem;
}
.widget-edit-bar-title { flex: 1; font-size: .75rem; font-weight: 600; color: var(--neu-text-muted); text-transform: uppercase; }

.edit-mode-banner {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .625rem 1rem;
  border-radius: var(--neu-radius-sm);
  background: rgba(108, 142, 244, 0.1);
  border: 1px solid var(--neu-primary);
  margin-bottom: 1.25rem;
  font-size: .875rem;
  color: var(--neu-primary);
}
.edit-mode-banner i { font-size: 1.1rem; }

.widget-add-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: 1.5rem;
}
.widget-add-btn {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem 1rem;
  border-radius: var(--neu-radius-sm);
  border: 1px dashed var(--neu-border);
  background: transparent;
  color: var(--neu-text-muted);
  cursor: pointer;
  font-size: .875rem;
  transition: all .15s;
}
.widget-add-btn:hover { border-color: var(--neu-primary); color: var(--neu-primary); }

/* ── Profil / préférences ────────────────────────────────────────────────────── */
.settings-section {
  margin-bottom: 1.25rem;
}
.settings-section h3 {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 1rem 0;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--neu-border);
}

.profile-info { display: flex; flex-direction: column; gap: .5rem; }
.profile-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: .9rem;
  padding: .375rem 0;
}
.profile-label {
  font-weight: 600;
  color: var(--neu-text-muted);
  min-width: 100px;
}
.profile-value { color: var(--neu-text); }

.badge-admin {
  background: rgba(108, 142, 244, 0.15);
  color: var(--neu-primary);
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-user {
  background: rgba(127, 136, 153, 0.15);
  color: var(--neu-text-muted);
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: .75rem;
  font-weight: 600;
}

/* Groupe de boutons (thème, sidebar position) */
.btn-group {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

/* ── Logo auth LineIcons ─────────────────────────────────────────────────────── */
.logo-icon {
  font-size: 2.5rem;
  color: var(--neu-primary);
  display: block;
  line-height: 1;
}
