/* Company Phone Book — friendly, approachable address-book UI.
   Trustworthy indigo-blue + warm amber accent, rounded Nunito headings,
   soft cards, alphabetical grouping with an A–Z quick-jump rail. */

:root {
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-on-primary: #ffffff;
  --color-accent: #f59e0b;         /* warm amber for friendliness */
  --color-accent-soft: #fef3c7;
  --color-green: #0ea472;
  --color-background: #f6f7fb;
  --color-surface: #ffffff;
  --color-foreground: #1e2130;
  --color-muted: #eef1fb;
  --color-muted-fg: #6b7280;
  --color-border: #e7e9f4;
  --color-destructive: #dc2626;
  --color-destructive-hover: #b91c1c;
  --color-ring: #4f46e5;

  /* Density 7/10 — standard spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;

  /* Soft, friendly shadows */
  --shadow-sm: 0 1px 2px rgba(30, 33, 48, 0.05), 0 2px 6px rgba(30, 33, 48, 0.05);
  --shadow-md: 0 6px 18px rgba(30, 33, 48, 0.09), 0 2px 6px rgba(30, 33, 48, 0.05);
  --shadow-lg: 0 16px 40px rgba(30, 33, 48, 0.18);

  --font-head: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

/* The [hidden] attribute must win over display rules set via class
   selectors (e.g. .contact-list { display:flex }). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-background);
  color: var(--color-foreground);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---- Header ---- */
.app-header {
  position: relative;
  background: radial-gradient(120% 140% at 15% 0%, #6d5ef0 0%, #4f46e5 45%, #4338ca 100%);
  color: #fff;
  z-index: 1;
  padding-bottom: 56px;      /* room for the hero panel to overlap */
  overflow: hidden;
}
/* Subtle decorative glow so the header isn't a flat block. */
.app-header::after {
  content: "";
  position: absolute;
  top: -60%;
  right: -10%;
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, rgba(255,255,255,0.18), transparent 62%);
  pointer-events: none;
}
.app-header__inner {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  position: relative;
  z-index: 1;
}
.brand { display: flex; align-items: center; gap: var(--space-3); }
.header-actions { display: flex; align-items: center; gap: var(--space-3); }

/* Lock / unlock status chip */
.lock-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-head);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.lock-chip:hover { background: rgba(255, 255, 255, 0.24); }
.lock-chip:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.5); }
.lock-chip.is-unlocked {
  background: #d1fae5;
  border-color: #6ee7b7;
  color: #047857;
}
.lock-chip__icon { display: inline-flex; }
.brand__mark {
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  backdrop-filter: blur(4px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}
.brand__title {
  font-family: var(--font-head);
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.1;
  color: #fff;
}
.brand__subtitle {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.82);
}

/* ---- Layout ---- */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 var(--space-5) var(--space-6);
}

/* ---- Hero panel (floats over the header edge) ---- */
.hero-panel {
  position: relative;
  margin-top: -40px;
  z-index: 2;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-5);
}

/* ---- Toolbar ---- */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.search { position: relative; flex: 1; }
.search__icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-muted-fg);
  pointer-events: none;
}
.search__input {
  width: 100%;
  padding: 14px 16px 14px 46px;
  font-family: var(--font-body);
  font-size: 0.98rem;
  color: var(--color-foreground);
  background: var(--color-muted);
  border: 1px solid transparent;
  border-radius: 999px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.search__input:hover { background: #e7ebfa; }
.search__icon { left: 18px; }
.search__input::placeholder { color: var(--color-muted-fg); }
.search__input:focus-visible {
  background: var(--color-surface);
  border-color: var(--color-ring);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.14);
}
.count {
  font-family: var(--font-head);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-muted-fg);
  white-space: nowrap;
  background: var(--color-muted);
  padding: 7px 14px;
  border-radius: 999px;
}

/* ---- Banner (errors / notices) ---- */
.banner {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  margin-bottom: var(--space-4);
  font-size: 0.9rem;
  border: 1px solid transparent;
}
.banner--error {
  background: #fef2f2;
  color: var(--color-destructive);
  border-color: #fecaca;
}
.banner--success {
  background: #ecfdf5;
  color: var(--color-accent);
  border-color: #a7f3d0;
}

/* ---- Directory layout (list + A–Z rail) ---- */
.directory {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
}
.directory__list { flex: 1; min-width: 0; }

/* Loading skeleton container keeps the old simple stack */
#loading { display: flex; flex-direction: column; gap: var(--space-3); }

/* ---- Alphabetical letter groups ---- */
.letter-group { margin-bottom: var(--space-5); scroll-margin-top: 84px; }
.letter-group__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0 0 var(--space-3) 2px;
}
.letter-group__letter {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--color-primary);
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: var(--color-muted);
  border-radius: 10px;
}
.letter-group__count {
  font-family: var(--font-head);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-muted-fg);
}
.letter-group__head::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--color-border), transparent);
}
/* Two-column card grid on wider screens to fill space and feel modern. */
.letter-group__cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}
@media (max-width: 720px) {
  .letter-group__cards { grid-template-columns: 1fr; }
}

