/* 玄関ダッシュボード - 1920x1080 最適化 (時間別天気 + CloudWatch対応) */
:root {
  /* 全体背景は明るめグレー（暗すぎない） */
  --bg-primary: #e5e7eb;
  --bg-secondary: #d1d5db;
  --bg-card: #ffffff;
  --text-primary: #111827;
  --text-secondary: #374151;
  --text-muted: #6b7280;
  --accent-blue: #3b82f6;
  --accent-green: #22c55e;
  --accent-orange: #f59e0b;
  --accent-red: #ef4444;
  --border-color: #e5e7eb;
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.10);
  --radius: 16px;
  --radius-sm: 8px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', 'Helvetica Neue', 'Hiragino Sans', 'Meiryo', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.dashboard {
  width: min(1920px, 100vw);
  height: min(1080px, 100vh);
  display: flex;
  flex-direction: column;
  padding: 20px 28px;
  gap: 16px;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

/* ========== 上段: 時計 + 現在の天気 ========== */
.header-row {
  display: flex;
  gap: 20px;
  flex-shrink: 0;
  height: 180px;
}

/* 時計パネル */
.clock-panel {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px 40px;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 28px;
  box-shadow: var(--shadow);
}

.time-display {
  font-size: 92px;
  font-weight: 200;
  font-variant-numeric: tabular-nums;
  letter-spacing: -2px;
  line-height: 1;
  background: linear-gradient(180deg, #111827 0%, #4b5563 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.date-display {
  font-size: 24px;
  font-weight: 300;
  color: var(--text-secondary);
  margin-top: 0;
  letter-spacing: 1px;
  white-space: nowrap;
  line-height: 1;
}

/* 現在の天気パネル（2エリア横並び） */
.current-weather-panel {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px 32px;
  display: flex;
  gap: 32px;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}

.current-weather-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cw-name {
  font-size: 20px;
  font-weight: 600;
  color: var(--accent-blue);
  min-width: 50px;
}

.cw-icon {
  width: 64px;
  height: 64px;
}

.cw-temp {
  font-size: 48px;
  font-weight: 200;
  min-width: 90px;
}

.cw-desc {
  font-size: 18px;
  color: var(--text-secondary);
  min-width: 80px;
}

/* ========== 時間別天気予報 ========== */
.hourly-weather-row {
  flex-shrink: 0;
}

/* 旧: 2パネル構成の名残（現在はテーブル表示のため未使用） */
.hourly-weather-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
}

.hourly-weather-grid .hourly-weather-panel {
  min-width: 0;
}

.hourly-weather-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px 24px;
  box-shadow: var(--shadow);
}

/* ========== 天気テーブル（2拠点×15時間） ========== */
.weather-table-wrap {
  width: 100%;
  overflow: hidden;
}

.weather-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.weather-table thead th {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 700;
  padding: 6px 4px;
  text-align: center;
}

.weather-area-col {
  width: 88px;
}

.weather-hour {
  white-space: nowrap;
}

.weather-area {
  text-align: left;
  padding: 10px 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border-top-left-radius: var(--radius-sm);
  border-bottom-left-radius: var(--radius-sm);
}

.weather-cell {
  padding: 6px 4px;
  text-align: center;
  vertical-align: middle;
  border-left: 1px solid var(--border-color);
}

.weather-cell.now {
  background: rgba(59, 130, 246, 0.10);
  outline: 1px solid rgba(59, 130, 246, 0.35);
  outline-offset: -1px;
}

.weather-icon {
  width: 28px;
  height: 28px;
  display: block;
  margin: 0 auto;
}

.weather-temp {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.1;
}

.weather-rain {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.1;
  min-height: 12px;
}

.weather-rain.high {
  color: var(--accent-orange);
}

.weather-loading {
  color: var(--text-muted);
  padding: 14px 10px;
  text-align: center;
}

.hourly-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.hourly-title {
  font-size: 20px;
  font-weight: 600;
}

.hourly-updated {
  font-size: 14px;
  color: var(--text-muted);
}

.hourly-scroll {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  overflow: hidden;
  padding-bottom: 0;
  min-width: 0;
}

.hourly-loading {
  color: var(--text-muted);
  padding: 20px;
  text-align: center;
  width: 100%;
}

