/* iw-liff-flex.css — iworn WP Plugins v1.3.0 — Liquid Glass */

/* ===== DESIGN TOKENS ===== */
:root {
  --iw-font:       system-ui, -apple-system, "Segoe UI", sans-serif;
  --iw-radius-xl:  20px;
  --iw-radius:     14px;
  --iw-radius-sm:  10px;
  --iw-radius-pill:99px;

  /* Glass layers */
  --glass-white:   rgba(255, 255, 255, 0.55);
  --glass-white-2: rgba(255, 255, 255, 0.75);
  --glass-border:  rgba(255, 255, 255, 0.55);
  --glass-shine:   inset 0 1.5px 0 rgba(255,255,255,0.70);
  --glass-shadow:  0 8px 32px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.06);

  /* Teal glass */
  --glass-teal-bg:     rgba(38, 198, 218, 0.22);
  --glass-teal-border: rgba(38, 198, 218, 0.45);

  /* Orange glass */
  --glass-orange-bg:     rgba(245, 124, 0, 0.82);
  --glass-orange-glow:   0 4px 20px rgba(245, 124, 0, 0.35);

  /* Green glass */
  --glass-green-bg:      rgba(46, 125, 50, 0.85);
  --glass-green-glow:    0 4px 20px rgba(46, 125, 50, 0.35);

  /* Text */
  --iw-text:       #1a1a2e;
  --iw-text-muted: rgba(0,0,0,0.45);
  --iw-border:     rgba(0,0,0,0.07);
}

/* ===== PAGE BACKGROUND — blends into whatever theme is behind ===== */
#liffCarouselContainer {
  /* No hard container background — cards float on page background */
  background: transparent;
  min-height: 100vh;
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px 180px;
  font-family: var(--iw-font);
  font-size: 15px;
  color: var(--iw-text);
}

/* Fallback: if page body has no gradient, add it here via pseudo */
#liffCarouselContainer::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse at 15% 0%,   rgba(27, 191, 204, 0.28) 0%, transparent 52%),
    radial-gradient(ellipse at 85% 8%,   rgba(201, 224, 42,  0.18) 0%, transparent 48%),
    radial-gradient(ellipse at 50% 55%,  rgba(27, 191, 204, 0.14) 0%, transparent 58%),
    radial-gradient(ellipse at 8%  90%,  rgba(201, 224, 42,  0.12) 0%, transparent 42%),
    linear-gradient(160deg, #f0fffe 0%, #f4fefc 45%, #f8fff5 100%);
  pointer-events: none;
}

/* ===== INFO BANNER — glass ===== */
.info-card {
  background: var(--glass-white);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--iw-radius);
  box-shadow: var(--glass-shine), var(--glass-shadow);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 12.5px;
  color: rgba(0,0,60,0.6);
  line-height: 1.5;
  text-align: center;
}

/* ===== NEWS CARDS — Liquid Glass ===== */
#newsList {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ===== LOGIN PROMPT BANNER ===== */
#liffLoginBanner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(6, 199, 85, 0.10);
  border: 1px solid rgba(6, 199, 85, 0.35);
  border-radius: var(--iw-radius);
  padding: 12px 16px;
  margin-bottom: 12px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.65), 0 2px 10px rgba(6,199,85,0.10);
  animation: bannerSlideIn 0.3s ease;
}

@keyframes bannerSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

#liffLoginBanner span {
  font-size: 13px;
  font-weight: 500;
  color: #025c1f;
  line-height: 1.4;
  flex: 1;
}

#liffLoginBtn {
  flex-shrink: 0;
  background: #06C755;
  color: #fff;
  border: none;
  border-radius: var(--iw-radius-pill);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(6,199,85,0.35);
  transition: filter 0.15s, transform 0.12s;
  white-space: nowrap;
}
#liffLoginBtn:active { filter: brightness(0.92); transform: scale(0.97); }

