/* Ultimate Dungeon Planner - Shared Styles */
/* Version 2.0 - Multi-page architecture */

:root {
  --bg-dark: #0f0f23;
  --bg-card: rgba(40, 35, 50, 0.9);
  --bg-input: rgba(15, 12, 20, 0.8);
  --gold: #d4af37;
  --gold-dim: rgba(212, 175, 55, 0.3);
  --gold-glow: rgba(212, 175, 55, 0.15);
  --green: #6db87a;
  --green-dim: rgba(109, 184, 122, 0.3);
  --red: #e85d4c;
  --red-dim: rgba(232, 93, 76, 0.3);
  --blue: #4a9eff;
  --blue-dim: rgba(74, 158, 255, 0.3);
  --text: #e8d5b7;
  --text-dim: rgba(232, 213, 183, 0.6);
  --border: rgba(212, 175, 55, 0.2);
}

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

body {
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, var(--bg-dark) 100%);
  background-attachment: fixed;
  font-family: 'Crimson Text', Georgia, serif;
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
  padding-bottom: 2rem;
}

/* ==================== TYPOGRAPHY ==================== */
.title-font { font-family: 'Cinzel', serif; }
.gold { color: var(--gold); }
.green { color: var(--green); }
.red { color: var(--red); }
.blue { color: var(--blue); }
.muted { opacity: 0.6; }
small { font-size: 0.75rem; opacity: 0.7; }

/* ==================== LAYOUT ==================== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 0.75rem;
}
@media (min-width: 768px) {
  .container { padding: 0 1rem; }
}

.page-header {
  padding: 1rem 0;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--gold-dim);
}
.page-header h1 {
  font-size: 1.25rem;
  letter-spacing: 0.08em;
  color: var(--gold);
}
@media (min-width: 768px) {
  .page-header h1 { font-size: 1.5rem; }
}
.page-header p {
  font-size: 0.85rem;
  opacity: 0.7;
  margin-top: 0.25rem;
}

/* Grid System */
.grid { display: grid; gap: 0.75rem; }
.grid-1 { grid-template-columns: 1fr; }
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
.grid-4 { grid-template-columns: repeat(2, 1fr); }
.grid-5 { grid-template-columns: repeat(2, 1fr); }

@media (min-width: 640px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
  .grid-5 { grid-template-columns: repeat(5, 1fr); }
  .grid { gap: 1rem; }
}

/* ==================== NAVIGATION ==================== */
.nav-header {
  background: rgba(20, 18, 30, 0.95);
  border-bottom: 1px solid var(--gold-dim);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  max-width: 1200px;
  margin: 0 auto;
}
.nav-brand {
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  color: var(--gold);
  text-decoration: none;
  letter-spacing: 0.05em;
}
.nav-brand:hover { opacity: 0.8; }

/* Hamburger Button */
.nav-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 32px;
  height: 32px;
  background: none;
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  cursor: pointer;
  padding: 6px;
}
.nav-toggle span {
  display: block;
  height: 2px;
  background: var(--gold);
  border-radius: 1px;
  transition: all 0.2s;
}
.nav-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
.nav-toggle.active span:nth-child(2) { opacity: 0; }
.nav-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(4px, -4px); }

@media (min-width: 900px) {
  .nav-toggle { display: none; }
}

/* Desktop Nav */
.nav-desktop {
  display: none;
}
@media (min-width: 900px) {
  .nav-desktop {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
  }
}
.nav-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-right: 0.5rem;
  margin-right: 0.5rem;
  border-right: 1px solid var(--gold-dim);
}
.nav-group:last-child { border-right: none; margin-right: 0; padding-right: 0; }
.nav-group-label {
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gold);
  opacity: 0.5;
  margin-right: 0.25rem;
}
.nav-link {
  padding: 0.35rem 0.5rem;
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  color: var(--text-dim);
  text-decoration: none;
  border-radius: 3px;
  transition: all 0.2s;
  white-space: nowrap;
}
.nav-link:hover { color: var(--gold); background: var(--gold-glow); }
.nav-link.active { color: var(--gold); background: var(--gold-dim); }

/* Mobile Nav Menu */
.nav-mobile {
  display: none;
  position: fixed;
  top: 49px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 12, 25, 0.98);
  z-index: 99;
  overflow-y: auto;
  padding: 1rem;
}
.nav-mobile.active { display: block; }
@media (min-width: 900px) {
  .nav-mobile { display: none !important; }
}
.nav-mobile-group {
  margin-bottom: 1rem;
}
.nav-mobile-group-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  opacity: 0.6;
  margin-bottom: 0.5rem;
  display: block;
}
.nav-mobile-link {
  display: block;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}
