/* ===========================================
 * NARERU AI Chat Widget (Plugin)
 * カラーは管理画面から動的に変更可（CSS変数）
 * =========================================== */

#nac-root { all: initial; }

#nac-root *,
#nac-root *::before,
#nac-root *::after {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "ヒラギノ角ゴ ProN", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
 * フローティングボタン (FAB)
 * ============================================================ */
.nac-fab {
  position: fixed;
  right: 16px;
  bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--nac-main, #094eaf);
  color: #fff;
  border: 3px solid #fff;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25), 0 2px 6px rgba(0, 0, 0, 0.1);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  padding: 0;
  line-height: 1;
}
.nac-fab:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3), 0 4px 8px rgba(0, 0, 0, 0.12);
}

.nac-fab__brand {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: #fff;
  margin-bottom: 3px;
  line-height: 1;
}
.nac-fab__ai {
  font-size: 15px;
  font-weight: 900;
  color: var(--nac-accent, #ff9351);
  letter-spacing: 0.5px;
  line-height: 1;
}
.nac-fab__pulse {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--nac-main, #094eaf);
  opacity: 0.45;
  animation: nac-pulse 2.4s infinite;
  pointer-events: none;
}
@keyframes nac-pulse {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(1.5); opacity: 0; }
}
.nac-fab__badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--nac-accent, #ff9351);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  letter-spacing: 0.6px;
  border: 1.5px solid #fff;
}

/* ============================================================
 * パネル
 * ============================================================ */
.nac-panel {
  position: fixed;
  right: 16px;
  bottom: calc(180px + env(safe-area-inset-bottom, 0px));
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100dvh - 220px);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2), 0 8px 24px rgba(0, 0, 0, 0.08);
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: nac-slide-up 0.25s ease-out;
}
.nac-panel.is-open { display: flex; }
@keyframes nac-slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
 * ヘッダー
 * ============================================================ */
