/* style.css — TavernQuest dark fantasy theme */
:root {
  --bg: #1a1a2e;
  --bg-light: #232342;
  --bg-card: #2d2d52;
  --bg-hover: #353568;
  --border: #3d3d7a;
  --text: #e0e0f0;
  --text-muted: #8888bb;
  --accent: #8b5cf6;
  --accent-hover: #7c3aed;
  --accent-dim: #6d28d9;
  --green: #22c55e;
  --red: #ef4444;
  --orange: #f59e0b;
  --blue: #3b82f6;
  --radius: 10px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* Views */
.view { display: none; height: 100vh; }
.view.active { display: flex; flex-direction: column; }

/* ─── Lobby ─────────────────────────────────────────── */
#lobby {
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1a2e 0%, #2d1b4e 100%);
}

.lobby-container { text-align: center; max-width: 800px; width: 90%; }

.lobby-container h1 {
  font-size: 2.5rem; margin-bottom: 8px;
  background: linear-gradient(90deg, #8b5cf6, #ec4899);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.tagline { color: var(--text-muted); margin-bottom: 32px; }

.lobby-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.lobby-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; text-align: left;
}

.lobby-card h2 { font-size: 1.2rem; margin-bottom: 16px; color: var(--accent); }

.lobby-card input, .lobby-card textarea {
  width: 100%; margin-bottom: 12px; padding: 10px 14px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 14px;
}

.lobby-card textarea { resize: vertical; }

.campaign-list { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; }

.campaign-item {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px; cursor: pointer; transition: all 0.2s;
}

.campaign-item:hover { border-color: var(--accent); background: var(--bg-hover); }

.campaign-item h4 { margin-bottom: 4px; }
.campaign-item p { font-size: 12px; color: var(--text-muted); }

/* ─── Buttons ────────────────────────────────────────── */
.btn-primary, .btn-secondary, .btn-danger, .btn-icon, .btn-small {
  border: none; border-radius: 8px; cursor: pointer; font-size: 14px;
  padding: 10px 20px; transition: all 0.2s; font-weight: 600;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-light); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-icon { background: var(--bg-light); padding: 8px 14px; }
.btn-small { padding: 4px 10px; font-size: 12px; background: var(--bg-light); }

/* ─── Game header ───────────────────────────────────── */
.game-header {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: var(--bg-light);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}

.header-info { flex: 1; display: flex; align-items: center; gap: 12px; }
.header-info h2 { font-size: 1.2rem; }

.presence-badge {
  background: var(--bg); padding: 4px 10px; border-radius: 20px;
  font-size: 12px; color: var(--green);
}

.round-info {
  background: var(--bg); padding: 6px 16px; border-radius: 8px;
  font-weight: 600; font-size: 14px;
}

/* ─── Game layout ────────────────────────────────────── */
.game-layout {
  display: grid; grid-template-columns: 280px 1fr 340px;
  gap: 12px; padding: 12px; flex: 1; overflow: hidden;
}

/* Panels */
.panel {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; overflow-y: auto;
}

.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel h3 { font-size: 1rem; color: var(--accent); }

/* ─── Sidebar left ──────────────────────────────────── */
.sidebar-left { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }

.turn-order { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }

.turn-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; background: var(--bg);
  border: 2px solid transparent; transition: all 0.2s; cursor: pointer;
}

.turn-item.active { border-color: var(--accent); background: var(--bg-hover); box-shadow: 0 0 12px rgba(139,92,246,0.3); }
.turn-item.inactive { opacity: 0.4; }

.turn-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: white; font-size: 14px;
}

.turn-info { flex: 1; min-width: 0; }
.turn-info .name { font-weight: 600; font-size: 14px; }
.turn-info .stats { font-size: 11px; color: var(--text-muted); }

.turn-init {
  font-weight: 700; font-size: 16px; color: var(--accent);
  min-width: 28px; text-align: right;
}

.turn-controls { display: flex; gap: 8px; }
.turn-controls button { flex: 1; padding: 8px; font-size: 13px; }

/* Char form */
.char-form { display: flex; flex-direction: column; gap: 8px; }
.char-form input, .char-form select {
  padding: 8px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 13px;
}

.char-form-row { display: flex; gap: 8px; }
.char-form-row label { flex: 1; font-size: 11px; color: var(--text-muted); display: flex; flex-direction: column; gap: 4px; }
.char-form-row input { padding: 6px; }

.color-picker { width: 100%; height: 36px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); cursor: pointer; }

/* ─── Character grid (main) ────────────────────────── */
.main-content { overflow-y: auto; }

.character-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px; padding-bottom: 20px;
}

.char-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; cursor: pointer;
  transition: all 0.2s; position: relative; overflow: hidden;
}