.card {
  position: relative;
  overflow: hidden;

  /* Glass fill — seamless, no hard boundary */
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(28px) saturate(180%) brightness(103%);
  -webkit-backdrop-filter: blur(28px) saturate(180%) brightness(103%);

  /* Soft teal-tinted border — not stark white */
  border: 1px solid rgba(27, 191, 204, 0.22);
  border-radius: var(--iw-radius);

  /* Layered elevation: no hard line, only shadow */
  box-shadow:
    inset 0 1.5px 0 rgba(255,255,255,0.80),
    0 2px 0 rgba(27,191,204,0.08),
    0 6px 20px rgba(4, 46, 52, 0.08),
    0 1px 4px rgba(4, 46, 52, 0.05);

  padding: 10px 12px;
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(.25,.8,.25,1),
              box-shadow 0.18s,
              background 0.18s;

  /* Compact grid */
  display: grid;
  grid-template-columns: 58px 1fr 22px 30px;
  align-items: center;
  gap: 0 10px;
  min-height: 68px;
}

/* Specular highlight — characteristic liquid glass sheen */
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    175deg,
    rgba(255,255,255,0.45) 0%,
    rgba(255,255,255,0.05) 40%,
    transparent 100%
  );
  pointer-events: none;
  z-index: 0;
}

.card > * { position: relative; z-index: 1; }

.card img {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: var(--iw-radius-sm);
  display: block;
  /* Subtle glass frame on image */
  box-shadow: 0 2px 8px rgba(0,0,0,0.12), 0 0 0 1px rgba(255,255,255,0.4);
}

.card-title {
  font-size: 14px;
  font-weight: 500;
  color: #0D3A3F;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  /* Thai + English mixed — allow natural line breaks */
  overflow-wrap: break-word;
  word-break: break-word;
  -webkit-hyphens: none;
  hyphens: none;
  /* Prevent mid-word Thai breaks — let browser find word boundaries */
  line-break: normal;
}