.nac-header {
  background: var(--nac-main, #094eaf);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}
.nac-header::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--nac-accent, #ff9351);
}
.nac-header__brand {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.nac-header__logo {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #fff;
  line-height: 1;
}
.nac-header__logo .ai {
  color: var(--nac-accent, #ff9351);
  margin-left: 4px;
  font-weight: 900;
}
.nac-header__subtitle {
  font-size: 10.5px;
  opacity: 0.92;
  letter-spacing: 0.3px;
  color: #fff;
}
.nac-header__close {
  margin-left: auto;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  padding: 4px 10px;
  border-radius: 6px;
  opacity: 0.85;
  transition: opacity 0.15s;
}
.nac-header__close:hover { opacity: 1; background: rgba(255, 255, 255, 0.15); }

/* ============================================================
 * 本文
 * ============================================================ */
.nac-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  background: #f7faff;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}
.nac-msg {
  max-width: 86%;
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.65;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.nac-msg--bot {
  background: #fff;
  color: #1a1a1a;
  align-self: flex-start;
  border: 1px solid #e3eaf5;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}
.nac-msg--user {
  background: var(--nac-main, #094eaf);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.nac-msg a {
  color: var(--nac-accent, #ff9351);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 2px;
  font-weight: 600;
}
.nac-msg--user a { color: #ffd2b8; }

/* ============================================================
 * サジェスト
 * ============================================================ */
.nac-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0;
}
.nac-suggestion {
  background: #fff;
  border: 1.5px solid var(--nac-main, #094eaf);
  color: var(--nac-main, #094eaf);
  padding: 7px 13px;
  border-radius: 18px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.nac-suggestion:hover {
  background: var(--nac-main, #094eaf);
  color: #fff;
  transform: translateY(-1px);
}

/* ============================================================
 * タイピング
 * ============================================================ */
.nac-typing {
  display: flex;
  gap: 5px;
  padding: 14px 16px;
  background: #fff;
  border-radius: 14px;
  align-self: flex-start;
  border: 1px solid #e3eaf5;
}
.nac-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--nac-main, #094eaf);
  opacity: 0.4;
  animation: nac-typing 1.2s infinite;
}
.nac-typing span:nth-child(2) { animation-delay: 0.2s; }
.nac-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes nac-typing {
  0%, 60%, 100% { opacity: 0.4; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* ============================================================
 * フッター（入力）
 * ============================================================ */
.nac-footer {
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  background: #fff;
  border-top: 1px solid #e3eaf5;
}
.nac-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.nac-input {
  flex: 1;
  border: 1.5px solid #d8dade;
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 16px;
  resize: none;
  outline: none;
  font-family: inherit;
  line-height: 1.5;
  max-height: 80px;
  background: #fff;
  color: #1a1a1a;
}
.nac-input:focus { border-color: var(--nac-main, #094eaf); }
.nac-input::placeholder { color: #aaa; font-size: 14px; }

.nac-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--nac-accent, #ff9351);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s;
}
.nac-send:hover:not(:disabled) { transform: scale(1.08); }
.nac-send:disabled {
  background: #d8dade;
  box-shadow: none;
  cursor: not-allowed;
}
.nac-send svg { width: 18px; height: 18px; fill: #fff; }

.nac-disclaimer {
  font-size: 10.5px;
  color: #888;
  text-align: center;
  margin: 8px 0 0;
  line-height: 1.5;
}
.nac-disclaimer a {
  color: var(--nac-main, #094eaf);
  font-weight: 600;
  text-decoration: underline;
}

/* ============================================================
 * 予約フロー
 * ============================================================ */
.nac-booking {
  background: #fff;
  border: 1.5px solid var(--nac-main, #094eaf);
  border-radius: 14px;
  padding: 12px;
  margin: 4px 0;
  align-self: stretch;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.nac-booking__title {
  font-size: 13px;
  font-weight: 700;
  color: var(--nac-main, #094eaf);
  margin-bottom: 8px;
}

.nac-booking__slots {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nac-booking__slot {
  background: #fff;
  border: 1.5px solid var(--nac-main, #094eaf);
  color: var(--nac-main, #094eaf);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: all 0.15s;
}
.nac-booking__slot:hover {
  background: var(--nac-main, #094eaf);
  color: #fff;
}

.nac-booking__form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nac-booking__form input,
.nac-booking__form textarea {
  border: 1.5px solid #d8dade;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: #fff;
  color: #1a1a1a;
  resize: vertical;
}
.nac-booking__form input:focus,
.nac-booking__form textarea:focus {
  border-color: var(--nac-main, #094eaf);
}

.nac-booking__selected {
  background: #f7faff;
  border: 1px dashed var(--nac-main, #094eaf);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--nac-main, #094eaf);
  font-weight: 600;
}

.nac-booking__submit {
  background: var(--nac-accent, #ff9351);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}
.nac-booking__submit:hover:not(:disabled) {
  transform: translateY(-1px);
}
.nac-booking__submit:disabled {
  background: #d8dade;
  cursor: not-allowed;
}

.nac-booking__back {
  background: transparent;
  border: none;
  color: #888;
  font-size: 12px;
  cursor: pointer;
  padding: 6px;
  text-align: center;
  font-family: inherit;
}
.nac-booking__back:hover { color: var(--nac-main, #094eaf); }

/* ============================================================
 * モバイル（フルスクリーン + iOSキーボード対応）
 * ============================================================ */
@media (max-width: 600px) {
  .nac-fab {
    bottom: calc(90px + env(safe-area-inset-bottom, 0px));
    right: 12px;
    width: 62px;
    height: 62px;
  }
  .nac-panel {
    right: 0;
    left: 0;
    bottom: 0;
    top: 0;
    width: 100%;
    max-width: 100%;
    height: var(--nac-h, 100dvh);
    max-height: var(--nac-h, 100dvh);
    border-radius: 0;
    box-shadow: none;
  }
  .nac-header {
    padding: 14px 16px;
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
  }
  .nac-body { padding: 16px 12px; }
}