.nav-mobile-link:hover, .nav-mobile-link.active {
  color: var(--gold);
  background: var(--gold-glow);
}

/* ==================== CARDS ==================== */
.card {
  background: linear-gradient(145deg, var(--bg-card), rgba(25, 22, 35, 0.95));
  border: 1px solid var(--gold-dim);
  border-radius: 6px;
  padding: 1rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  gap: 0.5rem;
}
.card-header h2, .card-header h3 {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  margin: 0;
}
.card-title {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
}

/* ==================== HELP BUTTON & MODAL ==================== */
.help-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gold-glow);
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  font-size: 0.7rem;
  font-weight: bold;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}
.help-btn:hover { background: var(--gold-dim); }

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.active { display: flex; }
.modal {
  background: linear-gradient(145deg, #2a2540, #1a1830);
  border: 1px solid var(--gold);
  border-radius: 8px;
  max-width: 500px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--gold-dim);
  position: sticky;
  top: 0;
  background: inherit;
}
.modal-header h3 { margin: 0; color: var(--gold); font-size: 1rem; }
.modal-close {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: 0.7;
}
.modal-close:hover { opacity: 1; color: var(--gold); }
.modal-body {
  padding: 1rem;
  font-size: 0.9rem;
  line-height: 1.7;
}
.modal-body p { margin-bottom: 0.75rem; }
.modal-body ul { margin: 0.5rem 0 0.75rem 1.25rem; }
.modal-body li { margin-bottom: 0.3rem; }
.modal-body strong { color: var(--gold); }
.modal-body code {
  background: rgba(0, 0, 0, 0.4);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.85em;
}

/* ==================== FORMS ==================== */
.input-group { margin-bottom: 0.75rem; }
.input-group:last-child { margin-bottom: 0; }
.input-group label {
  display: block;
  font-size: 0.75rem;
  margin-bottom: 0.3rem;
  opacity: 0.85;
}
.input-group input,
.input-group select,
.input-group textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  background: var(--bg-input);
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.2s;
}
.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
  outline: none;
  border-color: var(--gold);
}
.input-group input:disabled,
.input-group select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.input-group textarea { min-height: 100px; resize: vertical; }
.input-group small { display: block; margin-top: 0.25rem; }

.input-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.input-row .input-group { flex: 1; min-width: 80px; }

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--gold-dim);
  border-radius: 3px;
  outline: none;
  margin: 0.5rem 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: linear-gradient(145deg, var(--gold), #b8942d);
  border-radius: 50%;
  cursor: pointer;
}
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
  cursor: pointer;
}

/* Toggle Switch */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.5rem 0;
}
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: rgba(30, 27, 40, 0.8);
  border: 1px solid var(--gold-dim);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.toggle.active { background: var(--gold-dim); border-color: var(--gold); }
.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: all 0.2s;
}
.toggle.active::after { left: 22px; background: var(--gold); }

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  background: rgba(30, 27, 40, 0.8);
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.btn:hover { background: var(--gold-glow); border-color: var(--gold); color: var(--gold); }
.btn.active { background: var(--gold-dim); border-color: var(--gold); color: var(--gold); }
.btn.small { padding: 0.35rem 0.7rem; font-size: 0.75rem; }
.btn.primary { background: var(--gold-dim); border-color: var(--gold); color: var(--gold); }
.btn.danger { border-color: var(--red-dim); color: var(--red); }
.btn.danger:hover { background: var(--red-dim); border-color: var(--red); }
.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem; }

/* ==================== TABLES ==================== */
.table-wrap {
  overflow-x: auto;
  margin: 0 -0.5rem;
  padding: 0 0.5rem;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  min-width: 350px;
}
th, td {
  padding: 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.7;
  white-space: nowrap;
}
tr:hover { background: rgba(212, 175, 55, 0.03); }
td input, td select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 0.3rem 0.4rem;
  color: var(--text);
  font-size: 0.8rem;
  border-radius: 3px;
  width: 100%;
  min-width: 50px;
}
td input:focus, td select:focus { outline: none; border-color: var(--gold); }
.delete-col { width: 40px; text-align: center; }

