/* =========================================================
   MYCHAT — GLOBAL (shared)
   Base variables + helpers + generic components
   ========================================================= */

/* =========================================================
   Design tokens / safe-area / layout constants
   ========================================================= */
:root{
  /* unified palette */
  --bg: radial-gradient(circle at top left, #ffffff 0, #f8f7f4 40%, #ece9e0 100%);
  --card-1: #fffbea;
  --card-2: #f0f6ff;

  --border: #e0ded7;
  --text: #222;
  --muted: #777;

  --primary: #4a6cf7;
  --danger: #ff6b6b;

  --radius: 18px;
  --shadow: 0 10px 25px rgba(0,0,0,.08);

  /* safe-area */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  /* bottom nav constants */
  --mc-nav-h: 64px;
  --mc-bottomnav-h: 64px;

  /* z-index stack */
  --mc-header-z: 60;
  --mc-compose-z: 65;
  --mc-bottomnav-z: 6000;
}

/* =========================================================
   Reset / base
   ========================================================= */
*, *::before, *::after{
  box-sizing: border-box;
}

body.mychat-body{
  background: var(--bg);
  background-attachment: fixed;

  min-height: 100vh;
  min-height: 100dvh;

  margin: 0;
  padding: 0;

  padding-left: var(--safe-left);
  padding-right: var(--safe-right);

  overflow: hidden;
}

/* Shared scrollable page shell */
.mc-screen,
.mc-page{
  height: calc(100dvh - var(--safe-top));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--mc-nav-h) + var(--safe-bottom) + 12px);
}

/* =========================================================
   Utilities
   ========================================================= */
.muted{
  color: var(--muted);
}

.small{
  font-size: 13px;
}

.hidden{
  display: none !important;
}

/* =========================================================
   Buttons (generic)
   ========================================================= */
