/* ============================================================
   LARP Character Manager — Main Stylesheet
   Dark/medieval theme, responsive SPA layout
   ============================================================ */

/* ── CSS Custom Properties ── */
:root {
  --bg:          #141210;
  --bg-2:        #1e1a16;
  --bg-3:        #28231c;
  --surface:     #2e2820;
  --surface-2:   #38302a;
  --border:      #4a3f33;
  --border-light:#6b5a4a;

  --text:        #e8dcc8;
  --text-muted:  #9e8e7a;
  --text-light:  #f5ede0;

  --gold:        #c9a84c;
  --gold-light:  #e2c46a;
  --gold-dark:   #9a7a30;

  --red:         #c0392b;
  --red-light:   #e74c3c;
  --green:       #27ae60;
  --green-light: #2ecc71;
  --blue:        #2980b9;
  --blue-light:  #3498db;
  --orange:      #e67e22;

  --radius:      6px;
  --radius-lg:   10px;
  --shadow:      0 2px 8px rgba(0,0,0,0.5);
  --shadow-lg:   0 4px 20px rgba(0,0,0,0.7);

  --header-h:    60px;
  --sidebar-w:   220px;
  --transition:  0.2s ease;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--gold-light); text-decoration: none; }
a:hover { color: var(--gold); text-decoration: underline; }

img { max-width: 100%; }

h1, h2, h3, h4 {
  color: var(--text-light);
  line-height: 1.3;
  font-weight: 600;
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

/* ── Header / Nav ── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.header.hidden-header { display: none; }

.header-inner {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 1rem;
  gap: 1rem;
  max-width: 1400px;
  margin: 0 auto;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.brand-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 0.5px;
  text-decoration: none;
}
.brand-name:hover { color: var(--gold); text-decoration: none; }

/* Hamburger */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius);
}
.hamburger:hover { background: var(--surface); }
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: var(--transition);
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Main Nav */
.main-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
  overflow: hidden;
}

.main-nav a, .nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.9rem;
  white-space: nowrap;
  transition: color var(--transition), background var(--transition);
  text-decoration: none;
}
.main-nav a:hover, .nav-link:hover {
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
}
.main-nav a.active, .nav-link.active {
  color: var(--gold-light);
  background: var(--surface);
  font-weight: 500;
}

/* User Menu */
.user-menu {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-left: auto;
}
.user-menu .user-name {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ── Mobile Drawer ── */
.mobile-drawer {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: 260px;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  z-index: 90;
  transform: translateX(-100%);
  transition: transform var(--transition);
  overflow-y: auto;
  padding: 1rem;
}
.mobile-drawer.open { transform: translateX(0); }

.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--header-h);
  background: rgba(0,0,0,0.6);
  z-index: 89;
}
.mobile-overlay.show { display: block; }

.mobile-nav-links {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.mobile-nav-links a {
  display: block;
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.95rem;
}
.mobile-nav-links a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.mobile-nav-links a.active { color: var(--gold-light); background: var(--surface); }
.mobile-nav-links .nav-section {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 0.75rem 1rem 0.25rem;
  opacity: 0.6;
}

/* ── Main Content ── */
.main-content {
  min-height: calc(100vh - var(--header-h));
  padding: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
}

/* ── Auth Pages ── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}
.auth-logo h1 {
  font-size: 1.5rem;
  color: var(--gold-light);
}
.auth-logo p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* ── Cards & Panels ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  flex-wrap: wrap;
}
.card-title { font-size: 1.05rem; color: var(--gold-light); font-weight: 600; }

/* ── Page Header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 1.5rem; }
.page-header p { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.2rem; }
.page-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

/* ── Grid Layouts ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  text-align: center;
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold-light);
  line-height: 1;
}
.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

/* ── Forms ── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}
.form-group:last-child { margin-bottom: 0; }

label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}
label .required { color: var(--red-light); margin-left: 2px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  padding: 0.5rem 0.75rem;
  width: 100%;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--gold-dark);
  box-shadow: 0 0 0 3px rgba(201,168,76,0.15);
}
input::placeholder, textarea::placeholder { color: var(--border-light); }
select option { background: var(--bg-3); }
textarea { resize: vertical; min-height: 90px; }

.form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Checkbox */
.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}
.form-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--gold);
}
.form-check label { margin: 0; cursor: pointer; font-size: 0.95rem; color: var(--text); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition), transform var(--transition);
  white-space: nowrap;
  font-family: inherit;
  line-height: 1.4;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary   { background: var(--gold-dark); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--gold); }

.btn-outline   { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-light); }

.btn-danger    { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--red-light); }

.btn-success   { background: var(--green); color: #fff; }
.btn-success:hover:not(:disabled) { background: var(--green-light); }

.btn-ghost     { background: transparent; color: var(--text-muted); border: none; }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--surface); }

.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }
.btn-lg { padding: 0.7rem 1.4rem; font-size: 1rem; }
.btn-block { width: 100%; }

