/* =============================================================
   Sanare Action Hub - Front CSS
   プラグイン側のフロント専用スタイル
   ============================================================= */

/* ---------- ダッシュボード ---------- */
.sah-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.sah-stat-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid #E5E7EB;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sah-stat-card__label {
  font-size: 13px;
  color: #6B7280;
  font-weight: 500;
}

.sah-stat-card__value {
  font-size: 32px;
  font-weight: 700;
  color: #111827;
  line-height: 1;
}

.sah-stat-card__sub {
  font-size: 12px;
  color: #6B7280;
}

.sah-stat-card--primary .sah-stat-card__value { color: #2F63E6; }
.sah-stat-card--danger  .sah-stat-card__value { color: #EF4444; }
.sah-stat-card--success .sah-stat-card__value { color: #10B981; }
.sah-stat-card--warning .sah-stat-card__value { color: #F59E0B; }

/* ダッシュボード下段2カラム */
.sah-dashboard-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 768px) {
  .sah-dashboard-cols { grid-template-columns: 1fr; }
}

/* ---------- 共通セクション ---------- */
.sah-section {
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #E5E7EB;
  padding: 20px;
  margin-bottom: 20px;
}

.sah-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.sah-section__title {
  font-size: 15px;
  font-weight: 600;
  color: #111827;
}

.sah-section__more {
  font-size: 13px;
  color: #2F63E6;
  text-decoration: none;
  cursor: pointer;
}

.sah-section__more:hover { text-decoration: underline; }

/* ---------- タスク一覧 ---------- */
.sah-task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sah-task-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #E5E7EB;
  background: #F8FAFC;
  transition: background 0.15s;
}

.sah-task-item:hover { background: #EFF6FF; border-color: #BFDBFE; }

.sah-task-item.is-done {
  opacity: 0.55;
  background: #F9FAFB;
}

.sah-task-item.is-done .sah-task-item__title {
  text-decoration: line-through;
  color: #9CA3AF;
}

.sah-task-item__check {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: 2px solid #D1D5DB;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}

.sah-task-item__check:hover { border-color: #2F63E6; }
.sah-task-item__check.is-checked { border-color: #2F63E6; background: #2F63E6; }
.sah-task-item__check.is-checked::after {
  content: '';
  width: 8px;
  height: 5px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
  display: block;
}

.sah-task-item__body { flex: 1; min-width: 0; }

.sah-task-item__title {
  font-size: 14px;
  font-weight: 500;
  color: #111827;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sah-task-item__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.sah-task-item__actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.sah-task-item__btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: #6B7280;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  padding: 0;
}

.sah-task-item__btn:hover { background: #E5E7EB; color: #111827; }
.sah-task-item__btn--delete:hover { background: #FEE2E2; color: #EF4444; }

/* ---------- バッジ ---------- */
.sah-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.sah-badge--todo     { background: #F3F4F6; color: #374151; }
.sah-badge--progress { background: #DBEAFE; color: #1D4ED8; }
.sah-badge--review   { background: #FEF3C7; color: #92400E; }
.sah-badge--done     { background: #D1FAE5; color: #065F46; }
.sah-badge--pending  { background: #F3F4F6; color: #6B7280; }

.sah-badge--low      { background: #F3F4F6; color: #374151; }
.sah-badge--medium   { background: #DBEAFE; color: #1D4ED8; }
.sah-badge--high     { background: #FEF3C7; color: #92400E; }
.sah-badge--urgent   { background: #FEE2E2; color: #991B1B; }

.sah-badge--date { background: transparent; color: #6B7280; padding: 0; font-weight: 400; }

/* ---------- フォーム ---------- */
.sah-form { display: flex; flex-direction: column; gap: 16px; }

.sah-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 480px) { .sah-form-row { grid-template-columns: 1fr; } }

.sah-form-group { display: flex; flex-direction: column; gap: 6px; }

.sah-form-group label {
  font-size: 13px;
  font-weight: 500;
  color: #374151;
}

.sah-form-group input,
.sah-form-group select,
.sah-form-group textarea {
  border: 1px solid #D1D5DB;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  color: #111827;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
}

.sah-form-group input:focus,
.sah-form-group select:focus,
.sah-form-group textarea:focus {
  outline: none;
  border-color: #2F63E6;
  box-shadow: 0 0 0 3px rgba(47,99,230,0.12);
}

.sah-form-group textarea { resize: vertical; min-height: 80px; }

.sah-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* ---------- ボタン ---------- */
.sah-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
  font-family: inherit;
  line-height: 1;
}

.sah-btn--primary { background: #2F63E6; color: #fff; }
.sah-btn--primary:hover { background: #1D4ED8; }

.sah-btn--secondary { background: #F3F4F6; color: #374151; }
.sah-btn--secondary:hover { background: #E5E7EB; }

.sah-btn--danger { background: #EF4444; color: #fff; }
.sah-btn--danger:hover { background: #DC2626; }

.sah-btn--ghost { background: transparent; color: #6B7280; border: 1px solid #D1D5DB; }
.sah-btn--ghost:hover { background: #F9FAFB; }

.sah-btn--sm { padding: 6px 12px; font-size: 12px; }
.sah-btn--full { width: 100%; }

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

/* ---------- タブ ---------- */
.sah-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid #E5E7EB;
  margin-bottom: 20px;
}

.sah-tab {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: #6B7280;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
  font-family: inherit;
}

.sah-tab:hover { color: #111827; }

.sah-tab.is-active {
  color: #2F63E6;
  border-bottom-color: #2F63E6;
  font-weight: 600;
}

.sah-tab-content { display: none; }
.sah-tab-content.is-active { display: block; }

/* ---------- フィルターバー ---------- */
.sah-filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.sah-filter-bar select,
.sah-filter-bar input {
  border: 1px solid #D1D5DB;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  color: #374151;
  background: #fff;
  font-family: inherit;
}

.sah-filter-bar select:focus,
.sah-filter-bar input:focus {
  outline: none;
  border-color: #2F63E6;
}

/* ---------- モーダル ---------- */
.sah-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17,24,39,0.5);
  z-index: 9990;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.sah-modal-overlay.is-open { display: flex; }

.sah-modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  position: relative;
  animation: sahModalIn 0.18s ease;
}

@keyframes sahModalIn {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.sah-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.sah-modal__title {
  font-size: 17px;
  font-weight: 700;
  color: #111827;
}

.sah-modal__close {
  width: 32px;
  height: 32px;
  border: none;
  background: #F3F4F6;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  color: #6B7280;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s;
}

.sah-modal__close:hover { background: #E5E7EB; color: #111827; }

/* ---------- プログレスバー ---------- */
.sah-progress {
  background: #E5E7EB;
  border-radius: 20px;
  height: 8px;
  overflow: hidden;
}

.sah-progress__bar {
  height: 100%;
  background: #2F63E6;
  border-radius: 20px;
  transition: width 0.4s ease;
}

/* ---------- カレンダー ---------- */
.sah-calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.sah-calendar-nav__title {
  font-size: 17px;
  font-weight: 700;
  color: #111827;
}

.sah-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.sah-calendar-grid__head {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: #6B7280;
  padding: 6px 0;
  text-transform: uppercase;
}

.sah-calendar-day {
  border-radius: 8px;
  padding: 6px 4px;
  min-height: 72px;
  border: 1px solid #E5E7EB;
  cursor: pointer;
  transition: background 0.12s;
}

.sah-calendar-day:hover { background: #EFF6FF; border-color: #BFDBFE; }

.sah-calendar-day.is-today {
  border-color: #2F63E6;
  background: #EFF6FF;
}

.sah-calendar-day.is-today .sah-calendar-day__num {
  background: #2F63E6;
  color: #fff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sah-calendar-day.is-other-month { opacity: 0.35; }

.sah-calendar-day__num {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 4px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sah-calendar-event {
  font-size: 10px;
  background: #DBEAFE;
  color: #1D4ED8;
  border-radius: 4px;
  padding: 2px 4px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sah-calendar-event--task { background: #FEF3C7; color: #92400E; }

/* ---------- スケジュール日表示 ---------- */
.sah-schedule-day {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sah-schedule-slot {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.sah-schedule-slot__time {
  font-size: 12px;
  color: #6B7280;
  font-weight: 500;
  width: 44px;
  flex-shrink: 0;
  padding-top: 2px;
}

.sah-schedule-slot__event {
  flex: 1;
  background: #EFF6FF;
  border-left: 3px solid #2F63E6;
  border-radius: 6px;
  padding: 8px 12px;
}

.sah-schedule-slot__event-title {
  font-size: 13px;
  font-weight: 600;
  color: #1D4ED8;
}

.sah-schedule-slot__event-desc {
  font-size: 12px;
  color: #6B7280;
  margin-top: 2px;
}

/* ---------- 目標ツリー ---------- */
.sah-goal-tree { display: flex; flex-direction: column; gap: 12px; }

.sah-goal-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #E5E7EB;
  padding: 16px;
}

.sah-goal-card--child {
  margin-left: 24px;
  border-left: 3px solid #BFDBFE;
}

.sah-goal-card--grandchild {
  margin-left: 48px;
  border-left: 3px solid #DBEAFE;
}

.sah-goal-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.sah-goal-card__title {
  font-size: 15px;
  font-weight: 600;
  color: #111827;
}

.sah-goal-card__actions { display: flex; gap: 4px; }

.sah-goal-card__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.sah-goal-card__progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sah-goal-card__progress-label {
  font-size: 12px;
  color: #6B7280;
  white-space: nowrap;
  min-width: 36px;
  text-align: right;
}

.sah-goal-card__progress { flex: 1; }

/* ---------- プロジェクトカード ---------- */
.sah-project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.sah-project-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #E5E7EB;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.sah-project-card:hover { box-shadow: 0 4px 16px rgba(47,99,230,0.1); border-color: #BFDBFE; }

.sah-project-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.sah-project-card__title { font-size: 15px; font-weight: 600; color: #111827; }

.sah-project-card__desc {
  font-size: 13px;
  color: #6B7280;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sah-project-card__footer { display: flex; align-items: center; justify-content: space-between; }

.sah-project-card__progress-wrap { flex: 1; }

/* ---------- ナレッジ ---------- */
.sah-note-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.sah-note-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #E5E7EB;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
  min-height: 120px;
}

.sah-note-card:hover { box-shadow: 0 4px 16px rgba(47,99,230,0.1); border-color: #BFDBFE; }

.sah-note-card__title { font-size: 14px; font-weight: 600; color: #111827; }

.sah-note-card__preview {
  font-size: 12px;
  color: #6B7280;
  line-height: 1.6;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sah-note-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sah-note-card__actions { display: flex; gap: 4px; }

/* ---------- チーム ---------- */
.sah-member-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.sah-member-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #E5E7EB;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.sah-member-card__avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #DBEAFE;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: #2F63E6;
  overflow: hidden;
}

.sah-member-card__avatar img { width: 100%; height: 100%; object-fit: cover; }

.sah-member-card__name { font-size: 14px; font-weight: 600; color: #111827; }
.sah-member-card__role { font-size: 12px; color: #6B7280; }

/* ---------- 設定 ---------- */
.sah-settings-section { margin-bottom: 32px; }

.sah-settings-section__title {
  font-size: 15px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid #E5E7EB;
}

.sah-settings-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 0;
  border-bottom: 1px solid #F3F4F6;
}

.sah-settings-row:last-child { border-bottom: none; }

.sah-settings-row__label { flex: 1; }

.sah-settings-row__label strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 3px;
}

.sah-settings-row__label span {
  font-size: 12px;
  color: #6B7280;
}

.sah-settings-row__control { width: 260px; flex-shrink: 0; }

@media (max-width: 600px) {
  .sah-settings-row { flex-direction: column; }
  .sah-settings-row__control { width: 100%; }
}

/* ---------- AI 提案カード ---------- */
.sah-ai-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sah-ai-suggestion-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: #EFF6FF;
  border-radius: 8px;
  border: 1px solid #BFDBFE;
  font-size: 13px;
  color: #1D4ED8;
  line-height: 1.5;
}

.sah-ai-suggestion-item::before {
  content: '✦';
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ---------- 今日の予定リスト ---------- */
.sah-today-schedule {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sah-today-schedule-item {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  background: #F8FAFC;
  border-radius: 8px;
  border: 1px solid #E5E7EB;
  align-items: center;
}

.sah-today-schedule-item__time {
  font-size: 12px;
  font-weight: 600;
  color: #2F63E6;
  white-space: nowrap;
}

.sah-today-schedule-item__title {
  font-size: 13px;
  font-weight: 500;
  color: #111827;
}

/* ---------- ローディング ---------- */
.sah-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: #6B7280;
  font-size: 14px;
  gap: 8px;
}

.sah-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #E5E7EB;
  border-top-color: #2F63E6;
  border-radius: 50%;
  animation: sahSpin 0.7s linear infinite;
}

@keyframes sahSpin { to { transform: rotate(360deg); } }

/* ---------- 空状態 ---------- */
.sah-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  text-align: center;
  gap: 12px;
}

.sah-empty__icon { font-size: 40px; opacity: 0.35; }
.sah-empty__text { font-size: 14px; color: #6B7280; }

/* ---------- トースト ---------- */
.sah-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.sah-toast {
  background: #111827;
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  max-width: 300px;
  animation: sahToastIn 0.2s ease;
  pointer-events: auto;
}

.sah-toast--success { background: #065F46; }
.sah-toast--error   { background: #991B1B; }

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

/* ---------- レスポンシブ微調整 ---------- */
@media (max-width: 480px) {
  .sah-dashboard-grid { grid-template-columns: 1fr 1fr; }
  .sah-project-grid, .sah-note-grid, .sah-member-grid { grid-template-columns: 1fr; }
  .sah-calendar-day { min-height: 50px; }
  .sah-calendar-event { display: none; }
}
