/* Exhibition Lead Tracker -- Worldia brand tokens
   Colors sampled from the Worldia PPT template (diamond logo + header
   gradient) so this tool feels like the same company's material.
   Fonts: deliberately using a system font stack rather than a webfont --
   this app runs on booth WiFi that may have no internet, and branding
   should not silently break if a font CDN is unreachable. Weight and
   letter-spacing carry the "clean, confident" feel instead. */

:root {
  --navy: #0C5196;
  --blue: #2E7BB8;
  --sky: #249CD1;
  --ice: #EAF3FA;
  --ink: #1A1F26;
  --muted: #6B7480;
  --line: #E4E8EC;
  --paper: #F7F9FB;
  --white: #FFFFFF;

  --amber: #D98C1F;
  --green: #3E9B5C;
  --red: #D64545;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
}

a { color: var(--navy); }

h1, h2, h3 {
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 .5em;
}

/* ---------- Header / nav ----------
   Phones: a horizontal top bar (today's layout).
   iPad and wider (see .app-shell below): the same markup becomes a
   persistent left sidebar, the standard iPad app pattern -- nav stays in
   reach with a thumb from any scroll position, and it reclaims the top of
   the screen for content instead of a bar that just repeats on every page. */

.topbar {
  background: linear-gradient(100deg, var(--navy) 0%, var(--blue) 55%, var(--sky) 100%);
  color: var(--white);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.topbar .brand {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 20px;
  height: 20px;
  flex: none;
  background: var(--white);
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  display: none;
}

.topbar .brand small {
  font-weight: 500;
  opacity: .85;
  font-size: .78rem;
  display: block;
}

.topbar nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.topbar nav a {
  color: var(--white);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 600;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  min-height: 44px;
  display: flex;
  align-items: center;
}

.topbar nav a.active,
.topbar nav a:hover {
  background: rgba(255,255,255,0.22);
}

.topbar .who {
  font-size: .82rem;
  opacity: .9;
  display: flex;
  align-items: center;
  gap: 10px;
}

.who-logout {
  color: var(--white);
  min-height: 44px;
  display: flex;
  align-items: center;
}

/* ---------- Layout ---------- */

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-main {
  flex: 1;
  min-width: 0;
}

.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 18px 16px 80px;
}

/* Tablet and up: flip the top bar into a fixed-width sidebar. The
   breakpoint (768px) sits below every iPad's portrait width (>=744px)
   and above the widest iPhones, so this targets "iPad or bigger" without
   a device check. */
@media (min-width: 768px) {
  .app-shell { flex-direction: row; }

  .topbar {
    flex: none;
    width: 240px;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 28px;
    padding: 28px 18px;
    min-height: 100vh;
    position: sticky;
    top: 0;
    align-self: flex-start;
  }

  .brand-mark { display: block; }

  .topbar .brand { flex-direction: row; }
  .topbar .brand-text { display: flex; flex-direction: column; gap: 2px; }

  .topbar nav { flex-direction: column; gap: 4px; }
  .topbar nav a { width: 100%; }

  .topbar .who {
    margin-top: auto;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,.18);
  }

  .page { max-width: 960px; padding: 32px 40px 80px; }
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 22px 0 10px;
}

.section-head h2 {
  font-size: 1.05rem;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Diamond facet marker used as a signature accent next to section titles */
.section-head h2::before {
  content: "";
  width: 9px;
  height: 9px;
  background: var(--sky);
  transform: rotate(45deg);
  display: inline-block;
  border-radius: 2px;
}

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

/* ---------- Forms ---------- */

label {
  display: block;
  font-size: .82rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
}

.field {
  margin-bottom: 16px;
}

/* Pairs up short fields (Contact Name + Position, Country + Type, ...) so
   an iPad in either orientation doesn't spend its width on empty margin
   either side of one narrow input -- collapses to a single column on
   phones, where there isn't room to spare. */
.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0 16px;
}

@media (min-width: 620px) {
  .field-grid { grid-template-columns: 1fr 1fr; }
}

.field-hint {
  font-size: .78rem;
  color: var(--muted);
  margin-top: 4px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.checkbox-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: .9rem;
  font-weight: 500;
  color: var(--ink);
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  cursor: pointer;
}

.checkbox-option input[type=checkbox] {
  width: 20px;
  height: 20px;
  accent-color: var(--navy);
  flex: none;
}

.checkbox-option:has(input:checked) {
  border-color: var(--blue);
  background: var(--ice);
}

/* Touch targets: 20x20 boxes with generous hit-area padding beat the
   browser-default ~13px checkbox/radio, which is hard to tap reliably
   with a fingertip on a glass screen. */
input[type=checkbox],
input[type=radio] {
  width: 20px;
  height: 20px;
  accent-color: var(--navy);
  flex: none;
}

input[type=text],
input[type=email],
input[type=tel],
input[type=date],
input[type=password],
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 1rem;
  font-family: var(--font);
  background: var(--white);
  color: var(--ink);
}

textarea { min-height: 96px; resize: vertical; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(46,123,184,0.18);
}