/* Circular checkbox */
.card-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.18);
  background: rgba(255,255,255,0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  flex-shrink: 0;
  transition: all 0.2s cubic-bezier(.34,1.56,.64,1);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Source button */
.source-btn {
  background: rgba(255,255,255,0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: var(--iw-radius-sm);
  color: rgba(0,0,0,0.4);
  font-size: 13px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.source-btn:hover {
  background: rgba(38,198,218,0.2);
  color: #007d8a;
  border-color: rgba(38,198,218,0.4);
}

/* ── HOVER — float up, teal glow, no hard line ── */
.card:hover:not(.selected) {
  transform: translateY(-2px) scale(1.006);
  box-shadow:
    inset 0 1.5px 0 rgba(255,255,255,0.85),
    0 0 0 1px rgba(27,191,204,0.20),
    0 14px 36px rgba(27,191,204,0.12),
    0 4px 12px rgba(4,46,52,0.08);
}

/* ── SELECTED — teal glass ── */
.card.selected {
  background: rgba(38, 198, 218, 0.18);
  border-color: rgba(38, 198, 218, 0.55);
  box-shadow:
    inset 0 1.5px 0 rgba(255,255,255,0.70),
    0 0 0 2.5px rgba(38,198,218,0.25),
    0 8px 28px rgba(38,198,218,0.15);
  transform: scale(1.008);
}
.card.selected .card-title {
  font-weight: 600;
  color: #004d5a;
}
.card.selected .card-check {
  background: linear-gradient(135deg, #26C6DA, #00ACC1);
  border-color: #00BCD4;
  box-shadow: 0 2px 8px rgba(38,198,218,0.5), inset 0 1px 0 rgba(255,255,255,0.4);
}
/* Checkmark */
.card.selected .card-check::after {
  content: '';
  display: block;
  width: 6px;
  height: 10px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translate(-1px, -1px);
}

/* Shake when max reached */
.card.card-max {
  animation: iw-shake 0.3s ease;
}
@keyframes iw-shake {
  0%,100% { transform: translateX(0); }
  25%      { transform: translateX(-5px); }
  75%      { transform: translateX(5px); }
}

/* ===== INFINITE SCROLL SENTINEL ===== */
#loadSentinel {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--iw-text-muted);
  margin: 8px 0;
}
#loadSentinel.sentinel-loading::before { content: "⏳ กำลังโหลดเพิ่ม…"; }
#loadSentinel.sentinel-end {
  color: rgba(0,0,0,0.28);
  font-size: 11px;
}

/* Loading/Error */
.iw-loading, .iw-error {
  text-align: center;
  padding: 28px;
  font-size: 13px;
  color: var(--iw-text-muted);
}

/* ===== ACTION BAR — Liquid Glass sticky footer ===== */
#actionBar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;

  /* Deep glass blur — like iOS Control Centre */
  background: rgba(255, 255, 255, 0.68);
  backdrop-filter: blur(48px) saturate(200%) brightness(108%);
  -webkit-backdrop-filter: blur(48px) saturate(200%) brightness(108%);

  border-top: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow:
    0 -1px 0 rgba(0,0,0,0.06),
    0 -8px 40px rgba(0,0,0,0.08);

  /* Desktop: single row */
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
}

/* ── Status chip — teal glass + progress bar ── */
.status-card {
  position: relative;
  overflow: hidden;
  background: var(--glass-teal-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-teal-border);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.55),
    0 2px 10px rgba(38,198,218,0.15);
  border-radius: var(--iw-radius-pill);
  color: #004D5A;
  padding: 9px 18px 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Progress track (bottom of chip) */
.status-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 4px;
  width: var(--progress, 0%);
  border-radius: 0 99px 99px 0;
  background: linear-gradient(90deg, #26C6DA, #00BCD4);
  transition: width 0.35s cubic-bezier(.34,1.56,.64,1),
              background 0.4s ease;
}
/* amber zone (7-9) */
.status-card[data-fill="amber"]::after {
  background: linear-gradient(90deg, #FFA900, #FF6D00);
}
/* full (10/10) */
.status-card[data-fill="full"]::after {
  background: linear-gradient(90deg, #FF4D00, #E53935);
  box-shadow: 0 0 8px rgba(255,77,0,0.5);
}

/* ── Buttons group ── */
.action-btns {
  display: flex;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

/* Shared glass button base */
#clearBtn, #sendBtn {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: var(--iw-radius);
  font-family: var(--iw-font);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  padding: 10px 22px;
  color: #fff;
  white-space: nowrap;
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
  /* Specular */
  box-shadow: inset 0 1.5px 0 rgba(255,255,255,0.35);
}
/* Shine overlay */
#clearBtn::before, #sendBtn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(175deg, rgba(255,255,255,0.25) 0%, transparent 55%);
  pointer-events: none;
}

/* Clear — orange glass */
#clearBtn {
  background: var(--glass-orange-bg);
  box-shadow: var(--glass-orange-glow), inset 0 1.5px 0 rgba(255,255,255,0.30);
}
#clearBtn:hover  { filter: brightness(1.08); transform: translateY(-1px); }
#clearBtn:active { transform: scale(0.97); filter: brightness(0.96); }

/* Send — green glass */
#sendBtn {
  background: var(--glass-green-bg);
  box-shadow: var(--glass-green-glow), inset 0 1.5px 0 rgba(255,255,255,0.28);
}
#sendBtn:hover  { filter: brightness(1.08); transform: translateY(-1px); }
#sendBtn:active { transform: scale(0.97); filter: brightness(0.96); }
#sendBtn:disabled {
  background: rgba(0,0,0,0.18);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

/* Result */
#result {
  text-align: center;
  font-size: 13px;
  color: var(--iw-text-muted);
  padding: 6px 0;
  min-height: 22px;
}

/* ===== MOBILE — 2-row action bar ===== */
@media (max-width: 600px) {
  #liffCarouselContainer {
    padding: 14px 12px 180px;
  }

  #actionBar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 14px 14px;
  }

  .status-card {
    text-align: center;
    border-radius: var(--iw-radius-sm);
    padding: 10px 10px 15px;
    font-size: 14px;
  }
  .status-card::after {
    border-radius: 0 0 var(--iw-radius-sm) var(--iw-radius-sm);
  }

  .action-btns {
    margin-left: 0;
    width: 100%;
    gap: 8px;
  }

  #clearBtn, #sendBtn {
    flex: 1;
    justify-content: center;
    padding: 13px 8px;
    font-size: 14px;
    border-radius: var(--iw-radius-sm);
  }
}
