/* ================================================
   FEEDBOK — Global Styles
   Design System: Focus Utility
   ================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* ---- Focus Design Tokens ---- */
  --primary:       #151412;
  --secondary:     #68655F;
  --tertiary:      #A39F98;
  --bg:            #F5F4F0;
  --bg-deep:       #ECEAE3;
  --surface:       #FFFFFF;
  --border:        #EAE8E2;
  --border-mid:    #DFDDD7;
  --border-strong: #CFCDC7;
  --text-ghost:    #C5C1BA;
  --accent:        #2750D6;
  --accent-hover:  #3460E8;
  --accent-light:  #EBF0FD;
  --accent-text:   #1A38A0;
  --green:         #137E44;
  --green-light:   #E3F4EC;
  --green-text:    #0C5430;
  --amber:         #905300;
  --amber-light:   #FDF0DC;
  --red:           #BA2B2B;
  --red-light:     #FAEBEB;
  --red-text:      #861E1E;
  --radius-sm:     7px;
  --radius-md:     14px;
  --radius-lg:     20px;
  --radius-full:   9999px;

  /* ---- Legacy aliases (used in EJS inline styles) ---- */
  --pink:       #2750D6;
  --pink-light: #EBF0FD;
  --dark:       #151412;
  --yellow:     #FDF0DC;
  --yellow-dark:#905300;
  --white:      #FFFFFF;
  --text:       #151412;
  --text-muted: #68655F;
  --error:      #BA2B2B;
  --success:    #137E44;
  --radius:     14px;
  --card-shadow: 0 1px 3px rgba(21,20,18,0.07), 0 1px 2px rgba(21,20,18,0.04);
}

::selection { background: var(--accent-light); color: var(--accent-text); }

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

html { scroll-behavior: smooth; background: var(--bg); }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 14px;
  line-height: 1.5;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
}

/* ---- Typography ---- */
h1, h2, h3, h4 { line-height: 1.1; font-weight: 600; color: var(--primary); }
h1 { font-size: 28px; letter-spacing: -0.9px; }
h2 { font-size: 20px; letter-spacing: -0.5px; }
h3 { font-size: 15px; letter-spacing: -0.2px; }
p { margin-bottom: 1rem; }
p:last-child { margin-bottom: 0; }

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

/* ---- Logo ---- */
.nav-logo-link { display: inline-flex; align-items: center; text-decoration: none; }
.nav-logo { height: 28px; width: auto; max-width: 160px; display: block; }
.nav-logo-link:hover { opacity: 0.75; }

/* ---- Navigation ---- */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
}

.nav-links a {
  color: var(--secondary);
  font-weight: 500;
  font-size: 13.5px;
  letter-spacing: -0.1px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color 0.1s, background 0.1s;
}
.nav-links a:hover {
  color: var(--primary);
  background: var(--bg-deep);
  text-decoration: none;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 13px;
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.2px;
  cursor: pointer;
  border: none;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.2;
}
.btn:hover { text-decoration: none; }
.btn:active { opacity: 0.85; }

.btn-primary {
  background: var(--primary);
  color: var(--surface);
}
.btn-primary:hover { background: #272420; color: var(--surface); }

.btn-yellow {
  background: var(--accent);
  color: var(--surface);
}
.btn-yellow:hover { background: var(--accent-hover); color: var(--surface); }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--border-mid);
}
.btn-outline:hover {
  border-color: var(--border-strong);
  color: var(--primary);
  background: var(--bg-deep);
}

.btn-ghost {
  background: var(--surface);
  color: var(--secondary);
  border: 1px solid var(--border-mid);
}
.btn-ghost:hover { border-color: var(--border-strong); color: var(--primary); }

.btn-danger {
  background: var(--red);
  color: white;
  border: 1px solid transparent;
}
.btn-danger:hover { background: #a02424; color: white; }

.btn-sm {
  padding: 6px 12px;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
}

.btn-full { width: 100%; }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-weight: 500;
  font-size: 12.5px;
  letter-spacing: -0.1px;
  margin-bottom: 6px;
  color: var(--secondary);
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border-mid);
  border-radius: 11px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--primary);
  background: var(--bg);
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
  outline: none;
  height: 46px;
}
.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-ghost); font-weight: 400; }

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(39,80,214,0.12);
}
.form-input:focus-visible,
.form-textarea:focus-visible,
.form-select:focus-visible {
  outline: 2px solid rgba(39,80,214,0.4);
  outline-offset: 2px;
}
.form-textarea {
  resize: vertical;
  min-height: 180px;
  line-height: 1.6;
  height: auto;
}
.form-hint {
  font-size: 12px;
  color: var(--tertiary);
  margin-top: 5px;
}

