/**
 * アナリティクスチェッカー スタイルシート
 */

/* リセット & ベース */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans',
    'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: #333;
  background-color: #f5f5f5;
}

/* ログイン画面 */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.login-box {
  background: white;
  padding: 40px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 400px;
}

.login-box h1 {
  font-size: 24px;
  margin-bottom: 8px;
  text-align: center;
  color: #2c3e50;
}

.login-box .subtitle {
  text-align: center;
  color: #7f8c8d;
  margin-bottom: 30px;
  font-size: 13px;
}

/* コンテナ */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* ヘッダー */
.header {
  background: white;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

.header h1 {
  font-size: 24px;
  color: #2c3e50;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

.branch-name {
  font-weight: bold;
  color: #2c3e50;
}

.email {
  color: #7f8c8d;
  font-size: 13px;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
}

.badge-master {
  background-color: #e74c3c;
  color: white;
}

/* フォーム */
.form-section {
  background: white;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

.form-section h2 {
  font-size: 20px;
  margin-bottom: 20px;
  color: #2c3e50;
  border-bottom: 2px solid #3498db;
  padding-bottom: 10px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
  color: #2c3e50;
}

.form-group input[type='text'],
.form-group input[type='url'],
.form-group input[type='email'],
.form-group input[type='password'],
.form-group input[type='date'],
.form-group select {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #3498db;
}

.form-help {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  color: #7f8c8d;
}

.mode-section {
  margin-top: 15px;
  padding: 15px;
  background-color: #f8f9fa;
  border-radius: 4px;
}

/* PC表示で2カラムレイアウト */
@media (min-width: 769px) {
  .mode-section {
    display: flex;
    gap: 20px;
  }

  .mode-section .form-group {
    flex: 1;
  }
}

/* ボタン */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.3s;
}

.btn-primary {
  background-color: #3498db;
  color: white;
}

.btn-primary:hover {
  background-color: #2980b9;
}

.btn-large {
  padding: 12px 30px;
  font-size: 16px;
  width: 100%;
}

.btn-link {
  background: none;
  color: #3498db;
  padding: 5px 10px;
  font-size: 13px;
}

.btn-link:hover {
  text-decoration: underline;
}

/* エラーメッセージ */
.error-message {
  background-color: #fee;
  color: #c33;
  padding: 12px;
  border-radius: 4px;
  margin-bottom: 20px;
  border-left: 4px solid #c33;
}

/* ローディング */
.loading {
  text-align: center;
  padding: 40px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

.loading p {
  color: #7f8c8d;
  font-size: 16px;
}

/* 結果セクション */
.results-section {
  background: white;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

.results-section h2 {
  font-size: 20px;
  margin-bottom: 20px;
  color: #2c3e50;
  border-bottom: 2px solid #27ae60;
  padding-bottom: 10px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.metric-card {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  border-left: 4px solid #3498db;
}

.metric-card-after {
  border-left-color: #2ecc71;
}

.metric-card h3 {
  font-size: 14px;
  color: #7f8c8d;
  margin-bottom: 10px;
}

.metric-card .value {
  font-size: 32px;
  font-weight: bold;
  color: #2c3e50;
}

.metric-card .unit {
  font-size: 14px;
  color: #7f8c8d;
  margin-left: 5px;
}

.metric-description {
  font-size: 0.825rem;
}

.comparison-section {
  margin-block: 1rem;
  padding: 20px;
  background-color: #fff3cd;
  border-radius: 8px;
  border-left: 4px solid #ffc107;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.comparison-section h3 {
  font-size: 16px;
  margin-bottom: 15px;
  color: #856404;
}

.comparison-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #ffeaa7;
}

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

.comparison-label {
  font-weight: bold;
  color: #856404;
}

.comparison-value {
  color: #856404;
}

.comparison-value.positive {
  color: #27ae60;
}

.comparison-value.negative {
  color: #e74c3c;
}

/* フェーズ4: 詳細ビューのカードスタイル */
.period-section {
  background: white;
  padding: 25px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

.period-section:first-child {
  margin-top: 0;
}

.period-section-separated {
  margin-top: 30px;
  padding-top: 30px;
  border-top: 2px solid #ddd;
}

.url-info {
  background: white;
  padding: 15px 20px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
  color: #2c3e50;
}

.ranking-section {
  margin-top: 30px;
  background: white;
  padding: 25px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ranking-section h3 {
  font-size: 18px;
  margin-bottom: 15px;
  color: #2c3e50;
}

.ranking-description {
  font-size: 12px;
  color: #7f8c8d;
  margin-bottom: 15px;
}

.no-data-message {
  padding: 20px;
  text-align: center;
  color: #7f8c8d;
  font-style: italic;
  background-color: #f8f9fa;
  border-radius: 4px;
  margin-top: 10px;
}

.ranking-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 30px;
}

.ranking-table th,
.ranking-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #ddd;
}

.ranking-table th {
  background-color: #f8f9fa;
  font-weight: bold;
  color: #2c3e50;
}

.ranking-table tr:hover {
  background-color: #f8f9fa;
}

.ranking-table .rank {
  width: 50px;
  text-align: center;
  font-weight: bold;
  color: #7f8c8d;
}

.ranking-table .url {
  word-break: break-all;
  max-width: 400px;
}

.ranking-table .title {
  color: #7f8c8d;
  font-size: 13px;
}

.ranking-table .views {
  text-align: right;
  font-weight: bold;
}

/* フェーズ1: 固定カラー定義 */
:root {
  --color-blue: #3498db;
  --color-blue-light: #e8f4f8;
  --color-peach: #ff9f80;
  --color-peach-light: #fff0ed;
  --color-mint: #4ecdc4;
  --color-mint-light: #e8f7f6;
  --color-lavender: #a29bfe;
  --color-lavender-light: #f0eefd;
  --color-lemon: #fdcb6e;
  --color-lemon-light: #fff8e8;
}

/* URL入力ブロック */
.url-input-block {
  margin-bottom: 20px;
}

.url-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 15px;
  padding: 15px;
  background-color: #f8f9fa;
  border-radius: 4px;
  position: relative;
}

.url-input-row.color-1 {
  border-left: 4px solid var(--color-blue);
}

.url-input-row.color-2 {
  border-left: 4px solid var(--color-peach);
}

.url-input-row.color-3 {
  border-left: 4px solid var(--color-mint);
}

.url-input-row.color-4 {
  border-left: 4px solid var(--color-lavender);
}

.url-input-row.color-5 {
  border-left: 4px solid var(--color-lemon);
}

.url-input-row .color-tag {
  display: inline-block;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  flex-shrink: 0;
  margin-top: 8px;
}

.url-input-row .color-tag.color-1 {
  background-color: var(--color-blue);
}

.url-input-row .color-tag.color-2 {
  background-color: var(--color-peach);
}

.url-input-row .color-tag.color-3 {
  background-color: var(--color-mint);
}

.url-input-row .color-tag.color-4 {
  background-color: var(--color-lavender);
}

.url-input-row .color-tag.color-5 {
  background-color: var(--color-lemon);
}

.url-input-row .input-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.url-input-row .input-group-url {
  flex: 1;
}

.url-input-row input[type='url'],
.url-input-row input[type='text'] {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.url-input-row .remove-btn {
  background-color: #e74c3c;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  flex-shrink: 0;
  margin-top: 8px;
}

.url-input-row .remove-btn:hover {
  background-color: #c0392b;
}

.add-url-btn {
  background-color: #27ae60;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 10px 20px;
  cursor: pointer;
  font-size: 14px;
  margin-bottom: 20px;
}

.add-url-btn:hover {
  background-color: #229954;
}

.add-url-btn:disabled {
  background-color: #95a5a6;
  cursor: not-allowed;
}

/* タブ */
.tabs-container {
  margin-top: 20px;
}

.tabs {
  display: flex;
  gap: 5px;
  border-bottom: 2px solid #ddd;
  margin-bottom: 20px;
  overflow-x: auto;
}

.tab {
  padding: 12px 20px;
  background-color: #f8f9fa;
  border: none;
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  color: #7f8c8d;
  transition: all 0.3s;
  white-space: nowrap;
}

.tab:hover {
  background-color: #e9ecef;
}

.tab.active {
  background-color: #fff;
  color: #2c3e50;
  font-weight: bold;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}

.tab.color-1.active {
  background-color: var(--color-blue);
  color: white;
}

.tab.color-2.active {
  background-color: var(--color-peach);
  color: white;
}

.tab.color-3.active {
  background-color: var(--color-mint);
  color: white;
}

.tab.color-4.active {
  background-color: var(--color-lavender);
  color: white;
}

.tab.color-5.active {
  background-color: var(--color-lemon);
  color: white;
}

.tab.color-1:not(.active) {
  background-color: var(--color-blue-light);
}

.tab.color-2:not(.active) {
  background-color: var(--color-peach-light);
}

.tab.color-3:not(.active) {
  background-color: var(--color-mint-light);
}

.tab.color-4:not(.active) {
  background-color: var(--color-lavender-light);
}

.tab.color-5:not(.active) {
  background-color: var(--color-lemon-light);
}

.tab-content {
  display: none;
  padding: 20px;
  border-radius: 4px;
  transition: background-color 0.25s ease, opacity 0.25s ease;
  opacity: 0;
}

.tab-content.active {
  display: block;
  opacity: 1;
}

.tab-content.color-1 {
  background-color: var(--color-blue-light);
}

.tab-content.color-2 {
  background-color: var(--color-peach-light);
}

.tab-content.color-3 {
  background-color: var(--color-mint-light);
}

.tab-content.color-4 {
  background-color: var(--color-lavender-light);
}

.tab-content.color-5 {
  background-color: var(--color-lemon-light);
}

/* フェーズ2: サマリー表（v2-1仕様） */
.summary-section-top {
  background: white;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

.summary-section-top h2 {
  font-size: 20px;
  margin-bottom: 20px;
  color: #2c3e50;
  border-bottom: 2px solid #3498db;
  padding-bottom: 10px;
}

.summary-table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
  /* スマホでの横スクロールを確実にする */
  max-width: 100%;
  width: 100%;
}

.summary-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 600px;
}

.summary-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.summary-table thead th {
  background-color: #f8f9fa;
  font-weight: bold;
  color: #2c3e50;
  padding: 12px;
  text-align: center;
  border-bottom: 2px solid #ddd;
  white-space: nowrap;
  /* stickyヘッダーの視認性向上 */
  box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.1);
}

.summary-table thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 11;
  background-color: #f8f9fa;
  border-right: 2px solid #ddd;
  /* 左上角のセルは両方のstickyが重なるため、z-indexを最高にする */
  box-shadow: 2px 2px 2px -1px rgba(0, 0, 0, 0.1);
}

.summary-table tbody td {
  padding: 12px;
  text-align: center;
  border-bottom: 1px solid #e9ecef;
  white-space: nowrap;
}

.summary-table tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 9;
  border-right: 2px solid #ddd;
  text-align: left;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  /* 背景色はインラインスタイルで設定されるため、ここでは設定しない */
  /* sticky左列の視認性向上 */
  box-shadow: 2px 0 2px -1px rgba(0, 0, 0, 0.1);
}