.btn{
  appearance: none;
  border: none;
  cursor: pointer;
  border-radius: 999px;
  padding: 10px 12px;
  font-weight: 800;
  font-size: 13px;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  width: auto;

  color: #fff;
  background: linear-gradient(135deg, var(--primary), #8a9eff);
  box-shadow: 0 4px 12px rgba(74,108,247,.45);
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}

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

.btn:active{
  transform: scale(.99);
  box-shadow: 0 3px 10px rgba(74,108,247,.35);
}

.btn-secondary{
  color: var(--text);
  background: rgba(255,255,255,.75);
  border: 1px solid rgba(0,0,0,.08);
  box-shadow: 0 6px 16px rgba(0,0,0,.06);
}

.btn-danger{
  color: #fff;
  background: linear-gradient(135deg, #ff6b6b, #ff9b9b);
  box-shadow: 0 4px 12px rgba(255,107,107,.35);
}

/* =========================================================
   Cards (generic)
   ========================================================= */
.card{
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

/* =========================================================
   Icon button (generic)
   ========================================================= */
.icon-btn{
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.10);
  background: rgba(255,255,255,.85);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-btn:active{
  transform: scale(.99);
}

.icon-btn.danger{
  border-color: rgba(220,38,38,.25);
  color: #dc2626;
}

/* =========================================================
   Modal (generic)
   ========================================================= */
.modal-backdrop{
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);

  align-items: center;
  justify-content: center;

  padding: 16px;
  padding-bottom: calc(16px + var(--safe-bottom));
}

.modal-backdrop.is-open{
  display: flex;
}

.modal{
  width: min(520px, 100%);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
  padding: 16px;
}

.modal h3{
  margin: 4px 0 12px;
  font-size: 18px;
}

.modal .row{
  margin: 10px 0;
}

.modal input[type="text"],
.modal input[type="file"],
.modal input[type="email"],
.modal input[type="password"]{
  width: 100%;
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  background: #fff;
}

.modal .actions{
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* =========================================================
   Bottom navigation (global)
   ========================================================= */
.mc-bottom-nav{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--mc-bottomnav-z);

  height: calc(var(--mc-nav-h) + var(--safe-bottom));
  padding: 8px 10px calc(8px + var(--safe-bottom));
  box-sizing: border-box;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;

  background: rgba(255,255,255,.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid rgba(0,0,0,.06);
}

.mc-nav-item{
  flex: 1 1 0;
  min-width: 0;
  height: 100%;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;

  padding: 6px 8px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  box-sizing: border-box;

  text-decoration: none;
  font: inherit;
  color: #6b7280;
  outline: none;
  -webkit-tap-highlight-color: transparent;

  transition:
    color .18s ease,
    background-color .18s ease,
    transform .12s ease;
}

.mc-nav-item:link,
.mc-nav-item:visited{
  color: #6b7280;
}

.mc-nav-item i,
.mc-nav-item span{
  color: inherit;
}

.mc-nav-item i{
  font-size: 18px;
  line-height: 1;
}

.mc-nav-item span{
  font-size: 12px;
  line-height: 1.1;
  font-weight: 600;
  white-space: nowrap;
}

.mc-nav-item:active{
  transform: scale(.97);
}

.mc-nav-item.active,
.mc-nav-item[aria-current="page"]{
  background: rgba(59,130,246,.10);
  color: #111827;
}

.mc-nav-item.active i,
.mc-nav-item[aria-current="page"] i{
  color: #2563eb;
}

.mc-nav-item.active span,
.mc-nav-item[aria-current="page"] span{
  color: #111827;
}

.mc-page--with-bottom-nav{
  padding-bottom: calc(var(--mc-nav-h) + var(--safe-bottom) + 12px);
}

/* =========================================================
   Sticky helpers (generic)
   ========================================================= */
.mc-sticky-header{
  position: sticky;
  top: 0;
  z-index: var(--mc-header-z);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0,0,0,.06);
}

.mc-sticky-compose{
  position: sticky;
  bottom: calc(var(--mc-bottomnav-h) + var(--safe-bottom));
  z-index: var(--mc-compose-z);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid rgba(0,0,0,.06);
}

/* =========================================================
   Contact Action Sheet (shared)
   ========================================================= */
.mc-sheet-backdrop{
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 14px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.mc-sheet-backdrop.is-open{
  display: flex;
}

.mc-sheet{
  width: min(520px, 100%);
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0,0,0,.22);
  overflow: hidden;
}

.mc-sheet-head{
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  border-bottom: 1px solid rgba(0,0,0,.06);
}

.mc-sheet-ava{
  width: 46px;
  height: 46px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.10);
  overflow: hidden;
  background: #fff;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.mc-sheet-ava img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.mc-sheet-ava span{
  font-weight: 900;
  color: var(--text);
}

.mc-sheet-meta{
  min-width: 0;
  flex: 1;
}

.mc-sheet-name{
  font-weight: 900;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.1;
}

.mc-sheet-sub{
  margin-top: 2px;
  font-size: 12px;
  color: rgba(17,24,39,.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mc-sheet-close{
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.10);
  background: rgba(255,255,255,.85);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.mc-sheet-actions{
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mc-sheet-btn{
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,.08);
  background: rgba(255,255,255,.85);
  padding: 12px 12px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  cursor: pointer;
}

.mc-sheet-btn:active{
  transform: scale(.99);
}

.mc-sheet-btn.danger{
  border-color: rgba(220,38,38,.25);
  background: rgba(255,235,235,.75);
  color: #b91c1c;
}

.mc-sheet-msg{
  padding: 0 12px 12px;
  min-height: 18px;
}

/* =========================================================
   Mobile input zoom prevention
   ========================================================= */
input,
textarea,
select{
  font-size: 16px
  -webkit-text-size-adjust: 100%;
}

/* =========================
   CARDS (auth + feature)
   ========================= */

.auth-card,
.feature-card{
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  border: 1px solid rgba(0,0,0,.03);
  animation: fadeUp .35s ease-out both;
}

/* auth */
.auth-card{
  background: var(--card-1);
  box-shadow: 0 6px 16px rgba(0,0,0,.06);
  animation-delay: .05s;
}

/* feature */
.feature-card{
  background: var(--card-2);
  box-shadow: 0 6px 16px rgba(0,0,0,.04);
}

.feature-card:nth-of-type(1){ animation-delay: .1s; }
.feature-card:nth-of-type(2){ animation-delay: .15s; }

/* =========================
   FEATURE CARD CONTENT
   ========================= */

.feature-card--spaced{
  margin-top: 10px;
}

.card-title{
  display:flex;
  align-items:center;
  gap:8px;
  font-weight:600;
  font-size:14px;
  margin-bottom:6px;
}

.card-subtitle{
  margin-bottom:0;
  font-size:13px;
  color: var(--text);
}

/* list */
.feature-list{
  margin-top:8px;
  padding-left:0;
  list-style:none;
  color: var(--muted);
  font-size:12px;
  line-height:1.45;
}

.feature-list li{
  margin-bottom:2px;
}

.feature-list strong{
  display:block;
  margin-top:6px;
  color: var(--text);
  font-size:12px;
}