.char-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.char-card.current-turn { border-color: var(--green); box-shadow: 0 0 16px rgba(34,197,94,0.3); }
.char-card.unconscious { opacity: 0.5; filter: grayscale(0.6); }

.char-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }

.char-card-avatar {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: white; font-size: 16px;
}

.char-card-name { font-weight: 700; font-size: 15px; }
.char-card-type { font-size: 11px; color: var(--text-muted); text-transform: uppercase; }
.char-card-type.npc { color: var(--orange); }

.char-card-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.stat-box {
  background: var(--bg); border-radius: 6px; padding: 6px 8px; text-align: center;
}

.stat-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; }
.stat-value { font-size: 18px; font-weight: 700; }
.stat-value.hp { color: var(--green); }
.stat-value.hp.low { color: var(--orange); }
.stat-value.hp.critical { color: var(--red); }
.stat-value.ac { color: var(--blue); }

.hp-bar { height: 6px; background: var(--bg); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.hp-bar-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }

.hp-controls { display: flex; gap: 4px; margin-top: 8px; }
.hp-btn {
  flex: 1; padding: 6px; font-size: 12px; border: none; border-radius: 6px;
  cursor: pointer; font-weight: 600; transition: all 0.15s;
}
.hp-btn.dmg { background: var(--red); color: white; }
.hp-btn.heal { background: var(--green); color: white; }
.hp-btn:hover { opacity: 0.85; }
.hp-btn input { width: 100%; background: rgba(0,0,0,0.3); border: none; color: white; text-align: center; font-size: 12px; border-radius: 4px; padding: 2px; }

.char-card-notes { font-size: 12px; color: var(--text-muted); margin-top: 8px; font-style: italic; }

/* ─── Chat ──────────────────────────────────────────── */
.sidebar-right { overflow: hidden; }

.chat-panel { display: flex; flex-direction: column; height: 100%; }

.chat-tabs { display: flex; gap: 4px; }
.chat-tab { padding: 4px 10px; font-size: 11px; border: none; border-radius: 6px; cursor: pointer; background: var(--bg); color: var(--text-muted); }
.chat-tab.active { background: var(--accent); color: white; }

.chat-messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 4px 0; }

.chat-msg {
  padding: 8px 12px; border-radius: 8px; font-size: 13px; word-break: break-word;
  max-width: 95%;
}

.chat-msg.system { background: rgba(139,92,246,0.1); color: var(--text-muted); font-style: italic; text-align: center; font-size: 12px; }
.chat-msg.ooc { background: var(--bg); border-left: 3px solid var(--blue); }
.chat-msg.ic { background: var(--bg); border-left: 3px solid var(--accent); }

.chat-msg .author { font-weight: 700; font-size: 12px; margin-bottom: 2px; }
.chat-msg .timestamp { font-size: 10px; color: var(--text-muted); float: right; }

.chat-input-area { padding-top: 8px; border-top: 1px solid var(--border); }

.player-name-input {
  width: 100%; padding: 6px 10px; margin-bottom: 6px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-size: 12px;
}

.chat-input-row { display: flex; gap: 6px; }
.chat-input-row input {
  flex: 1; padding: 8px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px;
}

.chat-input-row button { padding: 8px 16px; font-size: 13px; }

.typing-indicator { font-size: 11px; color: var(--text-muted); height: 16px; font-style: italic; }

/* ─── Action log ────────────────────────────────────── */
.action-log-panel {
  background: var(--bg-card); border-top: 1px solid var(--border);
  padding: 8px 14px; max-height: 120px; overflow-y: auto; flex-shrink: 0;
}

.action-log-content { font-size: 12px; color: var(--text-muted); }
.action-log-content .log-entry { padding: 2px 0; }
.action-log-content .log-entry .log-round { color: var(--accent); font-weight: 700; }

/* ─── Modal ─────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}

.modal {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; width: 90%; max-width: 440px;
}

.modal h3 { margin-bottom: 16px; color: var(--accent); }

.modal-body { display: flex; flex-direction: column; gap: 12px; }

.modal-body label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-muted); }
.modal-body input, .modal-body select, .modal-body textarea {
  padding: 8px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 14px;
}
.modal-body textarea { resize: vertical; }

.modal-row { display: flex; gap: 8px; }
.modal-row label { flex: 1; }

.modal-footer { display: flex; gap: 8px; margin-top: 20px; }
.modal-footer button { flex: 1; }
.modal-footer .btn-danger { flex: 0.5; }

/* ─── Utilities ─────────────────────────────────────── */
.muted { color: var(--text-muted); font-size: 13px; }
.center-text { text-align: center; padding: 20px; }

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

/* Responsive */
@media (max-width: 900px) {
  .game-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .sidebar-left, .sidebar-right { max-height: 200px; }
  .lobby-grid { grid-template-columns: 1fr; }
}
