/* Assembly App — Light theme for 65+ audience */

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

:root {
  --bg: #f5f5f0;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #555555;
  --text-muted: #888888;
  --accent: #CC0000;
  --accent-light: #ff3333;
  --border: #dddddd;
  --border-light: #eeeeee;
  --success: #22863a;
  --warning: #d29922;
  --error: #d73a49;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --radius: 8px;
  --nav-height: 60px;
  --font-base: 16px;
  --font-lg: 18px;
  --font-xl: 22px;
  --font-xxl: 28px;
  --touch-min: 48px;
}

html.font-large {
  --font-base: 20px;
  --font-lg: 22px;
  --font-xl: 26px;
  --font-xxl: 32px;
}

html {
  font-size: var(--font-base);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-height) + 16px);
  -webkit-font-smoothing: antialiased;
}

/* --- App Container --- */
#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  padding-top: 8px;
}

/* --- Typography --- */
h1 { font-size: var(--font-xxl); font-weight: 700; margin-bottom: 8px; }
h2 { font-size: var(--font-xl); font-weight: 600; margin-bottom: 8px; }
h3 { font-size: var(--font-lg); font-weight: 600; margin-bottom: 4px; }
p { margin-bottom: 8px; }
a { color: var(--accent); text-decoration: none; }

/* --- Header Bar --- */
.header-bar {
  background: var(--accent);
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-bar h1 {
  font-size: var(--font-lg);
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.header-bar .role-tag {
  background: rgba(255,255,255,0.2);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 600;
}

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: var(--font-lg);
  font-weight: 600;
  margin-bottom: 4px;
}
.card-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-min);
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: var(--font-base);
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  text-decoration: none;
}
.btn:active { opacity: 0.8; }
.btn-primary { background: var(--accent); color: white; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--error); color: white; }
.btn-block { display: flex; width: 100%; }
.btn-lg { min-height: 56px; font-size: var(--font-lg); padding: 16px 32px; }

/* --- Forms --- */
input, select, textarea {
  width: 100%;
  min-height: var(--touch-min);
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--font-base);
  background: var(--bg-input);
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
}
label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 14px;
  color: var(--text-secondary);
}
.form-group { margin-bottom: 16px; }

/* --- Lists --- */
.list-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  min-height: var(--touch-min);
  gap: 12px;
}
.list-item:last-child { border-bottom: none; }

/* --- Status indicators --- */
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot.green { background: var(--success); }
.status-dot.yellow { background: var(--warning); }
.status-dot.red { background: var(--error); }
.status-dot.gray { background: var(--text-muted); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-delegate { background: #dcedc8; color: #33691e; }
.badge-alternate { background: #fff9c4; color: #f57f17; }
.badge-candidate { background: #e3f2fd; color: #1565c0; }
.badge-vendor { background: #fce4ec; color: #c62828; }
.badge-chair { background: #e8eaf6; color: #283593; }
.badge-staff { background: #e0f2f1; color: #00695c; }
.badge-operator { background: #212121; color: #ffffff; }

/* --- Bottom Navigation --- */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: none;
  align-items: center;
  justify-content: space-around;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 11px;
  padding: 4px 0;
  position: relative;
  min-width: 56px;
}
.nav-item.active { color: var(--accent); }
.nav-icon { font-size: 22px; line-height: 1; }
.nav-label { margin-top: 2px; }
.nav-badge {
  position: absolute;
  top: -2px;
  right: 8px;
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* --- More Menu --- */
#more-menu { display: none; }
#more-menu.open { display: block; }
.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 300;
}
.menu-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-radius: 16px 16px 0 0;
  z-index: 301;
  max-height: 70vh;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border-light);
  font-weight: 600;
  font-size: var(--font-lg);
}
.menu-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  min-width: var(--touch-min);
  min-height: var(--touch-min);
}
.menu-items { padding: 8px 0; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  color: var(--text);
  text-decoration: none;
  font-size: var(--font-base);
  min-height: var(--touch-min);
}
.menu-item:active { background: var(--bg); }
.menu-item-icon { font-size: 20px; width: 28px; text-align: center; }
.menu-section { padding: 4px 0; }
.menu-section + .menu-section { border-top: 1px solid #e0e0e0; }
.menu-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #999;
  padding: 12px 16px 4px;
}
.menu-role-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  background: var(--red);
  color: #fff;
  padding: 2px 8px;
  border-radius: 3px;
  margin-left: auto;
  margin-right: 8px;
}
[data-theme="dark"] .menu-section + .menu-section { border-color: #333; }
[data-theme="dark"] .menu-section-label { color: #777; }

/* --- Scanner Flash Overlays --- */
.scan-flash {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 500;
  color: white;
  font-size: var(--font-xxl);
  font-weight: 700;
  text-align: center;
  padding: 32px;
  animation: flashFade 1.5s ease-out forwards;
}
.scan-flash.pass { background: var(--success); }
.scan-flash.fail { background: var(--error); }
.scan-flash.warn { background: var(--warning); }
.scan-flash .scan-name { font-size: 48px; margin-bottom: 8px; }
.scan-flash .scan-detail { font-size: var(--font-lg); font-weight: 400; opacity: 0.9; }

@keyframes flashFade {
  0% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; pointer-events: none; }
}

/* --- Direction Toggle --- */
.direction-toggle {
  display: flex;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--border);
}
.direction-toggle .toggle-btn {
  flex: 1;
  padding: 16px;
  font-size: var(--font-xl);
  font-weight: 700;
  border: none;
  cursor: pointer;
  text-align: center;
  min-height: 56px;
  transition: all 0.15s;
}
.toggle-btn.in-btn { background: #e8f5e9; color: var(--success); }
.toggle-btn.out-btn { background: #fbe9e7; color: var(--error); }
.toggle-btn.active.in-btn { background: var(--success); color: white; }
.toggle-btn.active.out-btn { background: var(--error); color: white; }

/* --- Counter --- */
.scan-counter {
  display: flex;
  gap: 16px;
  justify-content: center;
  padding: 12px;
  font-size: var(--font-xl);
  font-weight: 700;
}
.count-in { color: var(--success); }
.count-out { color: var(--error); }

/* --- Empty states --- */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
}
.empty-state h3 { margin-bottom: 8px; }

/* --- Loading --- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  color: var(--text-muted);
}

/* --- Page errors --- */
.page-error {
  text-align: center;
  padding: 48px 16px;
}
.page-error h2 { margin-bottom: 16px; }

/* --- Utility --- */
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }

/* --- Disclaimer --- */
.disclaimer {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 8px 16px;
  background: var(--border-light);
}
