/* WaPanel — single-operator WhatsApp Cloud API console.
   Light theme only, by product decision. */

:root {
  --wa-teal: #075e54;
  --wa-teal-dark: #054c44;
  --wa-green: #25d366;
  --wa-green-dark: #128c7e;
  --wa-chat-bg: #efeae2;
  --wa-bubble-in: #ffffff;
  --wa-bubble-out: #d9fdd3;
  --wa-panel: #ffffff;
  --wa-border: #e4e6e8;
  --wa-muted: #667781;
  --wa-ink: #111b21;
  --wa-hover: #f5f6f6;
  --wa-active: #f0f2f5;

  --nav-w: 232px;
  --list-w: 360px;
  --info-w: 320px;
  --topbar-h: 56px;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--wa-ink);
  background: var(--wa-active);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.925rem;
}

a { text-decoration: none; }

/* ------------------------------------------------------------------ shell */

.app-shell {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

.app-nav {
  width: var(--nav-w);
  flex: 0 0 var(--nav-w);
  background: var(--wa-teal);
  color: #d7ded9;
  display: flex;
  flex-direction: column;
}

.app-nav .brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 0 1rem;
  color: #fff;
  font-weight: 600;
  letter-spacing: .01em;
  background: var(--wa-teal-dark);
  flex: 0 0 auto;
}

.app-nav .brand i { font-size: 1.35rem; color: var(--wa-green); }

.app-nav .nav-scroll { overflow-y: auto; padding: .5rem 0; flex: 1 1 auto; }

.app-nav a.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1rem;
  color: #d7ded9;
  border-left: 3px solid transparent;
  white-space: nowrap;
}

.app-nav a.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }

.app-nav a.nav-item.active {
  background: rgba(255, 255, 255, .12);
  color: #fff;
  border-left-color: var(--wa-green);
}

.app-nav a.nav-item i { width: 1.25rem; text-align: center; font-size: 1.05rem; }

.app-nav .nav-badge {
  margin-left: auto;
  background: var(--wa-green);
  color: #06231c;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  padding: .05rem .45rem;
}

.app-nav .nav-foot {
  flex: 0 0 auto;
  padding: .75rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, .12);
  font-size: .8rem;
}

.app-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--wa-active);
}

.app-topbar {
  height: var(--topbar-h);
  flex: 0 0 auto;
  background: var(--wa-panel);
  border-bottom: 1px solid var(--wa-border);
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 0 1rem;
}

.app-topbar .page-title { font-weight: 600; font-size: 1.02rem; margin: 0; }

.app-body { flex: 1 1 auto; min-height: 0; overflow: auto; }

.app-body.is-flush { overflow: hidden; }

.content-pad { padding: 1.25rem; }

/* Mobile: the nav becomes an off-canvas drawer. */
.nav-toggle { display: none; }
.nav-backdrop { display: none; }

@media (max-width: 991.98px) {
  .nav-toggle { display: inline-flex; }

  .app-nav {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1045;
    transform: translateX(-100%);
    transition: transform .18s ease-out;
  }

  .app-shell.nav-open .app-nav { transform: none; }

  .app-shell.nav-open .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1040;
    background: rgba(0, 0, 0, .35);
  }
}

/* ------------------------------------------------------------------ cards */

.stat-card {
  background: var(--wa-panel);
  border: 1px solid var(--wa-border);
  border-radius: .6rem;
  padding: .9rem 1rem;
  height: 100%;
}

.stat-card .stat-label {
  color: var(--wa-muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .2rem;
}

.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }

.stat-card .stat-sub { color: var(--wa-muted); font-size: .8rem; }

.panel {
  background: var(--wa-panel);
  border: 1px solid var(--wa-border);
  border-radius: .6rem;
}

.panel > .panel-head {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--wa-border);
  font-weight: 600;
}

.panel > .panel-body { padding: 1rem; }

/* ------------------------------------------------------------------ inbox */

.inbox {
  display: flex;
  height: 100%;
  min-height: 0;
}

.inbox-list {
  width: var(--list-w);
  flex: 0 0 var(--list-w);
  background: var(--wa-panel);
  border-right: 1px solid var(--wa-border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.inbox-list .list-head {
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--wa-border);
  flex: 0 0 auto;
}

.inbox-list .list-scroll { overflow-y: auto; flex: 1 1 auto; }

.conv-item {
  display: flex;
  gap: .7rem;
  padding: .65rem .75rem;
  border-bottom: 1px solid var(--wa-border);
  cursor: pointer;
  color: inherit;
}

.conv-item:hover { background: var(--wa-hover); }
.conv-item.active { background: var(--wa-active); }

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--wa-green-dark);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex: 0 0 auto;
  text-transform: uppercase;
}

.avatar.sm { width: 32px; height: 32px; font-size: .8rem; }
.avatar.lg { width: 76px; height: 76px; font-size: 1.6rem; }

