/* client/styles.css */

/* =========================
   Design Tokens
========================= */
:root{
  --bg: #f6f8fc;
  --panel: #ffffff;
  --text: rgba(15, 23, 42, 0.88);
  --muted: rgba(15, 23, 42, 0.62);
  --muted2: rgba(15, 23, 42, 0.50);

  --border: rgba(15, 23, 42, 0.10);

  --shadow-sm: 0 10px 24px rgba(15,23,42,.06);
  --shadow-md: 0 18px 48px rgba(15,23,42,.10);

  --radius: 18px;
  --radius-sm: 14px;

  --space-1: 8px;
  --space-2: 12px;
  --space-3: 16px;
  --space-4: 20px;
  --space-5: 24px;

  --btn-h: 44px;

  --primary: #111827; /* slightly softer than pure black */
  --primary-2: #0f172a;
  --accent: #4f46e5;

  /* ✅ Layout spacing system（全ページ統一） */
  --page-pad: 20px;
  --stack-gap: 18px;  /* 縦方向のカード間隔 */
  --grid-gap: 18px;   /* 2カラムのカード間隔 */
}

/* =========================
   Base
========================= */
* { box-sizing: border-box; }

/* ✅ 背景がスクロールで切れないように「height固定」をやめる */
html, body { min-height: 100%; }

/* ✅ 背景は html に貼る（スクロール全体に対して安定） */
html{
  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 30% -10%, rgba(79,70,229,.16), transparent 55%),
    radial-gradient(900px 540px at 80% 0%, rgba(99,102,241,.10), transparent 60%);
  background-repeat: no-repeat;
  background-attachment: scroll;
}

/* body は透明にして html 背景を見せる（切れ・段差防止） */
body{
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: transparent;
  color: var(--text);
}

input, textarea, select, button{
  font-size: 16px;
  box-sizing: border-box;
}

textarea{ width: 100%; min-height: 80px; resize: vertical; }

/* ========= Anchor reset (IMPORTANT) ========= */
a{
  color: inherit;
  text-decoration: none;
}
a:visited{ color: inherit; }

/* =========================
   Layout
========================= */
.page{
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--page-pad) 18px 40px;
}

/* ✅ 縦積み用の統一スタック（必要なページだけ付ける） */
.stack{
  display: flex;
  flex-direction: column;
  gap: var(--stack-gap);
}

/* 見出しの余白で “間隔がバラバラ” に見えないように */
.page > h1,
.page > h2{
  margin: 0 0 var(--stack-gap);
}

.section-title{
  margin: 0 0 10px;
  font-size: 16px;
  letter-spacing: .01em;
  color: var(--muted);
  font-weight: 700;
}

.row{ margin: 14px 0; }

/* ✅ 統一グリッド（全ページで同じ間隔 + 右カラムのズレ防止） */
.grid-2{
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: var(--grid-gap);
  align-items: stretch;
}

/* ✅ grid 内カードの margin がズレの原因になりやすいので禁止 */
.grid-2 > .card{
  margin: 0 !important;
  height: 100%;
}

@media (max-width: 920px){
  .grid-2{ grid-template-columns: 1fr; }
}

/* =========================
   Card
========================= */
.card{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  margin: 0;
}

/* ✅ これが一番安全：ページによってカード間隔がブレない */
.card + .card{ margin-top: var(--stack-gap); }

/* ✅ stack を使う場所は margin-top を使わない */
.stack .card + .card{ margin-top: 0; }

.card-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.card-subtitle{
  font-size: 13px;
  color: var(--muted);
}

