/* ============================================
   ModCraft Manager — Design System
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Press+Start+2P&display=swap');

/* --- CSS Variables --- */
:root {
  --bg-primary: #0a0a14;
  --bg-secondary: #12121f;
  --bg-tertiary: #1a1a2e;
  --bg-card: rgba(26, 26, 46, 0.85);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --bg-input: rgba(255, 255, 255, 0.06);
  --accent: #00d2ff;
  --accent2: #7b2ff7;
  --accent3: #0cebeb;
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #ef4444;
  --text: #e2e8f0;
  --text2: #94a3b8;
  --text3: #64748b;
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: 
    radial-gradient(ellipse at 20% 20%, rgba(123, 47, 247, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(0, 210, 255, 0.06) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* --- Typography --- */
h1, h2, h3 { font-weight: 700; line-height: 1.3; }
.pixel-font { font-family: 'Press Start 2P', monospace; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); background: rgba(0, 210, 255, 0.1); transform: translateY(-1px); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-2px); box-shadow: 0 4px 20px rgba(0, 210, 255, 0.3); }

.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.15); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon { padding: 8px; min-width: 36px; justify-content: center; }

/* --- Inputs --- */
.input, .select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  transition: all var(--transition);
  outline: none;
}
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 210, 255, 0.1); }
.input::placeholder { color: var(--text3); }
.select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.select option { background: var(--bg-secondary); color: var(--text); }

.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-group label { font-size: 0.8rem; color: var(--text2); font-weight: 500; }

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(12px);
  transition: all var(--transition);
}
.card:hover { border-color: var(--border-hover); }

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-success { background: rgba(74, 222, 128, 0.15); color: var(--success); }
.badge-warning { background: rgba(251, 191, 36, 0.15); color: var(--warning); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-info { background: rgba(0, 210, 255, 0.15); color: var(--accent); }
.badge-purple { background: rgba(123, 47, 247, 0.15); color: var(--accent2); }
.badge-manual { background: rgba(251, 191, 36, 0.15); color: var(--warning); }

/* --- Modal --- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: modalIn 0.3s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal h2 { margin-bottom: 20px; font-size: 1.3rem; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* --- Toast --- */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.85rem;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  box-shadow: var(--shadow);
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-info { border-left: 3px solid var(--accent); }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(40px); } }

/* --- Shimmer loading --- */
.shimmer {
  background: linear-gradient(90deg, var(--bg-glass) 25%, rgba(255,255,255,0.08) 50%, var(--bg-glass) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ============================================
   LAYOUT — Setup & Room Views
   ============================================ */
.view { display: none; position: relative; z-index: 1; }
.view.active { display: flex; }

/* --- Setup & Room Selection --- */
#setup-view, #room-view {
  min-height: 100vh;
  justify-content: center;
  align-items: center;
  padding: 20px;
}
.setup-card, .room-card {
  width: 100%;
  max-width: 480px;
  text-align: center;
}
.setup-card h1, .room-card h1 {
  font-size: 1.1rem;
  margin-bottom: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.setup-card .subtitle, .room-card .subtitle { color: var(--text2); font-size: 0.85rem; margin-bottom: 24px; }
.setup-card .form-group, .room-card .form-group { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.logo-title {
  font-size: 1.8rem;
  margin-bottom: 4px;
  background: linear-gradient(135deg, var(--accent), var(--accent3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.room-options { display: flex; flex-direction: column; gap: 16px; margin-top: 8px; }
.room-option-card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-glass);
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
}
.room-option-card:hover { border-color: var(--accent); background: rgba(0, 210, 255, 0.05); transform: translateY(-2px); }
.room-option-card h3 { font-size: 1rem; margin-bottom: 4px; }
.room-option-card p { font-size: 0.8rem; color: var(--text2); }

.room-code-display {
  font-family: 'Press Start 2P', monospace;
  font-size: 2rem;
  letter-spacing: 8px;
  color: var(--accent);
  padding: 20px;
  background: var(--bg-glass);
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  margin: 16px 0;
  cursor: pointer;
  transition: all var(--transition);
}
.room-code-display:hover { background: rgba(0, 210, 255, 0.1); }

/* ============================================
   LAYOUT — Main App
   ============================================ */
#main-view {
  flex-direction: column;
  min-height: 100vh;
}

/* --- Header --- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-wrap: wrap;
  gap: 12px;
}
.header-left { display: flex; align-items: center; gap: 16px; }
.header-logo { font-size: 0.85rem; font-weight: 800; background: linear-gradient(135deg, var(--accent), var(--accent2)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.header-room {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  background: var(--bg-glass);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--text2);
}
.header-room .code { color: var(--accent); font-weight: 700; cursor: pointer; }
.server-info { display: flex; gap: 8px; }
.header-right { display: flex; align-items: center; gap: 10px; }
.user-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: rgba(123, 47, 247, 0.15);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--accent2);
  font-weight: 600;
}

/* --- Main Content --- */
.app-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  flex: 1;
  min-height: 0;
}

/* --- Panels --- */
.panel {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
  overflow: hidden;
}
.panel:first-child { border-right: 1px solid var(--border); }
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.panel-header h2 { font-size: 0.95rem; display: flex; align-items: center; gap: 8px; }
.panel-header .count { font-size: 0.75rem; color: var(--text3); font-weight: 400; }
.panel-body { flex: 1; overflow-y: auto; padding: 16px 20px; }

/* --- Search Area --- */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.search-bar .input { flex: 1; }
.filters-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filters-row .select { flex: 1; min-width: 120px; font-size: 0.8rem; padding: 8px 12px; }

/* --- Mod Cards (Search Results) --- */
.mod-result {
  display: flex;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  background: var(--bg-glass);
  transition: all var(--transition);
  animation: fadeInUp 0.3s ease;
  cursor: default;
}
.mod-result:hover { border-color: var(--border-hover); background: rgba(255,255,255,0.03); }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(8px); } }