.btn-icon { padding: 0.4rem; width: 34px; height: 34px; }
.btn-icon.btn-sm { width: 28px; height: 28px; padding: 0.2rem; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-admin   { background: rgba(201,168,76,0.2);  color: var(--gold-light); }
.badge-manager { background: rgba(41,128,185,0.2);  color: var(--blue-light); }
.badge-staff   { background: rgba(39,174,96,0.2);   color: var(--green-light); }
.badge-player  { background: rgba(158,142,122,0.2); color: var(--text-muted); }

.badge-draft     { background: rgba(158,142,122,0.2); color: var(--text-muted); }
.badge-submitted { background: rgba(230,126,34,0.2);  color: var(--orange); }
.badge-approved  { background: rgba(39,174,96,0.2);   color: var(--green-light); }
.badge-rejected  { background: rgba(192,57,43,0.2);   color: var(--red-light); }

/* ── Alerts ── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}
.alert-error   { background: rgba(192,57,43,0.15);  border-color: var(--red);       color: #f5a49b; }
.alert-success { background: rgba(39,174,96,0.15);  border-color: var(--green);     color: #7deba3; }
.alert-info    { background: rgba(41,128,185,0.15); border-color: var(--blue);      color: #85c1e9; }
.alert-warning { background: rgba(230,126,34,0.15); border-color: var(--orange);    color: #f0b27a; }

/* ── Tables ── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
thead { background: var(--bg-3); }
thead th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
tbody td { padding: 0.75rem 1rem; vertical-align: middle; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ── Search / Filter Bar ── */
.filter-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar input, .filter-bar select { max-width: 220px; }
.filter-bar .spacer { flex: 1; }

/* ── Character Card ── */
.char-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.char-card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow);
}
.char-card-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-light);
}
.char-card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.char-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
  flex-wrap: wrap;
}

/* ── Character Sheet (View) ── */
.char-sheet {
  max-width: 860px;
}
.char-sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.char-sheet-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.field-view {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
}
.field-view-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}
.field-view-value {
  color: var(--text-light);
  font-size: 0.95rem;
  word-break: break-word;
  white-space: pre-wrap;
}
.field-view-value.empty { color: var(--text-muted); font-style: italic; font-size: 0.85rem; }

.review-box {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin-bottom: 1rem;
}

/* ── Submissions List ── */
.submission-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.submission-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ── Field Builder ── */
.field-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-3);
  margin-bottom: 0.5rem;
}
.field-item-drag {
  color: var(--border-light);
  cursor: grab;
  flex-shrink: 0;
}
.field-item-info { flex: 1; min-width: 0; }
.field-item-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.field-item-meta { font-size: 0.75rem; color: var(--text-muted); }
.field-item-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
}
.modal-box h3 { margin-bottom: 0.75rem; }
.modal-box p { color: var(--text-muted); margin-bottom: 1.25rem; font-size: 0.95rem; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; }

/* ── Toasts ── */
.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 340px;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  box-shadow: var(--shadow);
  animation: slideIn 0.2s ease;
  border-left: 4px solid var(--gold);
}
.toast.success { border-left-color: var(--green);  }
.toast.error   { border-left-color: var(--red);    }
.toast.info    { border-left-color: var(--blue);   }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);   opacity: 1; }
}

/* ── Empty States ── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 0.75rem; opacity: 0.5; }
.empty-state h3 { color: var(--text-muted); margin-bottom: 0.5rem; }
.empty-state p  { font-size: 0.875rem; }

/* ── Loading ── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-muted);
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 0.75rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Misc Utilities ── */
.text-muted  { color: var(--text-muted); }
.text-gold   { color: var(--gold-light); }
.text-danger { color: var(--red-light);  }
.text-success{ color: var(--green-light);}
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex  { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.hidden { display: none !important; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }
.text-sm { font-size: 0.875rem; }
.break-word { word-break: break-word; }
.full-width { width: 100%; }

/* ── Reports specific ── */
.report-controls {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  align-items: center;
}
.checkbox-col { width: 40px; }

/* ── Settings form ── */
.settings-form { max-width: 600px; }

/* ── User list ── */
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gold-dark);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Inline edit form ── */
.inline-form {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-top: 0.75rem;
}

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

/* ══════════════════════════════════════════
   PRINT STYLES
   ══════════════════════════════════════════ */
@media print {
  :root {
    --bg:      #fff;
    --surface: #fff;
    --text:    #111;
    --text-muted: #555;
    --border:  #ccc;
    --gold-light: #6b4f1a;
  }
  body { background: #fff; color: #111; }

  .header, .mobile-drawer, .no-print,
  .btn, .toast-container, .modal-overlay,
  .page-actions, .filter-bar, .char-card-actions,
  .char-sheet-header .page-actions { display: none !important; }

  .main-content { padding: 0; max-width: 100%; }

  .char-sheet { max-width: 100%; }

  .char-sheet-fields {
    grid-template-columns: repeat(2, 1fr);
  }

  .field-view {
    border: 1px solid #ccc;
    break-inside: avoid;
  }

  .print-header {
    text-align: center;
    border-bottom: 2px solid #6b4f1a;
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
  }
  .print-header h1 { font-size: 1.5rem; color: #6b4f1a; }

  /* Batch print page breaks */
  .print-page { page-break-after: always; }
  .print-page:last-child { page-break-after: auto; }

  .hide-in-print { display: none !important; }
}

/* ══════════════════════════════════════════
   RESPONSIVE — Tablet (≤ 900px)
   ══════════════════════════════════════════ */
@media (max-width: 900px) {
  .main-nav { display: none; }
  .hamburger { display: flex; }
  .user-menu .user-name { display: none; }
  .form-row { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════
   RESPONSIVE — Mobile (≤ 600px)
   ══════════════════════════════════════════ */
@media (max-width: 600px) {
  .main-content { padding: 1rem; }
  h1 { font-size: 1.35rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
  .char-sheet-fields { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; gap: 0.75rem; }
  .modal-box { padding: 1.1rem; }
  .filter-bar input, .filter-bar select { max-width: 100%; width: 100%; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .toast-container { left: 1rem; right: 1rem; max-width: 100%; }
}
