/* ═══════════════════════════════════════════
   PEPPY RANDOM TOOLS — style.css
═══════════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
  --page-bg:  #f4f4f5;
  --bg:       #ffffff;
  --bg2:      #f0f0f0;
  --bg3:      #f8f8f8;
  --border:   #d4d4d4;
  --text:     #1e1e1e;
  --text2:    #555555;
  --accent:   #5646F5;
  --accent2:  #4535e0;
  --accent-light: rgba(86,70,245,0.10);
  --sidebar:  #ececf1;
  --surface:  #ffffff;
  --surface2: #f0f0f0;
}

[data-theme="dark"] {
  --page-bg:  #141416;
  --bg:       #1e1e1e;
  --bg2:      #252526;
  --bg3:      #2d2d30;
  --border:   #3e3e42;
  --text:     #cccccc;
  --text2:    #888888;
  --accent:   #8b83f7;
  --accent2:  #5646F5;
  --accent-light: rgba(139,131,247,0.12);
  --sidebar:  #252526;
  --surface:  #1e1e1e;
  --surface2: #252526;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Body ── */
body {
  font-family: 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--page-bg);
  font-size: 14px;
  color: var(--text);
}

/* ── Top Bar ── */
.top-bar { display: flex; align-items: center; gap: 12px; padding: 0 16px; height: 44px; background: #5646F5; color: #fff; flex-shrink: 0; z-index: 20; }
.top-bar-left { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.top-bar-back { color: rgba(255,255,255,0.85); text-decoration: none; font-size: 1.1rem; line-height: 1; }
.top-bar-back:hover { color: #fff; }
.top-bar-title { font-size: 0.95rem; font-weight: 600; white-space: nowrap; }
.top-bar-right { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.top-btn { background: rgba(255,255,255,0.18); border: 1px solid rgba(255,255,255,0.25); color: #fff; width: 32px; height: 32px; border-radius: 6px; cursor: pointer; font-size: 1rem; display: flex; align-items: center; justify-content: center; transition: background 0.15s; }
.top-btn:hover { background: rgba(255,255,255,0.3); }

/* ── App Body ── */
.app-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: 210px;
  min-width: 180px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: hidden;
  flex-shrink: 0;
}

/* ── Sidebar Top Group Nav ── */
.sidebar-top-nav {
  display: flex;
  gap: 2px;
  padding: 7px 6px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface2);
}
.grp-nav-btn {
  flex: 1;
  padding: 6px 2px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  text-align: center;
  color: var(--text2);
  transition: background 0.15s;
  min-width: 0;
  background: none !important;
  border: 1px solid transparent !important;
  font-family: inherit;
}
.grp-nav-btn:hover  { background: var(--accent-light) !important; color: var(--accent); }
.grp-nav-btn.active { background: var(--accent-light) !important; border-color: var(--accent) !important; color: var(--accent); }

/* ── Sidebar Groups ── */
.sidebar-groups { flex: 1; overflow-y: auto; }

/* ── Group Header ── */
.grp-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 14px 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text2);
  cursor: pointer;
  user-select: none;
  background: none !important;
  border: none !important;
  font-family: inherit;
  text-align: left;
  transition: color 0.15s;
}
.grp-hdr:hover { color: var(--accent) !important; }
.grp-chevron {
  font-size: 8px;
  flex-shrink: 0;
  margin-left: 4px;
  transition: transform 0.2s ease;
}
.sidebar-group.collapsed .grp-chevron { transform: rotate(-90deg); }
.sidebar-group.collapsed .grp-tools   { display: none; }
.sidebar-group + .sidebar-group { border-top: 1px solid var(--border); }

/* ── Tab Buttons ── */
.tab-btn {
  width: 100%;
  padding: 7px 12px 7px 22px;
  text-align: left;
  background: none !important;
  border: none !important;
  border-radius: 0;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  transition: background 0.12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tab-btn:hover  { background: var(--accent-light) !important; color: var(--accent) !important; }
.tab-btn.active { background: var(--accent) !important; color: #fff !important; font-weight: 600; }

/* ── Tool Area ── */
.tool-area {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.tool-panel {
  display: none;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px;
  min-height: 0;
}
.tool-panel.active { display: flex; }

.panel-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
  flex-shrink: 0;
}

/* ── Form Elements ── */
.form-group { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.form-row   { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; flex-shrink: 0; }
.btn-row    { display: flex; gap: 8px; flex-wrap: wrap; flex-shrink: 0; align-items: center; }

.io-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.io-area {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px;
  font-family: 'Segoe UI', sans-serif;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  line-height: 1.5;
  resize: vertical;
  width: 100%;
}
.io-area:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }

/* ── Generic Buttons ── */
button {
  padding: 7px 16px;
  border: 1px solid var(--accent2);
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}
button:hover { opacity: 0.88; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg2) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
}
.btn-secondary:hover { background: var(--bg3) !important; opacity: 1; }

select,
input[type="number"],
input[type="text"],
input[type="time"] {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  font-family: inherit;
}
select:focus,
input[type="number"]:focus,
input[type="text"]:focus,
input[type="time"]:focus { border-color: var(--accent); }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  user-select: none;
}

.tool-msg      { font-size: 12px; color: var(--accent); }
.tool-msg.err  { color: #e05252; }
.tool-msg.ok   { color: #4caf50; }

/* ══════════════════════════════════
   RESULT DISPLAY
══════════════════════════════════ */
.result-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  flex-shrink: 0;
}

.big-result {
  text-align: center;
  padding: 28px 16px;
  border-radius: 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.big-result .result-label {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 8px;
}
.big-result .result-value {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--accent);
  word-break: break-word;
}
.big-result .result-sub {
  font-size: 0.88rem;
  color: var(--text2);
  margin-top: 6px;
}

/* ══════════════════════════════════
   WHEEL SPINNER
══════════════════════════════════ */
.wheel-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.wheel-left {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 200px;
  flex: 1;
}
.wheel-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 260px;
}
.wheel-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wheel-pointer {
  position: absolute;
  top: -6px;
  font-size: 1.5rem;
  color: var(--accent);
  z-index: 2;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
  line-height: 1;
}
#wheel-canvas {
  border-radius: 50%;
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
  display: block;
}
.wheel-result-text {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  min-height: 2rem;
  animation: fadeIn 0.4s ease;
}