.mod-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-tertiary);
}
.mod-info { flex: 1; min-width: 0; }
.mod-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 3px; display: flex; align-items: center; gap: 6px; }
.mod-desc { font-size: 0.78rem; color: var(--text2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 6px; }
.mod-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mod-meta span { font-size: 0.7rem; color: var(--text3); display: flex; align-items: center; gap: 3px; }
.mod-actions { display: flex; align-items: flex-start; flex-shrink: 0; }

/* --- Mod List Items --- */
.modlist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--bg-glass);
  transition: all var(--transition);
  animation: fadeInUp 0.3s ease;
}
.modlist-item:hover { border-color: var(--border-hover); }
.modlist-item.has-issue { border-color: rgba(239, 68, 68, 0.3); }
.modlist-item.has-warning { border-color: rgba(251, 191, 36, 0.3); }

.modlist-icon { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; flex-shrink: 0; background: var(--bg-tertiary); }
.modlist-info { flex: 1; min-width: 0; }
.modlist-name { font-weight: 600; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.modlist-detail { font-size: 0.72rem; color: var(--text3); }
.modlist-votes {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.vote-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  transition: all var(--transition);
}
.vote-btn:hover { border-color: var(--accent); color: var(--accent); }
.vote-btn.active-up { background: rgba(74, 222, 128, 0.2); border-color: var(--success); color: var(--success); }
.vote-btn.active-down { background: rgba(239, 68, 68, 0.2); border-color: var(--danger); color: var(--danger); }
.vote-count { font-size: 0.75rem; font-weight: 700; min-width: 20px; text-align: center; }
.vote-count.positive { color: var(--success); }
.vote-count.negative { color: var(--danger); }
.vote-count.neutral { color: var(--text3); }

.modlist-remove {
  width: 28px; height: 28px;
  border: none; background: transparent;
  color: var(--text3); cursor: pointer;
  border-radius: 6px; font-size: 1rem;
  transition: all var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.modlist-remove:hover { color: var(--danger); background: rgba(239, 68, 68, 0.1); }

/* --- Compatibility Bar --- */
.compat-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  flex-wrap: wrap;
}
.compat-item { display: flex; align-items: center; gap: 5px; }
.compat-dot { width: 8px; height: 8px; border-radius: 50%; }
.compat-dot.green { background: var(--success); }
.compat-dot.yellow { background: var(--warning); }
.compat-dot.red { background: var(--danger); }
.compat-details-btn { margin-left: auto; }

/* --- Empty States --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  color: var(--text3);
  text-align: center;
}
.empty-state .icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { font-size: 0.85rem; }

/* --- Loading --- */
.loading-spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Manual Entry Btn --- */
.manual-entry-btn {
  width: 100%;
  padding: 14px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text2);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
  margin-top: 8px;
}
.manual-entry-btn:hover { border-color: var(--warning); color: var(--warning); background: rgba(251, 191, 36, 0.05); }

/* --- Compat Modal List --- */
.compat-issue {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.compat-issue:last-child { border-bottom: none; }
.compat-issue .icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.compat-issue .msg { color: var(--text2); }
.compat-issue .mod-name { color: var(--text); font-weight: 600; }

/* --- Responsive --- */
@media (max-width: 900px) {
  .app-content { grid-template-columns: 1fr; }
  .panel { height: auto; min-height: 50vh; }
  .panel:first-child { border-right: none; border-bottom: 1px solid var(--border); }
  .filters-row { flex-direction: column; }
}
@media (max-width: 600px) {
  .app-header { padding: 10px 14px; }
  .header-left, .header-right { width: 100%; justify-content: center; }
  .panel-body { padding: 12px; }
}