.conv-main { min-width: 0; flex: 1 1 auto; }
.conv-top { display: flex; align-items: baseline; gap: .5rem; }
.conv-name { font-weight: 600; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { color: var(--wa-muted); font-size: .72rem; flex: 0 0 auto; }
.conv-preview { color: var(--wa-muted); font-size: .84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.unread-pill {
  background: var(--wa-green);
  color: #06231c;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 700;
  padding: .05rem .4rem;
}

.inbox-thread {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--wa-chat-bg);
  min-height: 0;
}

.thread-head {
  flex: 0 0 auto;
  background: var(--wa-panel);
  border-bottom: 1px solid var(--wa-border);
  padding: .5rem .75rem;
  display: flex;
  align-items: center;
  gap: .7rem;
}

.thread-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1rem .75rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.thread-compose {
  flex: 0 0 auto;
  background: var(--wa-panel);
  border-top: 1px solid var(--wa-border);
  padding: .6rem .75rem;
}

.inbox-info {
  width: var(--info-w);
  flex: 0 0 var(--info-w);
  background: var(--wa-panel);
  border-left: 1px solid var(--wa-border);
  overflow-y: auto;
}

@media (max-width: 1199.98px) {
  .inbox-info { display: none; }
}

@media (max-width: 767.98px) {
  .inbox-list { width: 100%; flex: 1 1 auto; border-right: 0; }
  .inbox-thread { display: none; }

  /* On a phone the thread takes the whole screen, WhatsApp style. */
  .inbox.show-thread .inbox-list { display: none; }
  .inbox.show-thread .inbox-thread { display: flex; }
}

/* --------------------------------------------------------------- bubbles */

.msg-row { display: flex; }
.msg-row.out { justify-content: flex-end; }

.bubble {
  max-width: min(78%, 560px);
  background: var(--wa-bubble-in);
  border-radius: .5rem;
  padding: .4rem .6rem .3rem;
  box-shadow: 0 1px .5px rgba(11, 20, 26, .13);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.msg-row.out .bubble { background: var(--wa-bubble-out); }

.bubble .bubble-text { white-space: pre-wrap; }

.bubble .bubble-meta {
  display: flex;
  align-items: center;
  gap: .25rem;
  justify-content: flex-end;
  color: var(--wa-muted);
  font-size: .68rem;
  margin-top: .1rem;
}

.bubble.failed { background: #fdecea; }

.bubble .tick-read { color: #53bdeb; }

.bubble-media img,
.bubble-media video {
  max-width: 100%;
  border-radius: .35rem;
  display: block;
}

.bubble-detail {
  margin-top: .35rem;
  border-top: 1px dashed var(--wa-border);
  padding-top: .3rem;
  font-size: .72rem;
  color: var(--wa-muted);
}

.bubble-detail dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: .1rem .5rem; }
.bubble-detail dt { font-weight: 600; }
.bubble-detail dd { margin: 0; overflow-wrap: anywhere; }

.day-divider {
  align-self: center;
  background: rgba(255, 255, 255, .85);
  border-radius: .5rem;
  padding: .15rem .6rem;
  font-size: .72rem;
  color: var(--wa-muted);
  margin: .5rem 0;
}

/* ---------------------------------------------------- service window chip */

.window-chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  border-radius: 999px;
  padding: .15rem .6rem;
  font-size: .78rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.window-chip.open { background: #e7f7ec; color: #0f5132; border-color: #badbcc; }
.window-chip.warn { background: #fff4d6; color: #7a5a00; border-color: #ffe08a; }
.window-chip.closed { background: #fdecea; color: #842029; border-color: #f5c2c7; }

.window-banner {
  background: #fdecea;
  border-top: 1px solid #f5c2c7;
  color: #842029;
  padding: .75rem;
}

.window-banner.warn { background: #fff4d6; border-top-color: #ffe08a; color: #7a5a00; }

/* ------------------------------------------------------------------ misc */

.text-muted-sm { color: var(--wa-muted); font-size: .82rem; }

.btn-wa { background: var(--wa-green-dark); border-color: var(--wa-green-dark); color: #fff; }
.btn-wa:hover, .btn-wa:focus { background: var(--wa-teal); border-color: var(--wa-teal); color: #fff; }

.tag-chip {
  display: inline-block;
  border-radius: 999px;
  padding: .05rem .5rem;
  font-size: .74rem;
  font-weight: 600;
  color: #fff;
}

.empty-state { text-align: center; color: var(--wa-muted); padding: 3rem 1rem; }
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: .5rem; opacity: .5; }

.drop-target { outline: 3px dashed var(--wa-green-dark); outline-offset: -8px; }

.table-sticky thead th { position: sticky; top: 0; background: var(--wa-panel); z-index: 2; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .78rem; }