/* ---- Contact card (vertical layout) ---- */
.contact {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  /* Staggered entrance */
  animation: card-in 380ms cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--i, 0) * 40ms);
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.contact:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  border-color: #d9dcf0;
}
.contact__top {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.contact__ident { flex: 1; min-width: 0; }
.contact__details {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-top: var(--space-3);
  border-top: 1px dashed var(--color-border);
}
/* Actions fade in on hover for a cleaner resting state (still keyboard-focusable). */
.contact__actions { opacity: 0.35; transition: opacity var(--transition); }
.contact:hover .contact__actions,
.contact:focus-within .contact__actions { opacity: 1; }
.avatar {
  flex: none;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.15rem;
  text-transform: uppercase;
  box-shadow: var(--shadow-sm), inset 0 0 0 3px rgba(255, 255, 255, 0.35);
}
.contact__body { flex: 1; min-width: 0; }
.contact__name {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.08rem;
  margin: 0;
  color: var(--color-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- A–Z quick-jump rail ---- */
.az-index {
  position: sticky;
  top: 90px;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: var(--space-2) 2px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.az-index__letter {
  font-family: var(--font-head);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-primary);
  text-decoration: none;
  width: 22px;
  height: 19px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  transition: background var(--transition), color var(--transition), transform var(--transition);
}
.az-index__letter:hover {
  background: var(--color-primary);
  color: #fff;
  transform: scale(1.15);
}
.az-index__letter.is-empty {
  color: #c4c8dc;
  cursor: default;
  pointer-events: none;
}
.contact__meta {
  margin: 6px 0 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px var(--space-4);
  font-size: 0.92rem;
}
/* Shared meta chip: darker, readable text with a colored icon cue. */
.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #334155;
  font-weight: 500;
}
.meta-item svg { flex: none; }
/* Phone reads as an actionable call link. */
.meta-item--phone {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 700;
}
.meta-item--phone svg { color: var(--color-primary); }
.meta-item--phone:hover { color: var(--color-primary-hover); text-decoration: underline; }
.meta-item--phone:hover svg { color: var(--color-primary-hover); }
/* Location: readable slate text with an amber pin. */
.meta-item--location svg { color: var(--color-accent); }
/* State sits on its own row beneath the suburb, slightly quieter. */
.meta-item--state { color: var(--color-muted-fg); font-weight: 600; }
.meta-item--state svg { color: #8b93a7; }
.dept-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-muted);
  color: #4338ca;
  padding: 3px 11px 3px 9px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}
.dept-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
}
.contact__actions { display: flex; gap: var(--space-2); flex: none; }

/* ---- Buttons ---- */
.btn {
  font-family: var(--font-head);
  font-size: 0.9rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition),
    border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.btn { font-weight: 700; border-radius: 999px; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.35);
}
.btn--primary {
  background: var(--color-primary);
  color: var(--color-on-primary);
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover { background: var(--color-primary-hover); }
.btn--primary[disabled] { opacity: 0.6; cursor: not-allowed; }

/* The Add button lives on the indigo header — make it pop in warm amber. */
.app-header .btn--primary {
  background: var(--color-accent);
  color: #3a2600;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}
.app-header .btn--primary:hover { background: #f0980a; }
.btn--ghost {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-foreground);
}
.btn--ghost:hover { background: var(--color-muted); }
.btn--icon {
  padding: 8px;
  width: 38px;
  height: 38px;
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-muted-fg);
}
.btn--icon:hover { background: var(--color-muted); color: var(--color-primary); }
.btn--icon.is-danger:hover {
  color: var(--color-destructive);
  border-color: #fca5a5;
  background: #fef2f2;
}

/* ---- Empty & skeleton ---- */
.empty-state {
  text-align: center;
  padding: var(--space-6) var(--space-5);
  color: var(--color-muted-fg);
}
.empty-state svg { color: #cbd5e1; margin-bottom: var(--space-3); }
.empty-state__title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--color-foreground);
  margin: 0 0 var(--space-1);
}
.empty-state__hint { margin: 0; }

.skeleton-card {
  height: 80px;
  border-radius: var(--radius-lg);
  background: linear-gradient(90deg, #eef2f9 25%, #f6f9ff 37%, #eef2f9 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border: 1px solid var(--color-border);
}
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

/* ---- Dialog ---- */
.dialog {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  width: min(460px, calc(100vw - 32px));
  box-shadow: var(--shadow-lg);
  color: var(--color-foreground);
}
.dialog::backdrop {
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
}
.dialog[open] { animation: dialog-in 200ms cubic-bezier(0.4, 0, 0.2, 1); }
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.form { padding: var(--space-5); }
.form__title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.2rem;
  margin: 0 0 var(--space-5);
}
.form__hint {
  margin: calc(-1 * var(--space-3)) 0 var(--space-5);
  color: var(--color-muted-fg);
  font-size: 0.9rem;
}
.field { display: block; margin-bottom: var(--space-4); }
.field__label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-foreground);
  margin-bottom: 6px;
}
.req { color: var(--color-destructive); }
.field input, .field select {
  width: 100%;
  padding: 11px 13px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--color-foreground);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.field select { height: 44px; cursor: pointer; }
.field input:focus-visible, .field select:focus-visible {
  border-color: var(--color-ring);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}
.field input[aria-invalid="true"],
.field select[aria-invalid="true"] {
  border-color: var(--color-destructive);
}
.field__error {
  display: block;
  min-height: 1em;
  margin-top: 5px;
  font-size: 0.8rem;
  color: var(--color-destructive);
}
.form__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .app-header__inner, .container { padding-left: var(--space-4); padding-right: var(--space-4); }
  .btn--primary .btn__label, .brand__subtitle { display: none; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .count { align-self: flex-start; }
  /* Hide the A–Z rail on small screens — search covers navigation there. */
  .az-index { display: none; }
  .avatar { width: 48px; height: 48px; font-size: 1.05rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