/* ══════════════════════════════════
   YES / NO
══════════════════════════════════ */
.yesno-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 16px 0;
}
.yesno-display {
  width: 240px;
  height: 240px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  font-weight: 900;
  letter-spacing: -2px;
  color: #fff;
  background: var(--bg2);
  border: 3px solid var(--border);
  transition: background 0.4s, border-color 0.4s, transform 0.15s;
  user-select: none;
}
.yesno-display.yes { background: #22c55e; border-color: #16a34a; transform: scale(1.05); }
.yesno-display.no  { background: #ef4444; border-color: #dc2626; transform: scale(1.05); }

/* ══════════════════════════════════
   COIN FLIP
══════════════════════════════════ */
.coin-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 8px 0;
}
.coin {
  width: 160px;
  height: 160px;
  perspective: 600px;
  cursor: pointer;
}
.coin-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.1s;
}
.coin.flipping .coin-inner {
  animation: coinFlip 1.0s ease-out forwards;
}
.coin-face, .coin-back {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 2.2rem;
  color: #fff;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}
.coin-face { background: radial-gradient(circle at 35% 35%, #f5c842, #c8882a); }
.coin-back { background: radial-gradient(circle at 35% 35%, #d0d0d8, #8888a0); transform: rotateY(180deg); }
.coin-label {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  min-height: 1.5rem;
}

@keyframes coinFlip {
  0%   { transform: rotateY(0deg); }
  100% { transform: rotateY(var(--coin-rot, 900deg)); }
}

/* ══════════════════════════════════
   DICE ROLLER
══════════════════════════════════ */
.dice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 0;
}
.die {
  width: 60px;
  height: 60px;
  border: 2px solid var(--accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--accent);
  background: var(--bg2);
  animation: dieRoll 0.3s ease-out;
}
.die.d6 { border-radius: 12px; }
.die-total {
  font-size: 1.1rem;
  color: var(--text2);
}
.die-total strong { color: var(--accent); font-size: 1.4rem; }

@keyframes dieRoll {
  0%   { transform: scale(0.5) rotate(-15deg); opacity: 0; }
  80%  { transform: scale(1.1) rotate(3deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* Dot layout for d6 */
.d6-dots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  width: 36px;
  height: 24px;
  gap: 2px;
}
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
.dot.hidden { visibility: hidden; }

/* ══════════════════════════════════
   CARD PICKER
══════════════════════════════════ */
.cards-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 0;
}
.playing-card {
  width: 64px;
  height: 90px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 5px;
  font-weight: 700;
  font-size: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  animation: fadeIn 0.35s ease;
}
.playing-card .rank-top { font-size: 0.85rem; }
.playing-card .suit-center { font-size: 1.6rem; text-align: center; }
.playing-card .rank-bot { font-size: 0.85rem; text-align: right; transform: rotate(180deg); }
.playing-card.red  { color: #e03030; }
.playing-card.black { color: var(--text); }

/* ══════════════════════════════════
   TEAM / GROUP DISPLAY
══════════════════════════════════ */
.teams-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}
.team-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  min-width: 150px;
  flex: 1;
  animation: fadeIn 0.35s ease;
}
.team-card .team-name {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 2px solid;
}
.team-card .team-members { display: flex; flex-direction: column; gap: 4px; }
.team-card .member-chip {
  font-size: 13px;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--bg3);
  border: 1px solid var(--border);
}

/* Team color accents */
.team-0 .team-name { color: #5646F5; border-color: #5646F5; }
.team-1 .team-name { color: #e85d6a; border-color: #e85d6a; }
.team-2 .team-name { color: #f5a623; border-color: #f5a623; }
.team-3 .team-name { color: #22c55e; border-color: #22c55e; }
.team-4 .team-name { color: #06b6d4; border-color: #06b6d4; }
.team-5 .team-name { color: #a855f7; border-color: #a855f7; }
.team-6 .team-name { color: #f97316; border-color: #f97316; }
.team-7 .team-name { color: #14b8a6; border-color: #14b8a6; }

/* ══════════════════════════════════
   PAIRS LIST
══════════════════════════════════ */
.pairs-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pair-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  animation: fadeIn 0.3s ease;
}
.pair-row .pair-num {
  font-size: 11px;
  color: var(--text2);
  min-width: 22px;
}
.pair-name {
  background: var(--accent-light);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}
.pair-arrow { color: var(--text2); font-size: 1.1rem; }

/* ══════════════════════════════════
   SHUFFLED / ORDERED LIST
══════════════════════════════════ */
.ordered-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ordered-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  animation: slideIn 0.25s ease both;
  font-size: 13px;
}
.ordered-item .order-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ══════════════════════════════════
   SECRET SANTA
══════════════════════════════════ */
.santa-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.santa-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  animation: fadeIn 0.35s ease;
}
.santa-giver   { font-weight: 600; min-width: 100px; }
.santa-arrow   { color: var(--text2); }
.santa-receiver {
  background: var(--accent-light);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 13px;
}
.santa-reveal {
  margin-left: auto;
  background: var(--bg3) !important;
  border: 1px solid var(--border) !important;
  color: var(--text2) !important;
  font-size: 11px !important;
  padding: 3px 8px !important;
  opacity: 0.75;
}
.santa-reveal:hover { opacity: 1 !important; }

/* ══════════════════════════════════
   SEATING
══════════════════════════════════ */
.seating-grid-wrap { overflow-x: auto; }
.seating-grid {
  display: inline-grid;
  gap: 8px;
  padding: 8px 0;
}
.seat {
  width: 80px;
  height: 52px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--bg2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  word-break: break-word;
  padding: 4px;
  animation: fadeIn 0.3s ease;
  line-height: 1.2;
}
.seat .seat-num { font-size: 10px; color: var(--text2); }
.seat.empty { background: var(--bg3); color: var(--text2); font-size: 12px; opacity: 0.5; }

/* ══════════════════════════════════
   HISTORY LIST
══════════════════════════════════ */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
}
.history-item {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text2);
  display: flex;
  gap: 8px;
}
.history-item .h-num { color: var(--accent); font-weight: 600; }

/* ══════════════════════════════════
   NUMBER RESULTS
══════════════════════════════════ */
.number-results {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.num-chip {
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--accent-light);
  border: 1.5px solid var(--accent);
  color: var(--accent);
  font-size: 1.1rem;
  font-weight: 700;
  animation: popIn 0.25s ease both;
}

/* ══════════════════════════════════
   WINNER DISPLAY
══════════════════════════════════ */
.winners-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.winner-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 8px;
  background: var(--bg2);
  border: 1px solid var(--border);
  animation: popIn 0.3s ease both;
}
.winner-row .w-rank {
  font-size: 1.6rem;
  min-width: 36px;
}
.winner-row .w-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}
.winner-row.first {
  background: linear-gradient(135deg, rgba(86,70,245,0.15), rgba(139,131,247,0.1));
  border-color: var(--accent);
}

/* ══════════════════════════════════
   ANIMATIONS
══════════════════════════════════ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes popIn {
  0%   { transform: scale(0.6); opacity: 0; }
  75%  { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.spinning-text {
  animation: pulse 0.5s infinite;
  color: var(--accent);
  font-weight: 700;
}

/* ══════════════════════════════════
   SLOT / PERSON PICKER
══════════════════════════════════ */
.slot-display {
  text-align: center;
  padding: 20px 24px;
  background: var(--bg2);
  border: 2px solid var(--border);
  border-radius: 10px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

/* ══════════════════════════════════
   RESPONSIVE
══════════════════════════════════ */

/* ── Hamburger menu button (hidden on desktop, shown on mobile) ── */
.menu-toggle { display: none; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}
.sidebar-overlay.active { display: block; }

@media (max-width: 768px) {
  .menu-toggle { display: inline-flex; }
  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 260px;
    min-width: unset;
    height: 100vh;
    z-index: 100;
    transition: left 0.3s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
    border-right: none;
  }
  .sidebar.open { left: 0; }
  .sidebar-top-nav { flex-wrap: wrap; }
  .tool-panel { padding: 16px; }
  .wheel-layout { flex-direction: column; }
  .wheel-right { min-width: 0; width: 100%; }
  .btn-row { flex-wrap: wrap; gap: 8px; }
}

@media (max-width: 480px) {
  .top-bar-title { font-size: 0.85rem; }
  .top-bar { padding: 0 10px; height: 40px; }
  .tool-panel { padding: 12px 10px; }
  .panel-title { font-size: 1rem; }
  .wheel-canvas-wrap canvas { max-width: 280px; max-height: 280px; }
}

/* ── Wheel history ─────────────────────────── */
.wheel-history { max-height: 180px; overflow-y: auto; margin-top: 8px; }
.wh-item { display: flex; align-items: center; gap: 8px; padding: 3px 8px;
  font-size: 12px; border-bottom: 1px solid var(--border); }
.wh-num { color: var(--accent); font-weight: 600; min-width: 28px; }
