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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  line-height: 1.5;
}

/* --- Header --- */
header {
  background: #1a1a2e;
  color: #fff;
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
header h1 { font-size: 1.2rem; font-weight: 600; }

/* --- Main --- */
main { max-width: 900px; margin: 1.5rem auto; padding: 0 1rem; }

/* --- Card --- */
.card {
  background: #fff;
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.card h2 { font-size: 1rem; margin-bottom: 0.75rem; color: #333; }

/* --- Buttons --- */
.btn {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  color: #333;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
.btn:hover { background: #f5f5f5; }
.btn-primary { background: #1a1a2e; color: #fff; border-color: #1a1a2e; }
.btn-primary:hover { background: #2d2d44; }
.btn-danger { color: #c0392b; border-color: #e6b0aa; }
.btn-danger:hover { background: #fdf2f2; }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.8rem; }
.btn-blue { background: #2196f3; color: #fff; border-color: #2196f3; }
.btn-blue:hover { background: #1976d2; }
.btn-full { width: 100%; }
.btn-preview { background: #e8f5e9; color: #2e7d32; border-color: #c8e6c9; }
.btn-preview:hover { background: #c8e6c9; }

/* --- Forms --- */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 0.3rem; }
input[type="text"], input[type="password"], input[type="file"] {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
}
input:focus { outline: none; border-color: #1a1a2e; }

.inline-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.inline-form input { flex: 1; }

/* --- Error --- */
.error { color: #c0392b; font-size: 0.85rem; margin-top: 0.5rem; }

/* --- Status Dot --- */
.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: middle;
}
.dot-green { background: #27ae60; }
.dot-yellow { background: #f39c12; }

/* --- Sites List --- */
.sites-list { display: flex; flex-direction: column; gap: 0.5rem; }
.site-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid #f0f0f0;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.site-row:last-child { border-bottom: none; }
.site-info { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.site-actions { display: flex; gap: 0.3rem; flex-wrap: wrap; }

/* --- IP List --- */
.ip-list { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.3rem; }
.ip-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0;
}
.ip-row code { font-size: 0.85rem; background: #f5f5f5; padding: 0.15rem 0.4rem; border-radius: 3px; }

/* --- Modal --- */
.modal[hidden] { display: none; }
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-content {
  background: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.modal-header h3 { font-size: 1rem; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #999;
  line-height: 1;
}
.modal-close:hover { color: #333; }

/* --- Modal Nav --- */
.modal-nav {
  display: flex;
  gap: 0.4rem;
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid #eee;
  flex-wrap: wrap;
}

/* --- Progress Bar --- */
.progress {
  background: #eee;
  border-radius: 4px;
  overflow: hidden;
  height: 24px;
  margin: 0.75rem 0;
}
.progress-bar {
  height: 100%;
  background: #1a1a2e;
  color: #fff;
  font-size: 0.75rem;
  line-height: 24px;
  text-align: center;
  transition: width 0.2s;
  width: 0%;
}

/* --- Backup List --- */
.backup-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid #f0f0f0;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.backup-row:last-child { border-bottom: none; }

/* --- Site Panel (replaces details modal) --- */
.site-panel[hidden] { display: none; }
.site-panel {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.site-panel-inner {
  background: #fff;
  border-radius: 10px;
  width: 95%;
  max-width: 1200px;
  height: 85vh;
  display: flex;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

/* Sidebar */
.site-panel-sidebar {
  width: 180px;
  min-width: 180px;
  background: #f8f9fa;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
}
.site-panel-sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid #e0e0e0;
}
.site-panel-sidebar-header h3 {
  font-size: 0.9rem;
  word-break: break-all;
  margin-bottom: 0.25rem;
}
.sidebar-nav { flex: 1; padding: 0.5rem 0; }
.sidebar-item {
  display: block;
  width: 100%;
  padding: 0.55rem 1rem;
  border: none;
  background: none;
  text-align: left;
  font-size: 0.85rem;
  color: #555;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.sidebar-item:hover { background: #eee; color: #1a1a2e; }
.sidebar-item.active {
  background: #fff;
  color: #1a1a2e;
  font-weight: 600;
  border-left-color: #1a1a2e;
}

/* Main content area */
.site-panel-main {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
  position: relative;
}
.site-panel-close {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #999;
  line-height: 1;
  z-index: 1;
}
.site-panel-close:hover { color: #333; }

/* --- File Tree --- */
.file-tree {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.75rem;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  background: #fff;
}
.file-tree-item {
  display: flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  border-bottom: 1px solid #f5f5f5;
  white-space: nowrap;
}
.file-tree-item:hover { background: #f0f4ff; }
.file-tree-item.selected { background: #e3f2fd; }
.file-tree-toggle {
  display: inline-block;
  width: 1em;
  text-align: center;
  margin-right: 0.2rem;
  user-select: none;
  font-size: 0.65rem;
  color: #888;
}
.file-tree-name { flex: 1; }
.file-tree-name.dir-name { color: #1565c0; font-weight: 500; }
.file-tree-size { color: #888; margin-left: 0.5rem; }

/* --- File Editor / Viewer --- */
.file-editor {
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  margin-top: 0.75rem;
  overflow: hidden;
}
.file-editor-header {
  background: #f8f9fa;
  padding: 0.4rem 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e0e0e0;
  font-size: 0.8rem;
}
.file-editor-header .file-path {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-weight: 500;
}
.file-editor-actions { display: flex; gap: 0.3rem; }
.file-editor textarea {
  width: 100%;
  min-height: 300px;
  padding: 0.75rem;
  border: none;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  resize: vertical;
  background: #fff;
  color: #1a1a2e;
}
.file-editor textarea:focus { outline: none; }
.file-editor textarea[readonly] { background: #fafafa; color: #555; }
.file-editor-binary {
  padding: 2rem;
  text-align: center;
  color: #888;
  font-size: 0.85rem;
}

/* --- Config Viewer (nginx conf) --- */
.config-viewer {
  background: #1a1a2e;
  color: #e0e0e0;
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  max-height: 350px;
  overflow-y: auto;
}
.config-viewer pre {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
}

/* --- Upload Section --- */
.upload-section {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.upload-box {
  flex: 1;
  min-width: 220px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 1rem;
  background: #fafafa;
}
.upload-box h4 {
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  color: #333;
}

/* Folder selection info card */
.folder-info {
  background: #e8f5e9;
  border: 1px solid #c8e6c9;
  border-radius: 5px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  line-height: 1.5;
  color: #2e7d32;
}
.folder-info strong {
  font-size: 0.85rem;
  color: #1b5e20;
}

/* --- SEO Indicators --- */
.seo-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.seo-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
}
.seo-present { background: #e8f5e9; color: #2e7d32; }
.seo-missing { background: #fce4ec; color: #c62828; }

/* --- Deploy History --- */
.deploy-history {
  max-height: 200px;
  overflow-y: auto;
}
.deploy-history-item {
  padding: 0.3rem 0;
  font-size: 0.8rem;
  color: #555;
  border-bottom: 1px solid #f5f5f5;
}

.status-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-weight: 500;
  vertical-align: middle;
  text-transform: capitalize;
}
.badge-green { background: #e8f5e9; color: #2e7d32; }
.badge-yellow { background: #fff8e1; color: #f57f17; }

.stats-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.stat-card {
  flex: 1;
  background: #f8f9fa;
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  text-align: center;
}
.stat-value { font-size: 0.95rem; font-weight: 600; color: #1a1a2e; }
.stat-label { font-size: 0.7rem; color: #888; margin-top: 0.15rem; }

.details-section {
  margin-bottom: 1rem;
}
.details-section h4 {
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid #eee;
  padding-bottom: 0.3rem;
}

.file-list {
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 4px;
}
.file-row {
  display: flex;
  justify-content: space-between;
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  border-bottom: 1px solid #f5f5f5;
}
.file-row:last-child { border-bottom: none; }
.file-dir span:first-child { color: #1565c0; font-weight: 500; }
.file-file span:first-child { color: #333; }

.site-domain-link {
  font-weight: 600;
  color: #1a1a2e;
  text-decoration: none;
  cursor: pointer;
}
.site-domain-link:hover {
  text-decoration: underline;
  color: #1565c0;
}

/* --- Confirmation Modals --- */
.modal-content-sm { max-width: 400px; }
.confirm-msg { margin-bottom: 1rem; font-size: 0.9rem; line-height: 1.5; }
.confirm-warning {
  background: #fdf2f2;
  border: 1px solid #e6b0aa;
  color: #c0392b;
  border-radius: 4px;
  padding: 0.6rem 0.8rem;
  font-size: 0.82rem;
  margin-bottom: 1rem;
  line-height: 1.4;
}
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* --- Utility --- */
.muted { color: #888; font-size: 0.8rem; }

/* --- Login Page --- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-card {
  background: #fff;
  border-radius: 8px;
  padding: 2rem;
  width: 90%;
  max-width: 360px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.login-card h1 {
  text-align: center;
  font-size: 1.3rem;
  margin-bottom: 1.5rem;
  color: #1a1a2e;
}

/* --- SSL Badge & Button --- */
.ssl-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  border-radius: 10px;
  font-weight: 600;
  background: #e3f2fd;
  color: #1565c0;
  vertical-align: middle;
}
.btn-ssl { background: #e3f2fd; color: #1565c0; border-color: #bbdefb; }
.btn-ssl:hover { background: #bbdefb; }

/* --- Toast notifications --- */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 380px;
}
.toast {
  background: #fff;
  border-radius: 6px;
  padding: 0.7rem 1rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  border-left: 4px solid #888;
  opacity: 0;
  transform: translateX(40px);
  transition: opacity 0.3s, transform 0.3s;
}
.toast.toast-show { opacity: 1; transform: translateX(0); }
.toast-error { border-left-color: #c0392b; }
.toast-success { border-left-color: #27ae60; }
.toast-info { border-left-color: #1a1a2e; }
.toast-msg { flex: 1; }
.toast-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #999;
  line-height: 1;
  padding: 0;
}
.toast-close:hover { color: #333; }

/* --- Upload overlay --- */
.upload-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.upload-overlay-inner {
  background: #fff;
  border-radius: 10px;
  padding: 2rem;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.upload-overlay-title {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}
.upload-overlay-status {
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 0.25rem;
}
.upload-status-ok { color: #27ae60; font-weight: 600; }
.upload-status-err { color: #c0392b; font-weight: 600; }
.upload-overlay-files {
  max-height: 180px;
  overflow-y: auto;
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.72rem;
  color: #666;
  line-height: 1.6;
  margin-top: 0.5rem;
}
.upload-overlay-error {
  background: #fdf2f2;
  border: 1px solid #e6b0aa;
  color: #c0392b;
  border-radius: 4px;
  padding: 0.6rem 0.8rem;
  font-size: 0.82rem;
  margin-top: 0.75rem;
}