/* ---- Alerts ---- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 16px;
  border: 1px solid transparent;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.alert-error {
  background: var(--red-light);
  border-color: rgba(186,43,43,0.2);
  color: var(--red-text);
}
.alert-success {
  background: var(--green-light);
  border-color: rgba(19,126,68,0.2);
  color: var(--green-text);
}
.alert-info {
  background: var(--accent-light);
  border-color: rgba(39,80,214,0.2);
  color: var(--accent-text);
}

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}
.card-body { padding: 20px; }
.card-header {
  padding: 13px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-deep);
  font-size: 13px;
  font-weight: 500;
  color: var(--secondary);
}

/* ---- Layout ---- */
.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
}
.container-sm { max-width: 480px; }
.container-md { max-width: 640px; }

main { flex: 1; padding: 36px 20px; }

.page-header { margin-bottom: 28px; }
.page-header h1 {
  font-size: 20px;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}
.page-header p {
  color: var(--secondary);
  font-size: 13.5px;
}

/* ---- Auth Pages ---- */
.auth-page {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

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

.auth-logo { text-align: center; margin-bottom: 24px; }

.auth-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
  text-align: center;
  color: var(--primary);
}

.auth-subtitle {
  font-size: 13px;
  color: var(--secondary);
  text-align: center;
  margin-bottom: 24px;
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--secondary);
}

/* ---- QR Code Cards ---- */
.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.qr-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  transition: box-shadow 0.15s;
}
.qr-card:hover {
  box-shadow: 0 4px 14px rgba(21,20,18,0.1);
}

.qr-card-header {
  padding: 13px 16px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--bg-deep);
}

.qr-label {
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: -0.2px;
  color: var(--primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qr-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}
.qr-status.active {
  background: var(--green-light);
  color: var(--green-text);
}
.qr-status.inactive {
  background: var(--bg-deep);
  color: var(--secondary);
  border: 1px solid var(--border-mid);
}

.qr-image-wrap {
  padding: 20px;
  display: flex;
  justify-content: center;
  background: var(--surface);
}
.qr-image-wrap img {
  width: 152px;
  height: 152px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.qr-card-body { padding: 14px 16px; }

.qr-meta {
  font-size: 12px;
  color: var(--secondary);
  margin-bottom: 12px;
}

.qr-feedback-count {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
  margin-bottom: 10px;
}

.qr-progress {
  height: 3px;
  background: var(--border-mid);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 14px;
}
.qr-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.qr-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ---- Feedback Form Page ---- */
.feedback-page {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.feedback-hero {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 32px 20px;
  text-align: center;
}

.feedback-avatar {
  width: 68px;
  height: 68px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid var(--border-mid);
  margin-bottom: 12px;
}

.feedback-avatar-placeholder {
  width: 68px;
  height: 68px;
  border-radius: var(--radius-full);
  background: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--surface);
  margin-bottom: 12px;
  font-family: 'Inter', sans-serif;
  letter-spacing: -0.5px;
}

.feedback-notice {
  background: var(--accent-light);
  border: 1px solid rgba(39,80,214,0.2);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--accent-text);
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ---- Summary Page ---- */
.tone-tabs {
  display: flex;
  gap: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-mid);
  margin-bottom: 20px;
}

.tone-tab {
  flex: 1;
  padding: 10px 14px;
  border: none;
  background: var(--surface);
  color: var(--secondary);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.1px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  border-right: 1px solid var(--border-mid);
  text-align: center;
}
.tone-tab:last-child { border-right: none; }
.tone-tab:hover { background: var(--bg); color: var(--primary); }
.tone-tab.active {
  background: var(--primary);
  color: var(--surface);
}

.tone-content { display: none; }
.tone-content.active { display: block; }

.summary-text {
  background: var(--primary);
  border-radius: var(--radius-md);
  padding: 24px 28px;
  border: 1px solid rgba(21,20,18,0.8);
  font-size: 14px;
  line-height: 1.75;
  color: rgba(255,255,255,0.88);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 400;
}

/* ---- 404 Page ---- */
.page-404 {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  background: var(--bg);
}

.page-404 .eggs-wrap { margin-bottom: 24px; }

.page-404 .eggs-img {
  width: 160px;
  height: 160px;
  object-fit: contain;
  animation: wobble 2.5s ease-in-out infinite;
}

@keyframes wobble {
  0%, 100% { transform: rotate(-4deg) translateY(0); }
  25%       { transform: rotate(4deg) translateY(-8px); }
  50%       { transform: rotate(-2deg) translateY(-4px); }
  75%       { transform: rotate(3deg) translateY(-10px); }
}

.page-404 h1 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 5rem;
  font-weight: 500;
  color: var(--primary);
  letter-spacing: -4px;
  line-height: 1;
  margin-bottom: 12px;
}

