/* ═══════════════════════════════════════════════════════════════
   Puppy Stardew Server - Web Panel Styles (Dark Theme)
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg-primary:    #0f1923;
  --bg-secondary:  #1a2736;
  --bg-tertiary:   #243447;
  --bg-hover:      #2a3d52;
  --bg-overlay:    rgba(74, 222, 128, 0.08);
  --accent:        #4ade80;
  --accent-dark:   #22c55e;
  --accent-warn:   #fbbf24;
  --accent-error:  #ef4444;
  --accent-info:   #38bdf8;
  --text-primary:  #e2e8f0;
  --text-secondary:#94a3b8;
  --text-muted:    #64748b;
  --border:        #2d3f52;
  --console-bg:    #0a0e14;
  --shadow-soft:   0 10px 40px rgba(0,0,0,0.4);
  --radius:        10px;
  --sidebar-w:     220px;
}

:root[data-theme='light'] {
  --bg-primary:    #eef5f0;
  --bg-secondary:  #ffffff;
  --bg-tertiary:   #edf4ee;
  --bg-hover:      #dde9df;
  --bg-overlay:    rgba(34, 197, 94, 0.12);
  --accent:        #16a34a;
  --accent-dark:   #15803d;
  --accent-warn:   #d97706;
  --accent-error:  #dc2626;
  --accent-info:   #0284c7;
  --text-primary:  #162119;
  --text-secondary:#4b6351;
  --text-muted:    #6f8374;
  --border:        #d7e4da;
  --console-bg:    #f5f8f6;
  --shadow-soft:   0 12px 30px rgba(22,33,25,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.icon-spin {
  animation: icon-spin 1.2s linear infinite;
}

@keyframes icon-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ─── Layout ──────────────────────────────────────────────────── */

#app {
  display: flex;
  min-height: 100vh;
}

#sidebar {
  width: var(--sidebar-w);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform 0.3s;
}

#content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── Sidebar ──────────���──────────────────────────────────────── */

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.logo-mark .icon { width: 100%; height: 100%; }

.logo-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}

.nav-menu {
  list-style: none;
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
  font-size: 14px;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--bg-overlay);
  color: var(--accent);
  border-left-color: var(--accent);
}

.nav-icon {
  width: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-icon .icon { width: 18px; height: 18px; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: center;
}

/* ─── Topbar ──────────────────────────────────────────────────── */

#topbar {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 50;
}

#topbar h2 { flex: 1; font-size: 18px; }

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

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 600;
}
.status-badge.online  { background: rgba(74,222,128,0.15); color: var(--accent); }
.status-badge.offline { background: rgba(239,68,68,0.15); color: var(--accent-error); }
.status-badge.checking { background: rgba(56,189,248,0.15); color: var(--accent-info); }

/* ─── Page Container ──────────────────────────────────────────── */

#page-container { padding: 24px; flex: 1; }

.page { display: none; }
.page.active { display: block; }

/* ─── Cards ───────────────────────────────────────────────────── */

.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.card h3 {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
}

.stat-icon {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.stat-icon .icon { width: 32px; height: 32px; }

.stat-value { font-size: 22px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ─── Resource Bars ───────────────────────────────────────────── */

.resource-bar { margin-bottom: 14px; }
.resource-bar:last-child { margin-bottom: 0; }

.resource-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.progress-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.progress-fill.warn { background: var(--accent-warn); }
.progress-fill.danger { background: var(--accent-error); }

/* ─── Dashboard Details ──────────────────────────────────────── */

.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.detail-item {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  min-height: 96px;
}

.detail-item-wide {
  grid-column: 1 / -1;
}

.detail-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.detail-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  word-break: break-word;
}

.detail-note {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.detail-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--text-secondary);
  font-size: 13px;
}

.detail-stats strong {
  color: var(--text-primary);
  font-size: 16px;
}

/* ─── Buttons ─────────────────────────────────────────────────── */

