/* ==========================================================
   StrataVote - shared stylesheet
   Mobile-first: base styles target small screens, then we
   scale up with min-width media queries.
   ========================================================== */

:root {
  --bg: #0f1115;
  --bg-elevated: #161922;
  --bg-card: #1b1f2a;
  --border: #2a2f3d;
  --text: #e9ecf1;
  --text-dim: #9aa3b2;
  --brand: #5ee06a;         /* Minecraft-grass green accent */
  --brand-dark: #3fb44d;
  --accent: #7c8cff;        /* secondary accent (links, owner UI) */
  --danger: #ff5d6c;
  --warning: #ffb84d;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 18px rgba(0,0,0,.35);
  --max-width: 1160px;
  font-size: 16px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

img { max-width: 100%; display: block; }

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------------- Header / Nav ---------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(15,17,21,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  max-width: var(--max-width);
  margin: 0 auto;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text);
}
.nav-brand span { color: var(--brand); }

.nav-toggle {
  display: inline-flex;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 10px;
  font-size: 1.1rem;
}

.nav-links {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-direction: column;
  padding: 8px 16px 16px;
  gap: 4px;
}
.nav-links.open { display: flex; }
.nav-links a, .nav-links button {
  padding: 12px 8px;
  border-radius: var(--radius-sm);
  color: var(--text);
  background: none;
  border: none;
  text-align: left;
  font-size: 1rem;
  width: 100%;
}
.nav-links a:hover, .nav-links button:hover { background: var(--bg-card); text-decoration: none; }

@media (min-width: 820px) {
  .nav-toggle { display: none; }
  .nav-links {
    display: flex !important;
    position: static;
    flex-direction: row;
    background: none;
    border: none;
    padding: 0;
    gap: 6px;
    width: auto;
  }
  .nav-links a, .nav-links button { width: auto; }
}

/* ---------------- Buttons ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform .05s ease, filter .15s ease;
  min-height: 44px; /* touch target */
}
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--brand); color: #0b1a0d; }
.btn-primary:hover { filter: brightness(1.08); text-decoration: none; }
.btn-secondary { background: var(--bg-card); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--accent); text-decoration: none; }
.btn-danger { background: var(--danger); color: #2a0507; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: .85rem; min-height: 36px; }

/* ---------------- Cards / layout ---------------- */

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

.page-title { font-size: 1.6rem; margin: 20px 0 6px; }
.page-subtitle { color: var(--text-dim); margin: 0 0 20px; }

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}
@media (min-width: 700px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 980px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}

/* ---------------- Server list ---------------- */

.server-list { display: flex; flex-direction: column; gap: 12px; margin: 16px 0 40px; }

.server-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  position: relative;
}
.server-card.featured { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset; }

.server-rank {
  font-weight: 800;
  color: var(--text-dim);
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.server-icon {
  width: 56px; height: 56px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  object-fit: cover;
  flex-shrink: 0;
}

.server-info { flex: 1 1 200px; min-width: 0; }
.server-info h3 { margin: 0 0 2px; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.server-info p { margin: 0; color: var(--text-dim); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 3px 8px;
  border-radius: 100px;
  background: var(--bg-elevated);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.badge-featured { background: rgba(94,224,106,.15); color: var(--brand); border-color: var(--brand); }

.server-stats { text-align: right; flex-shrink: 0; min-width: 76px; }
.server-stats .votes { font-size: 1.3rem; font-weight: 800; color: var(--brand); line-height: 1; }
.server-stats .label { font-size: .72rem; color: var(--text-dim); }

.server-actions { flex-basis: 100%; display: flex; gap: 8px; margin-top: 4px; }
@media (min-width: 700px) {
  .server-actions { flex-basis: auto; margin-top: 0; }
}

/* ---------------- Forms ---------------- */

.field { margin-bottom: 16px; }
.field label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; color: var(--text-dim); }
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 12px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.field small { display: block; color: var(--text-dim); margin-top: 4px; font-size: .78rem; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row .field { flex: 1 1 160px; }

.form-error { background: rgba(255,93,108,.12); border: 1px solid var(--danger); color: #ffb3ba; padding: 10px 12px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: .9rem; }
.form-success { background: rgba(94,224,106,.12); border: 1px solid var(--brand); color: var(--brand); padding: 10px 12px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: .9rem; }

/* ---------------- Tables (admin/dashboards) ---------------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 560px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-dim); font-weight: 600; font-size: .8rem; text-transform: uppercase; }

/* ---------------- Modal ---------------- */

.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 100;
  align-items: flex-end;
  justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 480px;
  padding: 20px;
  max-height: 90vh;
  overflow-y: auto;
}
@media (min-width: 600px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: var(--radius); }
}
.modal-close { float: right; background: none; border: none; color: var(--text-dim); font-size: 1.4rem; cursor: pointer; line-height: 1; }

/* ---------------- Tabs (dashboards) ---------------- */

.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 16px 0; border-bottom: 1px solid var(--border); }
.tab-btn {
  background: none; border: none; color: var(--text-dim);
  padding: 10px 14px; font-weight: 600; cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab-btn.active { color: var(--text); border-color: var(--brand); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------------- Misc ---------------- */

.hero {
  padding: 40px 0 24px;
  text-align: center;
}
.hero h1 { font-size: 1.9rem; margin: 0 0 8px; }
.hero p { color: var(--text-dim); max-width: 560px; margin: 0 auto; }
@media (min-width: 700px) {
  .hero h1 { font-size: 2.4rem; }
}

.search-bar { display: flex; gap: 8px; margin: 20px 0; }
.search-bar input { flex: 1; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-dim); }

.footer { border-top: 1px solid var(--border); margin-top: 60px; padding: 24px 0; color: var(--text-dim); font-size: .85rem; text-align: center; }

.text-dim { color: var(--text-dim); }
.mt-0 { margin-top: 0; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.icon-preview, .banner-preview {
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  background: var(--bg-elevated);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: .8rem;
  overflow: hidden;
}
.icon-preview { width: 80px; height: 80px; }
.banner-preview { width: 100%; max-width: 468px; height: 60px; }

.toast-container { position: fixed; bottom: 16px; left: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text);
  padding: 12px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow);
  max-width: 480px; width: 100%; font-size: .9rem;
}
.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--brand); }