.small{
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* =========================
   Form controls
========================= */
.label{
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 8px;
}

.input,
input[type="text"],
input[type="password"],
input[type="email"],
select,
textarea{
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 12px;
  background: #fff;
  color: var(--text);
  outline: none;
  box-shadow: 0 1px 0 rgba(15,23,42,.02);
}

select{ padding-right: 36px; }

input:focus,
select:focus,
textarea:focus{
  border-color: rgba(79,70,229,.35);
  box-shadow: 0 0 0 4px rgba(79,70,229,.10);
}

/* 閲覧モード（プロフィール）：枠が「入力っぽい」と誤解されないように */
.mode-view input,
.mode-view textarea{
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  padding-left: 0;
  padding-right: 0;
}

.view-pill{
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(15,23,42,.03);
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
}

/* =========================
   Buttons
========================= */
.btn{
  height: var(--btn-h);
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.88);
  cursor: pointer;

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

  font-weight: 800;
  letter-spacing: .01em;
  color: var(--primary);

  box-shadow: 0 10px 22px rgba(15,23,42,.06);
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

a.btn:visited{ color: var(--primary); }

.btn:hover{
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(15,23,42,.10);
  background: #fff;
}

.btn:disabled{
  opacity: .6;
  cursor: not-allowed;
  transform: none;
}

/* Primary */
.btn--primary{
  background: linear-gradient(180deg, #0f172a, #111827);
  color: #fff;
  border-color: rgba(255,255,255,.18);
}
.btn--primary:hover{
  background: linear-gradient(180deg, #0b1220, #0f172a);
}
a.btn.btn--primary:visited{ color: #fff; }

.btn--ghost{
  background: transparent;
  box-shadow: none;
}

.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-weight: 800;
  font-size: 12px;
}
.badge--ok { color: #0a7a2f; border-color: rgba(10,122,47,.20); background: rgba(10,122,47,.06); }
.badge--ng { color: #c21b1b; border-color: rgba(194,27,27,.20); background: rgba(194,27,27,.06); }
.badge--na { color: #6b7280; border-color: rgba(107,114,128,.18); background: rgba(107,114,128,.06); }

/* =========================
   Header (unified)
========================= */
.app-header, .header{
  position: sticky;
  top: 0;
  z-index: 2000;
  background: rgba(246,248,252,.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(15,23,42,.08);
}

.header__inner,
.app-header__inner{
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 18px;
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
}

.brand{
  display:flex;
  align-items:center;
  gap: 10px;
  white-space: nowrap;
}

.brand__link,
.brand{
  text-decoration:none;
  color: inherit;
}

.brand__logo,
.brand__mark{
  width: 40px;
  height: 40px;
  border-radius: 14px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: linear-gradient(180deg, #0f172a, #111827);
  color:#fff;
  font-weight:900;
  letter-spacing: .02em;
  box-shadow: 0 16px 28px rgba(15,23,42,.16);
}

.brand__mark{
  width: 36px;
  height: 36px;
  border-radius: 12px;
  box-shadow: 0 14px 24px rgba(15,23,42,.14);
}

.brand__name{
  font-weight: 900;
  letter-spacing: .02em;
  color: var(--primary);
}

.header__nav,
.app-header__nav{
  display:flex;
  align-items:center;
  gap: 10px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.app-header__links,
.header__links{
  display:flex;
  align-items:center;
  gap: 18px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.nav-link,
.header-nav__item{
  text-decoration: none;
  color: rgba(15, 23, 42, .68);
  font-weight: 800;
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
}

.nav-link:hover,
.header-nav__item:hover{
  color: rgba(15, 23, 42, .92);
  background: rgba(15, 23, 42, .06);
  border-color: rgba(15, 23, 42, .06);
}

.header-nav__item.active{
  color: var(--primary);
  background: rgba(79,70,229,.08);
  border-color: rgba(79,70,229,.16);
}

.header-auth{
  display:flex;
  align-items:center;
  gap: 10px;
}
.header-auth a{ text-decoration:none; }

@media (max-width: 860px){
  .app-header__links,
  .header__links{
    display: none;
  }
  .header__inner,
  .app-header__inner{
    padding: 10px 14px;
  }
}

/* =========================
   Landing Page
========================= */
.hero{
  border-radius: 26px;
  padding: 26px 22px;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(79,70,229,.18), transparent 55%),
              radial-gradient(1000px 560px at 90% 0%, rgba(99,102,241,.10), transparent 60%),
              #fff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.hero h1{
  margin: 0 0 10px;
  font-size: 46px;
  letter-spacing: -0.02em;
  color: var(--primary);
}
.hero p{
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.7;
  font-weight: 600;
}

.hero-actions{
  display:flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items:center;
  margin-top: 14px;
}

.card h2, .card h3{
  color: rgba(15,23,42,.78);
  font-weight: 900;
}

/* =========================
   OKR detail: equal heights in grid
========================= */
.grid-2 .card{
  height: 100%;
}

/* =========================
   Chat (AI OKRコーチ)
========================= */
.chat-panel{
  position: fixed;
  right: 18px;
  bottom: 160px;
  width: min(620px, 92vw);
  height: min(760px, 78vh);
  max-height: calc(100vh - 180px);

  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 22px 60px rgba(15,23,42,.18);
  overflow: hidden;
  z-index: 9998;

  display:flex;
  flex-direction: column;
}
.chat-panel.hidden{ display:none; }

.chat-panel__header{
  padding: 12px 14px;
  border-bottom: 1px solid rgba(15,23,42,.08);
  display:flex;
  align-items:center;
  justify-content: space-between;
}
.chat-panel__title{
  display:flex;
  align-items:center;
  gap: 12px;
  font-size: 18px;
  font-weight: 900;
  color: rgba(15,23,42,.82);
}
.chat-panel__title img{
  width: 54px;
  height: 54px;
  border-radius: 14px;
  object-fit: contain;
  background: transparent;
}
.chat-close{
  border: 1px solid rgba(15,23,42,.10);
  background: rgba(255,255,255,.9);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  cursor:pointer;
  font-size: 20px;
}

.chat-messages, #chatMessages{
  flex: 1;
  overflow:auto;
  padding: 14px;
  background: rgba(15,23,42,.02);
}

.chat-bubble{
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 14px;
  margin: 8px 0;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid rgba(15,23,42,.08);
  background: #fff;
  box-shadow: 0 10px 22px rgba(15,23,42,.06);
}
.chat-bubble.user{
  margin-left: auto;
  background: linear-gradient(180deg, #0f172a, #111827);
  color: #fff;
  border-color: rgba(255,255,255,.18);
}
.chat-bubble.assistant{ margin-right: auto; }

.chat-panel__input{
  display:flex;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid rgba(15,23,42,.08);
  background: #fff;
  align-items:flex-end;
}

#chatText{
  flex: 1;
  height: 52px;
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 12px;
}

#chatFab.chat-fab{
  position: fixed;
  right: 18px;
  bottom: 18px;

  width: 140px;
  height: 140px;

  border: 1px solid rgba(15,23,42,.10);
  padding: 0;
  margin: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.92);

  box-shadow: 0 22px 60px rgba(15,23,42,.22);
  cursor: pointer;
  z-index: 1000;

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

  transition: transform .15s ease, box-shadow .15s ease;
}
#chatFab.chat-fab:hover{
  transform: translateY(-3px);
  box-shadow: 0 28px 72px rgba(15,23,42,.26);
}
#chatFab.chat-fab img{
  width: 92%;
  height: 92%;
  object-fit: contain;
  display:block;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  pointer-events:none;
}

#chatFab.chat-fab::after{
  content: "AI OKRコーチ おけるくん";
  position:absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 10px;

  background: rgba(15,23,42,.92);
  color: #fff;
  font-size: 12px;
  padding: 7px 10px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 10px 22px rgba(15,23,42,.18);
}

@media (max-width: 520px){
  #chatFab.chat-fab{ width: 112px; height: 112px; right: 12px; bottom: 12px; }
  .chat-panel{ right: 10px; bottom: 132px; width: calc(100vw - 20px); height: 70vh; }
  .hero h1{ font-size: 34px; }
}
