/* ================================
   AI Billing Dashboard - Light Theme
   ================================ */

/* WP 管理画面側の背景 */
.toplevel_page_ai-billing-dashboard #wpcontent {
  padding-left: 0;
  background-color: #f3f4f6; /* 明るいグレー */
}

/* 全体ラッパー ---------------------- */
.ai-bd-wrap {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  max-width: 1200px;
  margin: 24px auto 40px;
  padding: 16px 24px 32px;
  color: #111827; /* text-gray-900 */
  background: linear-gradient(180deg, #f9fafb 0%, #eef2ff 40%, #e5e7eb 100%);
  border-radius: 24px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
}

.ai-bd-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 18px;
  color: #111827;
}

/* サマリーカード ------------------- */
.ai-bd-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.ai-bd-card {
  position: relative;
  padding: 18px 20px;
  border-radius: 16px;
  background:
    radial-gradient(circle at top left, #e0f2fe 0, #ffffff 45%) border-box;
  border: 1px solid #e5e7eb;
  box-shadow:
    0 18px 40px rgba(148, 163, 184, 0.25),
    0 0 0 1px rgba(148, 163, 184, 0.15) inset;
}

.ai-bd-card-label {
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6b7280; /* text-gray-500 */
  margin-bottom: 6px;
}

.ai-bd-card-value {
  font-size: 26px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 8px;
}

.ai-bd-card-meta {
  font-size: 12px;
  line-height: 1.6;
  color: #4b5563;
  white-space: nowrap;
}

/* ツールバー ----------------------- */

.ai-bd-toolbar {
  margin-top: 18px;
  margin-bottom: 18px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  color: #4b5563;
  gap: 16px;
  flex-wrap: wrap;
}

.ai-bd-toolbar-label,
.ai-bd-view-control {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-bd-toolbar select {
  padding: 4px 8px;
  font-size: 13px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #111827;
  max-width: 260px;      /* 物件名が長くてもほどよく収まるように */
}

.ai-bd-toolbar-label {
  font-size: 13px;
  color: #6b7280;
}

/* トグルボタン（「月ごと / 日ごと」） */
.ai-bd-toggle {
  display: inline-flex;
  padding: 2px;
  border-radius: 9999px;
  background: #e5e7eb;
  border: 1px solid #d1d5db;
}

.ai-bd-toggle button {
  position: relative;
  border: none;
  outline: none;
  background: transparent;
  color: #4b5563;
  font-size: 13px;
  padding: 6px 18px;
  border-radius: 9999px;
  cursor: pointer;
  transition:
    color 0.16s ease,
    background-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.08s ease;
}

.ai-bd-toggle button.is-active {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.35);
  transform: translateY(-0.5px);
}

.ai-bd-toggle button:not(.is-active):hover {
  background-color: rgba(255, 255, 255, 0.8);
}

.ai-bd-toolbar input[type="month"] {
  margin-left: 4px;
  padding: 4px 8px;
  font-size: 13px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #111827;
}

/* メイン3カラム --------------------- */
.ai-bd-main {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.7fr) minmax(0, 1.6fr);
  gap: 18px;
  margin-top: 8px;

  /* ★ 1行の高さを固定（お好みで 320〜380 あたり） */
  grid-auto-rows: 360px;
}


/* 共通カードスタイル（予算 / グラフ / テーブル） */
.ai-bd-budget,
.ai-bd-chart,
.ai-bd-table {
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  box-shadow:
    0 18px 35px rgba(148, 163, 184, 0.25),
    0 0 0 1px rgba(148, 163, 184, 0.16) inset;
  padding: 18px 18px 20px;
}

/* 予算ドーナツ ---------------------- */
.ai-bd-budget-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #111827;
}

.ai-bd-budget-inner {
  position: relative;
  width: 100%;
  max-width: 220px;
  margin: 10px auto 0;
}

.ai-bd-budget-inner canvas {
  width: 100%;
  height: auto;
}

.ai-bd-budget-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
}

.ai-bd-budget-center-top {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 2px;
}

.ai-bd-budget-center-value {
  font-size: 22px;
  font-weight: 600;
  color: #111827;
}

.ai-bd-budget-center-bottom {
  font-size: 12px;
  color: #9ca3af;
  margin-top: 3px;
}

.ai-bd-budget-caption {
  margin-top: 10px;
  font-size: 12px;
  text-align: center;
  color: #6b7280;
}

.ai-bd-budget-caption span {
  font-weight: 600;
  color: #2563eb;
}

.ai-bd-chart {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
}


/* ヘッダー（タイトル＋トグル） */
.ai-bd-chart-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.ai-bd-chart-title {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
}

.ai-bd-chart-note {
  font-size: 12px;
  color: #6b7280;
  white-space: nowrap;
}

/* ★ グラフエリア本体：残りの高さを全部使う */
.ai-bd-chart-body {
  flex: 1 1 auto;
  min-height: 0;
}

/* ★ キャンバスはグラフエリアにぴったり収める */
.ai-bd-chart-body canvas {
  width: 100% !important;
  height: 100% !important;
}


/* 右テーブル ------------------------ */
.ai-bd-table {
  overflow: hidden;
}

.ai-bd-table-title {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 8px;
}

.ai-bd-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ai-bd-table thead th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 500;
  color: #6b7280;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
  position: sticky;
  top: 0;
  z-index: 1;
}

.ai-bd-table tbody {
  display: block;
  max-height: 230px;   /* ★ ヘッダー＋余白を引いた分だけにする */
  overflow-y: auto;
}


.ai-bd-table thead,
.ai-bd-table tbody tr {
  display: table;
  width: 100%;
  table-layout: fixed;
}

.ai-bd-table tbody tr {
  border-bottom: 1px solid #f3f4f6;
  transition: background-color 0.12s ease;
}

.ai-bd-table tbody tr:nth-child(even) {
  background-color: #f9fafb;
}

.ai-bd-table tbody tr:hover {
  background-color: #e5f0ff;
}

.ai-bd-table tbody td {
  padding: 9px 12px;
  color: #111827;
}

.ai-bd-table .ai-bd-date-cell {
  white-space: nowrap;
}

/* スクロールバー（WebKit） */
.ai-bd-table tbody::-webkit-scrollbar {
  width: 7px;
}

.ai-bd-table tbody::-webkit-scrollbar-track {
  background: #e5e7eb;
  border-radius: 999px;
}

.ai-bd-table tbody::-webkit-scrollbar-thumb {
  background: #9ca3af;
  border-radius: 999px;
}

/* 小さい画面向け -------------------- */
@media (max-width: 1024px) {
  .ai-bd-main {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;   /* ★ 追加：スマホ・タブレットでは高さ自動 */
  }

  .ai-bd-budget,
  .ai-bd-chart,
  .ai-bd-table {
    min-height: auto;
  }
}


@media (max-width: 768px) {
  .ai-bd-wrap {
    padding: 16px;
    margin: 16px;
  }

  .ai-bd-cards {
    grid-template-columns: 1fr;
  }

  .ai-bd-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .ai-bd-toolbar-label,
  .ai-bd-view-control {
    width: 100%;
  }

  .ai-bd-main {
    gap: 14px;
  }

  .ai-bd-budget-inner {
    max-width: 190px;
  }

  /* ★ 追加：スマホ時のグラフカード高さを固定 */
  .ai-bd-chart {
    height: 300px;     /* お好みで 280〜340px くらいに調整可 */
  }
}

.ai-bd-wrap canvas { 
  display:block; 
}
