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

:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-card-hover: #22263a;
  --border: #2a2e3e;
  --text: #e4e6eb;
  --text-muted: #8b8fa3;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --danger: #ef4444;
  --danger-hover: #f87171;
  --success: #22c55e;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

/* Landing page */
.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  text-align: center;
}

.landing h1 {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.landing p {
  font-size: 1.2rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  max-width: 500px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.75rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}

/* Navbar */
.navbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.75rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.navbar-brand {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.navbar-brand:hover {
  color: var(--accent);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Dashboard layout */
.dashboard {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.dashboard-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
}

/* Upload zone */
.upload-section {
  margin-bottom: 2.5rem;
}

.upload-section h2 {
  font-size: 1.2rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
  font-weight: 500;
}

.upload-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.upload-namespace-row {
  margin-bottom: 1rem;
}

.upload-namespace-row input {
  width: 100%;
  padding: 0.65rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}

.upload-namespace-row input:focus {
  border-color: var(--accent);
}

.upload-namespace-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.upload-name-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.upload-name-row input {
  flex: 1;
  padding: 0.65rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}

.upload-name-row input:focus,
.upload-tags-row input:focus {
  border-color: var(--accent);
}

.upload-tags-row {
  margin-bottom: 1rem;
}

.upload-tags-row input {
  width: 100%;
  padding: 0.65rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}

.upload-description-row {
  margin-bottom: 1rem;
}

.upload-description-row input {
  width: 100%;
  padding: 0.65rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}

.upload-visibility-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.5rem;
  margin-bottom: 1rem;
}

.upload-visibility-row .visibility-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-size: 0.95rem;
}

.upload-visibility-row .visibility-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.replace-confirm {
  margin-bottom: 1rem;
  padding: 1rem;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
}

.replace-warning {
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.replace-confirm input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
}

.replace-confirm input:focus {
  outline: none;
  border-color: var(--danger);
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 2.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.05);
  color: var(--text);
}

.dropzone p {
  margin-bottom: 0.5rem;
}

.dropzone .hint {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.upload-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.upload-progress {
  display: none;
  margin-top: 1rem;
}

.upload-progress.active {
  display: block;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s;
  width: 0%;
}

.upload-status {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* Sites grid */
.sites-section h2 {
  font-size: 1.2rem;
  color: var(--text-muted);
  font-weight: 500;
  margin: 0 0 0.75rem 0;
}

.sites-section .tag-filters {
  margin-bottom: 0.75rem;
}

.sites-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.sites-filters input[type="text"] {
  padding: 0.5rem 0.75rem;
  min-width: 200px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

.sites-filters input[type="text"]:focus {
  border-color: var(--accent);
}

.sites-filters input[type="text"]::placeholder {
  color: var(--text-muted);
}

.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag-filter {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.tag-filter:hover {
  border-color: var(--accent);
  color: var(--text);
}

.tag-filter.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.namespace-header {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.namespace-header:first-child {
  margin-top: 0;
}

.sites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

/* Site card - redesigned */
.site-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.site-card:hover {
  border-color: var(--border);
  background: var(--bg-card-hover);
}

.site-card__header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.site-card__title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.site-card__title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.3;
}

.site-card__open {
  flex-shrink: 0;
}

.site-card__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.site-card__meta-sep {
  color: var(--border);
  user-select: none;
}

.site-card__author {
  font-style: italic;
}

.site-card__path {
  font-size: 0.75rem;
  font-family: ui-monospace, monospace;
  color: var(--text-muted);
  opacity: 0.9;
}

.site-description {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.site-card__description-placeholder {
  font-size: 0.9rem;
  color: var(--text-muted);
  opacity: 0.7;
  font-style: italic;
}

.site-card__edit-input,
.site-card__edit-textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font);
  margin-bottom: 0.5rem;
  outline: none;
  transition: border-color 0.15s;
}

.site-card__edit-input:focus,
.site-card__edit-textarea:focus {
  border-color: var(--accent);
}

.site-card__edit-textarea {
  resize: vertical;
  min-height: 4rem;
}

.site-card__edit-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.site-visibility-badge {
  display: inline-block;
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.site-visibility-badge.private {
  background: rgba(139, 143, 163, 0.15);
  color: var(--text-muted);
}

.site-visibility-badge.public {
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent);
}

.site-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.site-tag {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  background: rgba(139, 143, 163, 0.15);
  border-radius: 4px;
  color: var(--text-muted);
}

/* Card actions - grouped */
.site-card__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.site-card__action-group {
  display: flex;
  gap: 0.35rem;
}

.site-card__settings {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
}

.site-card__settings-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.site-card__delete {
  margin-left: auto;
  color: var(--text-muted);
  border-color: transparent;
}

.site-card__delete:hover {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.08);
}

.site-link {
  font-size: 0.85rem;
  color: var(--accent);
}

/* Toggle switch */
.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
}

.toggle-input,
.visibility-toggle {
  display: none;
}

.toggle-switch {
  width: 36px;
  height: 20px;
  background: var(--border);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--text);
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-input:checked + .toggle-switch,
.visibility-toggle:checked + .toggle-switch {
  background: var(--accent);
}

.toggle-input:checked + .toggle-switch::after,
.visibility-toggle:checked + .toggle-switch::after {
  transform: translateX(16px);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state p {
  font-size: 1.1rem;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.3s ease;
}

.toast.success {
  border-color: var(--success);
}

.toast.error {
  border-color: var(--danger);
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* htmx transitions */
.htmx-swapping {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.htmx-settling {
  opacity: 1;
  transition: opacity 0.3s ease;
}

/* Hidden file inputs */
.hidden {
  display: none;
}

/* Footer - always present */
.sss-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 99998;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  font-family: var(--font);
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

body.sss-has-footer {
  padding-bottom: 40px !important;
}