.page-404 p {
  color: var(--secondary);
  font-size: 15px;
  margin-bottom: 24px;
}

/* ---- Logout Banner ---- */
.logout-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--primary);
  color: rgba(255,255,255,0.88);
  text-align: center;
  padding: 14px 20px;
  font-weight: 500;
  font-size: 14px;
  z-index: 9999;
  animation: slideDown 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to   { transform: translateY(0); }
}

.logout-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  background: var(--bg);
}

.logout-page h2 { margin-bottom: 8px; }
.logout-page p { color: var(--secondary); font-size: 14px; }

/* ---- Profile page ---- */
.avatar-preview-wrap {
  position: relative;
  display: inline-block;
  margin-bottom: 16px;
}

.avatar-preview {
  width: 88px;
  height: 88px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid var(--border-mid);
  display: block;
}

.avatar-placeholder {
  width: 88px;
  height: 88px;
  border-radius: var(--radius-full);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--surface);
  font-family: 'Inter', sans-serif;
}

.avatar-edit-btn {
  position: absolute;
  bottom: 0; right: 0;
  width: 26px; height: 26px;
  background: var(--primary);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--surface);
  font-size: 13px;
  border: 2px solid var(--surface);
}

/* ---- Flash messages ---- */
.flash-bar {
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
}
.flash-bar.success {
  background: var(--green-light);
  border-color: rgba(19,126,68,0.2);
  color: var(--green-text);
}
.flash-bar.warning {
  background: var(--amber-light);
  border-color: rgba(144,83,0,0.2);
  color: var(--amber);
}

/* ---- Modal ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(21,20,18,0.42);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 420px;
  width: 100%;
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(21,20,18,0.16);
}
.modal h3 { margin-bottom: 8px; }
.modal p { color: var(--secondary); margin-bottom: 20px; font-size: 13.5px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ---- Footer ---- */
.footer {
  background: var(--bg);
  padding: 20px 24px;
  margin-top: auto;
}

.footer-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  list-style: none;
  justify-content: center;
}

.footer-links a {
  font-size: 12.5px;
  color: var(--tertiary);
  letter-spacing: -0.1px;
}
.footer-links a:hover { color: var(--secondary); text-decoration: none; }

.footer-copy {
  font-size: 11.5px;
  color: var(--text-ghost);
  font-family: 'JetBrains Mono', monospace;
}

/* ---- Utility ---- */
.text-center { text-align: center; }
.text-muted { color: var(--secondary); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.w-full { width: 100%; }

.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1px;
}
.badge-pink {
  background: var(--green-light);
  color: var(--green-text);
}
.badge-yellow {
  background: var(--amber-light);
  color: var(--amber);
}

/* ---- Skip navigation ---- */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  background: var(--primary);
  color: var(--surface);
  padding: 8px 16px;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  z-index: 9999;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  transition: top 0.15s;
}
.skip-link:focus { top: 0; color: var(--surface); text-decoration: none; }

/* ---- Screen reader only ---- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ---- Focus visible ---- */
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.tone-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.nav-hamburger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.nav-links a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  text-decoration: none;
}
.invite-char:focus-visible {
  outline: 2px solid rgba(39,80,214,0.4);
  outline-offset: 2px;
}

/* ---- Hamburger menu ---- */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
}
.nav-hamburger span {
  display: block;
  width: 20px;
  height: 1.5px;
  background: var(--primary);
  border-radius: 2px;
  transition: all 0.2s;
}
.nav-hamburger.open span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

@media (max-width: 768px) {
  .nav-hamburger { display: flex; }
  .nav-links {
    display: none;
    position: absolute;
    top: 56px;
    left: 0; right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 10px 16px;
    gap: 2px;
    z-index: 99;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 10px 12px; display: block; }
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .auth-card { padding: 24px 20px; }
  .qr-grid { grid-template-columns: 1fr; }
  .page-404 h1 { font-size: 3.5rem; }
  .tone-tabs { flex-direction: column; }
  .tone-tab { border-right: none; border-bottom: 1px solid var(--border-mid); }
  .tone-tab:last-child { border-bottom: none; }
}
