/* ===============================
   Global Theme Variables
   =============================== */
:root {
  --bg: #111216;
  --panel: #1f1f24;
  --panel-2: #2a2a2f;
  --muted: #9aa0a6;
  --accent: #ffb62b;
  --text: #e6e7e8;
  --box: #33363b;

  --radius: 10px;
  --shadow: 0 6px 14px rgba(0, 0, 0, 0.6);
}

/* ===============================
   Base
   =============================== */
html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: Inter, Arial, Helvetica, sans-serif;
  background: linear-gradient(180deg, #0f1113 0%, #141416 100%);
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  box-sizing: border-box;
}

/* ===============================
   Header
   =============================== */
header.app-header {
  background: linear-gradient(90deg, #121416 0%, #1c1f24 100%);
  border-radius: var(--radius);
  padding: 14px 18px;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6),
    inset 0 -1px 0 rgba(255, 255, 255, 0.02);
}

/* ===============================
   Sections & Panels
   =============================== */
.section {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.03);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

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

.sections.horizontal {
  flex-direction: row;
  gap: 12px;
}

.sections.horizontal .section {
  flex: 1 1 0;
  min-width: 0;
}

.roll-area {
  display: flex;            /* use flexbox */
  flex-direction: column;   /* stack vertically */
  align-items: center;      /* center horizontally */
  gap: 12px;                /* space between button and result */
  margin-top: 16px;         /* optional spacing from above */
}

.roll-area button {
  align-self: center; /* centers the button in the flex container */
}

/* ===============================
   Forms & Controls
   =============================== */
.input-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
  align-items: center;
  margin-top: 6px;
}

.input-grid label {
  color: #b0b5bb;
  font-size: 16px;
}

input[type="number"],
select {
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background: var(--panel-2);
  border: 1px solid var(--box);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
  text-align: center;
  text-align-last: center;
  padding: 6px 8px;
  width: 45px;
  max-width: 100%;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}

.wide-select {
  width: 100px; /* enough for 'Player / NPC' */
}

input[type="checkbox"] {
  width: 24px;
  height: 24px;
  cursor: pointer;
}

/* ===============================
   Buttons
   =============================== */
button {
  padding: 12px 20px;
  margin-top: 16px;
  font-size: 1.1rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, #2b2d30, #232428);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  align-self:flex-start;
}

button:hover {
  filter: brightness(1.06);
}

/* ===============================
   Utility
   =============================== */
hr.sep {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  margin: 8px 0;
}

/* Standard results text */
  .results {
  font-size: 14px;
  line-height: 1.4;
}

#dice-selectors label {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
  color: var(--text);
}

#dice-selectors {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20px, 1fr)); /* MIN SPACE BETWEEN ITEMS */
  gap: 16px;
  margin-bottom: 16px;
}

.die-control {
  display: flex;
  flex-direction: column;
  align-items: center; /* centers label & select horizontally */
}

.die-control label {
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

.die-control select {
  width: 45px;        /* stays small */
  text-align-last: center;
}

.results {
  white-space: pre-line; /* preserves \n line breaks */
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-top: 16px;
}

/* ===============================
   Responsive
   =============================== */
@media (max-width: 900px) {
  .sections.horizontal {
    flex-direction: column;
  }
}

@media (max-width: 420px) {
  body {
    padding: 10px;
  }

  input[type="number"],
  select {
    width: 45px;
    font-size: 14px; /* zoom trigger */
  }

  button {
    padding: 8px 12px;
    font-size: 14px;
  }
}

/* ===============================
   Initiative Tracker Additions
   =============================== */

#addHasteControl input {
  width: 30px;
  text-align: center;
  padding: 4px;
  background: var(--panel-2); /* dark gray panel */
  color: var(--text);         /* light text */
  border: 1px solid var(--box);
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9rem;
}

/* Add Participant Name Input Theme */
#nameInput {
  background: var(--panel-2);  /* matches dropdown background */
  color: var(--text);           /* light text */
  border: 1px solid var(--box);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 1rem;
  text-align: left;
  width: 100%;                  /* fill available space */
  box-sizing: border-box;
}

/* Highlights the current group/subgroup */
.group-border {
  border: 0;          /* remove actual border */
  border-radius: 6px; /* optional */
  padding: 8px;       /* preserves spacing */
  margin-bottom: 6px;
}

.group-border.active {
  box-shadow: 0 0 0 2px var(--accent);
}

/* Each participant is a single horizontal row */
.participant-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.participant-row input[type="checkbox"] {
  margin: 0;
}

/* Remove button aligned to the right */
.participant-row button.remove-btn {
  padding: 4px 6px;
  margin-left: auto;
  margin-top: 0px; /* adjust as needed */
}

/* Wider dropdown for type selection (Player/NPC) */
.wide-select {
  width: 100px;
}

/* Haste input with - and + buttons inline */
.haste-control {
  display: flex;
  align-items: center;
  gap: 4px;
}

.haste-control button {
  padding: 2px 6px;
  font-weight: 600;
  margin-top: 0px; /* adjust as needed */
}

/* Haste input styling for participant rows */
.haste-control input {
  width: 30px;
  text-align: center;
  padding: 4px;
  background: var(--panel-2); /* dark gray panel like dropdowns */
  color: var(--text);         /* light text */
  border: 1px solid var(--box);
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9rem;
}

/* Header row for column labels */
.header-row {
  display: flex;
  align-items: center;
  font-weight: 700;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 4px;
  margin-bottom: 4px;
  gap: 8px;
}

/* Explicit widths to match participant row elements */
.header-haste {
  padding: 8px;
  width: 87px;
  text-align: left;
}

.header-name {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.header-actions {
  width: 70px;
  text-align: right;
}

.header-reactions {
  width: 70px;
  text-align: right;
}

.header-remove {
  width: 40px;
  text-align: center;
}

.participant-row span {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.turn-buttons {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  gap: 8px;
}

.turn-buttons .left-buttons {
  display: flex;
  gap: 8px;
}

.turn-buttons button {
  padding: 8px 16px;
  font-weight: 600;
  border-radius: 6px;
  background: linear-gradient(180deg, #2b2d30, #232428);
  color: var(--text);
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.12); /* default border */
}

/* Next Round button only */
.turn-buttons button.next-round {
  border: 2px solid red;
}

.turn-buttons button.next-round.ready {
  border-color: green;
}

/* -=-=-=-=- SAVE AND LOAD -=-=-=-=- */

.io-buttons {
  margin-top: -20px;
  display: flex;
  gap: 10px;
}

.io-buttons button {
  background-color: #333;
  color: #eee;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
}

.io-buttons button:hover {
  background-color: #555;
}

/* === Vendor Inventory additions === */
.vendor-group {
  min-width: 180px;
  margin-top: -14px;
  margin-bottom: -18px;
}

.vendor-group .divider {
  flex-shrink: 0;
}