.btn {
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-sm { padding: 6px 12px; font-size: 12px; }

.btn .icon { width: 16px; height: 16px; }

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

.btn-success   { background: var(--accent); color: #0f1923; }
.btn-success:hover { background: var(--accent-dark); }

.btn-warning   { background: var(--accent-warn); color: #0f1923; }
.btn-warning:hover { background: #f59e0b; }
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-danger    { background: var(--accent-error); color: #fff; }
.btn-danger:hover { background: #dc2626; }

.btn-icon {
  background: none;
  border: none;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: background 0.15s;
  text-decoration: none;
}
.btn-icon:hover { background: var(--bg-hover); }

.btn-icon .icon { width: 20px; height: 20px; }

.action-buttons { display: flex; gap: 10px; flex-wrap: wrap; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-header h3 { margin-bottom: 0; }

/* ─── Logs ────────────────────────────────────────────────────── */

.logs-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.log-filters { display: flex; gap: 4px; }

.log-filter {
  padding: 5px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.log-filter:hover { color: var(--text-primary); }
.log-filter.active {
  background: rgba(74,222,128,0.15);
  color: var(--accent);
  border-color: var(--accent);
}

.log-search { flex: 1; min-width: 150px; }
.log-search input {
  width: 100%;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}
.log-search input:focus { border-color: var(--accent); }

.log-controls { display: flex; gap: 4px; }

.log-output {
  background: var(--console-bg);
  border-radius: 8px;
  padding: 12px;
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.6;
  height: 500px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.log-line { padding: 1px 0; }
.log-line.error { color: var(--accent-error); }
.log-line.warn  { color: var(--accent-warn); }
.log-line.info  { color: var(--text-secondary); }
.log-line.debug { color: var(--text-muted); }

/* ─── Terminal ────────────────────────────────────────────────── */

.terminal-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-weight: 600;
}

.terminal-output {
  background: var(--console-bg);
  border-radius: 8px;
  padding: 12px;
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.6;
  height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin-bottom: 12px;
}

.terminal-hint {
  color: var(--text-muted);
  font-style: italic;
}

.terminal-input-row {
  display: flex;
  gap: 8px;
}

.terminal-input-row input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: monospace;
  font-size: 14px;
  outline: none;
}
.terminal-input-row input:focus { border-color: var(--accent); }
.terminal-input-row input:disabled { opacity: 0.5; }

/* ─── Players ─────────────────────────────────────────────────── */

.players-list { display: flex; flex-direction: column; gap: 8px; }

.player-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border-radius: 8px;
}

.player-avatar {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.player-avatar .icon { width: 24px; height: 24px; }
.player-name { font-weight: 600; }
.player-info { font-size: 12px; color: var(--text-secondary); }

/* ─── Saves ───────────────────────────────────────────────────── */

.saves-list { display: flex; flex-direction: column; gap: 8px; }

.save-item, .backup-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border-radius: 8px;
}

.save-info { flex: 1; }
.save-name {
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.save-name-icon { width: 18px; height: 18px; }
.save-meta { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.save-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.save-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.save-upload-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--bg-secondary);
}

.save-upload-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.save-upload-hint,
.save-upload-status {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.backup-status {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-tertiary);
}

.backup-status.running {
  border-color: rgba(59, 130, 246, 0.35);
}

.backup-status.success {
  border-color: rgba(34, 197, 94, 0.35);
}

.backup-status.error {
  border-color: rgba(239, 68, 68, 0.35);
}

.backup-status-title {
  font-size: 13px;
  font-weight: 600;
}

.backup-status-meta {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.backup-status-error {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.45;
  color: #ef4444;
  white-space: pre-wrap;
}

.backup-progress {
  margin-top: 10px;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg-primary);
}

.backup-progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #f59e0b);
  transition: width 0.25s ease;
}

/* ─── Config ──────────────────────────────────────────────────── */

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

.config-group-title {
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.config-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.config-item:last-child { border-bottom: none; }

.config-label { font-size: 14px; }
.config-key { font-size: 11px; color: var(--text-muted); font-family: monospace; }
.config-help {
  margin-top: 4px;
  max-width: 420px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.config-value {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input {
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  min-width: 120px;
}
.input:focus { border-color: var(--accent); }

.form-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Toggle switch */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
}

.toggle input { display: none; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-tertiary);
  border-radius: 12px;
  cursor: pointer;
  transition: 0.3s;
  border: 1px solid var(--border);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 2px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: 0.3s;
}

.toggle input:checked + .toggle-slider { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(19px); background: #fff; }

/* ─── Mods ────────────────────────────────────────────────────── */

.mods-list { display: flex; flex-direction: column; gap: 8px; }

.mod-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border-radius: 8px;
}

.mod-info { flex: 1; }
.mod-name { font-weight: 600; font-size: 14px; }
.mod-meta { font-size: 12px; color: var(--text-secondary); margin-top: 3px; }
.mod-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(74,222,128,0.15);
  color: var(--accent);
}
.mod-badge.custom { background: rgba(56,189,248,0.15); color: var(--accent-info); }

/* ─── Toast ───────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: var(--shadow-soft);
  transition: transform 0.3s ease;
  z-index: 1000;
  max-width: 90vw;
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--accent); }
.toast.error   { border-color: var(--accent-error); }
.toast.warn    { border-color: var(--accent-warn); }

/* ─── Empty State ─────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
}

.empty-icon {
  width: 40px;
  height: 40px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ─── Mobile ──────────────────────────────────────────────────── */

.mobile-only { display: none; }

#mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 6px 0;
  z-index: 100;
  justify-content: space-around;
}

.mob-nav-item {
  background: none;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  padding: 8px;
  cursor: pointer;
  border-radius: 8px;
  opacity: 0.5;
  transition: all 0.15s;
}

.mob-nav-item .icon { width: 22px; height: 22px; }

.mob-nav-item.active {
  opacity: 1;
  background: var(--bg-overlay);
  color: var(--accent);
}

.status-dot,
.status-orb {
  border-radius: 999px;
  display: inline-flex;
  flex-shrink: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
}

.status-orb {
  width: 16px;
  height: 16px;
}

.status-dot.online,
.status-orb.online {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(74, 222, 128, 0.12);
}

.status-dot.offline,
.status-orb.offline {
  background: var(--accent-error);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12);
}

.status-dot.checking,
.status-orb.checking {
  background: transparent;
  border: 2px solid rgba(56, 189, 248, 0.25);
  border-top-color: var(--accent-info);
  animation: icon-spin 1s linear infinite;
}

@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }

  #content { margin-left: 0; padding-bottom: 70px; }

  #mobile-nav { display: flex; }
  .mobile-only { display: block; }

  .cards-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-item-wide { grid-column: auto; }
  .logs-toolbar { flex-direction: column; }
  .log-filters { flex-wrap: wrap; }
  .action-buttons { flex-direction: column; }
  .form-row { flex-direction: column; }
  .config-item { flex-direction: column; align-items: flex-start; gap: 8px; }
}

@media (max-width: 480px) {
  .cards-grid { grid-template-columns: 1fr; }
  #page-container { padding: 12px; }
}

/* ─── Scrollbar ───────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Modal ──────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modalFadeIn 0.2s ease;
}

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

.modal-dialog {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 32px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  text-align: center;
  animation: modalSlideIn 0.25s ease;
}

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

.modal-icon {
  margin-bottom: 14px;
}

.modal-dialog h3 {
  font-size: 18px;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.modal-dialog p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 22px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.modal-actions .btn {
  min-width: 100px;
}

/* ─── Password Toggle ────────────────────────────────────────── */

.password-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.password-wrapper input {
  padding-right: 36px;
}

.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s;
}

.password-toggle:hover {
  color: var(--text-primary);
}

.password-toggle .icon {
  width: 16px;
  height: 16px;
}