.inline-field {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.inline-field > *:first-child { flex: 1; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 11px 18px;
  border-radius: 8px;
  border: none;
  font-size: .92rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  font-family: var(--font);
  white-space: nowrap;
}

.btn-primary { background: var(--navy); color: var(--white); }
.btn-primary:hover { background: #0a4179; }

.btn-outline {
  background: var(--white);
  color: var(--blue);
  border: 1px solid var(--blue);
}
.btn-outline:hover { background: var(--ice); }

.btn-update {
  background: var(--white);
  color: var(--blue);
  border: 1px solid var(--blue);
  min-height: 44px;
  padding: 8px 16px;
  font-size: .85rem;
}
.btn-update:hover { background: var(--ice); }
.btn-update.saved { background: var(--green); border-color: var(--green); color: var(--white); }

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

.btn-sm { min-height: 38px; padding: 7px 12px; font-size: .8rem; }
.btn-block { width: 100%; }

.action-bar {
  position: sticky;
  bottom: 0;
  background: var(--white);
  border-top: 1px solid var(--line);
  padding: 12px 16px;
  margin: 0 -16px;
  display: flex;
  gap: 10px;
}

@media (min-width: 768px) {
  /* .page has more side padding at this width; match it so the bar still
     bleeds flush to the edges of .app-main instead of leaving a gap. */
  .action-bar { margin: 0 -40px; padding: 16px 40px; }
}

/* ---------- Tags / badges ---------- */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .75rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--ice);
  color: var(--navy);
}

.tag-amber { background: #FCF1DF; color: #93600F; }
.tag-green { background: #E4F4E9; color: #2A7245; }
.tag-red { background: #FBE7E7; color: #A32E2E; }
.tag-muted { background: var(--line); color: var(--muted); }
.tag-owner { background: var(--white); border: 1px solid var(--sky); color: var(--navy); padding-left: 4px; }
.tag-exhibition { background: var(--navy); color: var(--white); }

.avatar-xs {
  width: 16px;
  height: 14px;
  font-size: .55rem;
}

.avatar {
  width: 28px;
  height: 24px;
  background: var(--navy);
  color: var(--white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  font-weight: 800;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

/* ---------- Lead list ---------- */

.lead-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  margin-bottom: 8px;
  text-decoration: none;
  color: inherit;
}

.lead-row:hover { border-color: var(--blue); }

.lead-row .main { min-width: 0; }
.lead-row .company { font-weight: 700; font-size: 1rem; }
.lead-row .meta { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.lead-row .tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.filters-bar select, .filters-bar input {
  width: auto;
  min-width: 140px;
  min-height: 44px;
  font-size: .85rem;
  padding: 10px 12px;
}

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--muted);
}
.empty-state .diamond {
  width: 34px;
  height: 34px;
  background: var(--ice);
  border: 2px solid var(--sky);
  transform: rotate(45deg);
  margin: 0 auto 16px;
  border-radius: 4px;
}

/* ---------- Attachments ---------- */

.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.attachment-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--white);
}
.attachment-item img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  display: block;
  background: var(--ice);
}
.attachment-item .meta {
  padding: 6px 8px;
  font-size: .72rem;
  color: var(--muted);
}
.attachment-item .file-generic {
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ice);
  color: var(--blue);
  font-weight: 800;
  font-size: .75rem;
}

/* ---------- Follow-ups ---------- */

.followup-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  background: var(--white);
}
.followup-grid {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
@media (max-width: 640px) {
  .followup-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- Login ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(160deg, var(--ice) 0%, var(--white) 55%),
    repeating-linear-gradient(115deg, rgba(12,81,150,0.05) 0 2px, transparent 2px 22px);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: 0 20px 40px rgba(12,81,150,0.08);
  text-align: center;
}
.login-diamond {
  width: 42px;
  height: 42px;
  margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--sky), var(--navy));
  transform: rotate(45deg);
  border-radius: 8px;
}
.login-card h1 {
  font-size: 1.25rem;
  color: var(--navy);
  margin-bottom: 2px;
}
.login-card .sub {
  color: var(--muted);
  font-size: .85rem;
  margin-bottom: 22px;
}
.login-card form { text-align: left; }

/* ---------- Flash messages ---------- */

.flash {
  padding: 12px 14px;
  border-radius: 8px;
  font-size: .88rem;
  margin-bottom: 14px;
  font-weight: 600;
}
.flash-success { background: #E4F4E9; color: #2A7245; }
.flash-error { background: #FBE7E7; color: #A32E2E; }

.text-muted { color: var(--muted); font-size: .85rem; }

/* ---------- Options admin screen ---------- */

.option-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.option-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.option-row.option-inactive {
  opacity: .55;
  background: var(--ice);
}
.option-rename-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 220px;
  min-width: 200px;
}
.option-rename-form input[type="text"] {
  flex: 1;
  min-height: 44px;
}
.option-usage {
  font-size: .8rem;
  color: var(--muted);
  white-space: nowrap;
}
.option-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.option-actions form { display: inline-flex; }
.option-add-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px dashed var(--line);
  padding-top: 14px;
}
.option-add-form input[type="text"] {
  flex: 1;
  min-width: 200px;
  min-height: 44px;
}