/* ==================== STATS & SUMMARIES ==================== */
.stat-card {
  text-align: center;
  padding: 0.75rem 0.5rem;
}
.stat-card .value {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.2;
}
.stat-card .label {
  font-size: 0.7rem;
  opacity: 0.6;
  margin-top: 0.2rem;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.summary-row:last-child { border-bottom: none; }
.summary-row.total {
  border-top: 2px solid var(--gold-dim);
  border-bottom: none;
  margin-top: 0.5rem;
  padding-top: 0.6rem;
  font-weight: 600;
}
.summary-row.subtotal {
  background: var(--gold-glow);
  margin: 0.3rem -0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 3px;
}

/* ==================== ALERTS ==================== */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 5px;
  margin: 0.75rem 0;
  font-size: 0.85rem;
  line-height: 1.5;
}
.alert.success { background: var(--green-dim); border: 1px solid var(--green); }
.alert.warning { background: var(--gold-glow); border: 1px solid var(--gold-dim); }
.alert.danger { background: var(--red-dim); border: 1px solid var(--red); }
.alert.info { background: var(--blue-dim); border: 1px solid var(--blue); }
.alert strong { display: block; margin-bottom: 0.25rem; }

/* ==================== SWIPEABLE ROWS ==================== */
.swipe-row {
  position: relative;
  overflow: hidden;
  touch-action: pan-y;
}
.swipe-row-content {
  position: relative;
  background: inherit;
  transition: transform 0.2s ease;
  z-index: 1;
}
.swipe-row-delete {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 80px;
  background: var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.8rem;
  font-weight: 600;
}
.swipe-row.swiped .swipe-row-content { transform: translateX(-80px); }

/* Desktop delete button */
.row-delete-btn {
  display: none;
  background: none;
  border: none;
  color: var(--red);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.row-delete-btn:hover { opacity: 1; }
@media (min-width: 768px) {
  .row-delete-btn { display: inline-block; }
  .swipe-row-delete { display: none; }
}

/* ==================== COLLAPSIBLE ==================== */
.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 0.6rem;
  margin: 0.5rem -0.5rem;
  border-radius: 4px;
  background: var(--gold-glow);
  user-select: none;
}
.collapsible-header:hover { background: var(--gold-dim); }
.collapsible-arrow { transition: transform 0.2s; font-size: 0.8rem; }
.collapsible-header.collapsed .collapsible-arrow { transform: rotate(-90deg); }
.collapsible-content {
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  opacity: 1;
}
.collapsible-content.collapsed {
  max-height: 0 !important;
  opacity: 0;
}

/* ==================== SCHEDULE VISUALIZATION ==================== */
.schedule-viz {
  background: rgba(15, 12, 20, 0.5);
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  overflow-x: auto;
  padding: 0.5rem;
}
.sched-block {
  position: absolute;
  left: 3px;
  right: 3px;
  border-radius: 4px;
  padding: 3px 5px;
  font-size: 0.6rem;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
.sched-block.standard {
  background: linear-gradient(135deg, #2d5a3d, #3d7a4d);
  border: 1px solid #4a9a5a;
}
.sched-block.hot {
  background: linear-gradient(135deg, #8b3a3a, #a04545);
  border: 1px solid #c05555;
}

/* ==================== RISK MATRIX ==================== */
.risk-cell {
  padding: 0.6rem;
  text-align: center;
  font-size: 0.7rem;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
}
.risk-cell:hover { transform: scale(1.05); }
.risk-cell.highlight {
  box-shadow: 0 0 0 3px var(--gold);
  transform: scale(1.05);
}
.risk-low { background: rgba(109, 184, 122, 0.25); }
.risk-med { background: rgba(212, 175, 55, 0.25); }
.risk-high { background: rgba(232, 93, 76, 0.25); }

/* ==================== CHECKLIST ==================== */
.checklist-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}
.checklist-item:last-child { border-bottom: none; }
.checklist-item input[type="checkbox"] { flex-shrink: 0; }
.checklist-item.done span { text-decoration: line-through; opacity: 0.5; }
.checklist-item-text {
  flex: 1;
  font-size: 0.9rem;
}
.checklist-item-text input {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.9rem;
  width: 100%;
  padding: 0;
}
.checklist-item-text input:focus { outline: none; }

/* ==================== UTILITIES ==================== */
.divider {
  border: none;
  border-top: 1px solid var(--gold-dim);
  margin: 1rem 0;
}
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none !important; }

/* ==================== SAVE INDICATOR ==================== */
.save-indicator {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  padding: 0.5rem 1rem;
  background: rgba(30, 27, 40, 0.95);
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  font-size: 0.8rem;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
  z-index: 50;
}
.save-indicator.show {
  opacity: 1;
  transform: translateY(0);
}
.save-indicator.saving { color: var(--gold); }
.save-indicator.saved { color: var(--green); }

/* ==================== PRINT ==================== */
@media print {
  body { background: white; color: black; }
  .nav-header, .nav-mobile, .help-btn, .btn, .save-indicator { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .modal-overlay { display: none !important; }
}