.summary-table tbody tr:hover {
  opacity: 0.95;
}

.summary-table tbody tr:hover td {
  /* ホバー時も背景色を維持（インラインスタイルで設定された背景色を上書きしない） */
  opacity: 0.95;
}

/* URLラベルセル */
.summary-url-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
}

.summary-url-color-tag {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  flex-shrink: 0;
}

.summary-url-color-tag.color-1 {
  background-color: var(--color-blue);
}

.summary-url-color-tag.color-2 {
  background-color: var(--color-peach);
}

.summary-url-color-tag.color-3 {
  background-color: var(--color-mint);
}

.summary-url-color-tag.color-4 {
  background-color: var(--color-lavender);
}

.summary-url-color-tag.color-5 {
  background-color: var(--color-lemon);
}

.summary-url-label {
  font-weight: 500;
  color: #2c3e50;
}

.summary-url-value {
  font-size: 12px;
  color: #7f8c8d;
  word-break: break-all;
}

/* レスポンシブ */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
  }

  .user-info {
    margin-top: 15px;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .ranking-table {
    font-size: 12px;
  }

  .ranking-table .url {
    max-width: 200px;
  }

  .url-input-row {
    flex-direction: column;
  }

  .url-input-row .input-group {
    width: 100%;
  }

  .tabs {
    flex-wrap: nowrap;
  }
}
