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

:root {
  --bg:         #0f1117;
  --surface:    #1a1d27;
  --border:     #2a2d3a;
  --primary:    #7c6af5;
  --primary-h:  #9d8fff;
  --text:       #e2e4f0;
  --muted:      #8c90a8;
  --danger:     #f04444;
  --success:    #34c472;
  --radius:     10px;
  --shadow:     0 4px 24px rgba(0,0,0,.45);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-h); text-decoration: underline; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ─── Header ───────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
  gap: 12px;
}
.logo { font-size: 1.25rem; font-weight: 700; color: var(--text); letter-spacing: -.01em; }
.logo:hover { text-decoration: none; color: var(--primary-h); }
.header-nav { display: flex; align-items: center; gap: 8px; }

/* ─── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-outline  { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .85; }
.btn-sm       { padding: 5px 12px; font-size: .82rem; }
.full-width   { width: 100%; margin-top: 8px; }

/* ─── Search bar ───────────────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 24px 0 16px;
}
.search-bar input,
.search-bar select {
  flex: 1 1 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 14px;
  border-radius: var(--radius);
  font-size: .92rem;
  outline: none;
}
.search-bar input:focus,
.search-bar select:focus { border-color: var(--primary); }

/* ─── Plugin grid ──────────────────────────────────────────────────────────── */
.plugin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding-bottom: 24px;
}
.plugin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
}
.plugin-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.plugin-card h3 { font-size: 1.05rem; font-weight: 700; }
.plugin-card .author { color: var(--muted); font-size: .85rem; }
.plugin-card .desc {
  color: var(--muted);
  font-size: .88rem;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  flex: 1;
}
.tag-list { display: flex; flex-wrap: wrap; gap: 5px; }
.tag {
  background: rgba(124,106,245,.15);
  color: var(--primary-h);
  border-radius: 5px;
  padding: 2px 8px;
  font-size: .78rem;
  font-weight: 600;
}
.platform-badges { display: flex; gap: 5px; }
.badge {
  font-size: .75rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--border);
}
.badge-esp32   { background: #1e3a5f; color: #6bb8ff; }
.badge-esp8266 { background: #1f3d24; color: #5dd27a; }
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .8rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ─── Plugin detail ────────────────────────────────────────────────────────── */
#pluginDetail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  margin-bottom: 32px;
}
#pluginDetail h2 { font-size: 1.5rem; margin-bottom: 6px; }
#pluginDetail .meta { color: var(--muted); margin-bottom: 16px; font-size: .9rem; }
#pluginDetail .desc-full { margin: 16px 0; line-height: 1.7; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.lamp-input { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.lamp-input input {
  flex: 1 1 200px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: .9rem;
}

/* ─── Pagination ───────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 16px 0 32px;
}
.pagination button {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: .85rem;
}
.pagination button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination button:hover:not(.active) { border-color: var(--primary); color: var(--primary); }

/* ─── Modals ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
  position: relative;
}
.modal h2 { margin-bottom: 20px; font-size: 1.2rem; }
.modal label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
  font-size: .9rem;
  color: var(--muted);
}
.modal input,
.modal textarea,
.modal select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: .92rem;
  outline: none;
  width: 100%;
  font-family: inherit;
}
.modal input:focus,
.modal textarea:focus { border-color: var(--primary); }
.modal-footer { margin-top: 14px; font-size: .85rem; color: var(--muted); text-align: center; }

.modal-close-btn {
  position: fixed;
  top: 18px;
  right: 22px;
  z-index: 300;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ─── Form feedback ────────────────────────────────────────────────────────── */
.form-error   { color: var(--danger);  font-size: .85rem; padding: 8px 0; }
.form-success { color: var(--success); font-size: .85rem; padding: 8px 0; }

/* ─── User info strip ──────────────────────────────────────────────────────── */
.user-info { display: flex; align-items: center; gap: 8px; }
#userName { font-weight: 600; }

/* ─── Loading / empty states ───────────────────────────────────────────────── */
.loading, .empty-state {
  text-align: center;
  color: var(--muted);
  padding: 60px 0;
  font-size: 1.05rem;
}

/* ─── Utility ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 540px) {
  .modal { padding: 24px 18px; }
  .plugin-grid { grid-template-columns: 1fr; }
}