.hourly-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 6px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.hourly-item.now {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.55);
}

.hourly-time {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.hourly-icon {
  width: 32px;
  height: 32px;
}

.hourly-temp {
  font-size: 16px;
  font-weight: 500;
}

.hourly-rain {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1;
  min-height: 14px; /* 値が空でも高さを確保してガタつきを防ぐ */
}

.hourly-rain.high {
  color: var(--accent-orange);
}

/* ========== 中段: バス + CloudWatch ========== */
.main-row {
  flex: 1;
  display: flex;
  gap: 20px;
  min-height: 0;
}

/* バスパネル */
.bus-panel {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.bus-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.bus-icon {
  font-size: 36px;
}

.bus-title {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bus-route-name {
  font-size: 22px;
  font-weight: 600;
}

.bus-route-detail {
  font-size: 14px;
  color: var(--text-secondary);
}

.bus-updated {
  font-size: 13px;
  color: var(--text-muted);
}

.update-label {
  margin-right: 4px;
}

/* バステーブル */
.bus-table-container {
  flex: 1;
  overflow: hidden;
}

.bus-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 20px;
}

.bus-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--border-color);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.bus-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.bus-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.05);
}

.bus-table tbody tr:first-child {
  background: rgba(59, 130, 246, 0.1);
}

.bus-table tbody tr:first-child td {
  font-weight: 600;
}

.col-route { width: 90px; }
.col-dest { width: 120px; }
.col-time { width: 100px; }
.col-status { width: 120px; }
.col-travel { width: 70px; }

/* 状態バッジ */
.status-soon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 16px;
  animation: pulse 1.5s infinite;
}

.status-waiting {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
  border-radius: var(--radius-sm);
  font-size: 16px;
}

.status-normal {
  color: var(--text-secondary);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.bus-loading td,
.bus-empty td {
  text-align: center;
  color: var(--text-muted);
  font-size: 18px;
  padding: 40px 12px;
}

/* ========== CloudWatch パネル ========== */
.cloudwatch-panel {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.cloudwatch-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.cloudwatch-icon {
  font-size: 24px;
}

.cloudwatch-title {
  flex: 1;
  font-size: 20px;
  font-weight: 600;
}

.cloudwatch-refresh {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 18px;
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.cloudwatch-refresh:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.cloudwatch-content {
  flex: 1;
  min-height: 0;
  position: relative;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.cloudwatch-images {
  position: absolute;
  inset: 0;
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 10px;
}

.cw-img-card {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.cw-img-title {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 6px 8px;
  border-bottom: 1px solid rgba(17, 24, 39, 0.08);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cw-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.cloudwatch-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.placeholder-icon {
  font-size: 48px;
  opacity: 0.3;
}

.placeholder-text {
  font-size: 20px;
  color: var(--text-muted);
}

.placeholder-hint {
  font-size: 13px;
  color: var(--text-muted);
  opacity: 0.7;
}

.cloudwatch-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: var(--bg-secondary);
}

/* ========== フッター ========== */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 8px;
  flex-shrink: 0;
  height: 28px;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.api-status {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.api-status.connected {
  color: var(--accent-green);
}

.api-status.error {
  color: var(--accent-red);
}

.footer-domain {
  font-size: 13px;
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.footer-center {
  display: flex;
  align-items: center;
  gap: 12px;
}

.refresh-data-btn {
  padding: 6px 16px;
  background: var(--accent-blue);
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.refresh-data-btn:hover {
  background: #2563eb;
  transform: scale(1.02);
}

.refresh-data-btn:active {
  transform: scale(0.98);
}

.refresh-data-btn:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
}

.refresh-status {
  font-size: 11px;
  color: var(--text-secondary);
}

.refresh-status.success {
  color: var(--accent-green);
}

.refresh-status.pending {
  color: var(--accent-orange);
}

.footer-right {
  font-size: 13px;
  color: var(--text-muted);
}

/* スクロールバー（横スクロール用） */

@media (max-width: 1400px) {
  .hourly-scroll {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  .hourly-weather-grid {
    grid-template-columns: 1fr;
  }
  .hourly-scroll {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

/* レスポンシブ（開発用） */
@media (max-width: 1920px) {
  .dashboard {
    width: 100vw;
    height: 100vh;
    transform-origin: top left;
  }
}
