/* ========================================================
   WebView Access Log Viewer - Stylesheet
   ======================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  background-color: #0f172a;
  color: #f1f5f9;
  line-height: 1.5;
  font-size: 14px;
  padding-bottom: 50px;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ヘッダー */
.viewer-header {
  background: #1e293b;
  border-bottom: 1px solid #334155;
  padding: 20px 16px;
}

.header-content {
  max-width: 960px;
  margin: 0 auto;
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #38bdf8;
}

.subtitle {
  color: #94a3b8;
  font-size: 0.825rem;
  margin-top: 6px;
}

.header-buttons {
  display: flex;
  gap: 8px;
}

/* ボタン */
.btn {
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.btn-primary { background: #2563eb; color: white; }
.btn-primary:active { background: #1d4ed8; }

.btn-secondary { background: #334155; color: #f1f5f9; }
.btn-secondary:active { background: #475569; }

.btn-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}
.btn-danger:active { background: rgba(239, 68, 68, 0.4); }

.btn-outline {
  background: transparent;
  border: 1px solid #38bdf8;
  color: #38bdf8;
}
.btn-outline:active { background: rgba(56, 189, 248, 0.1); }

.btn-sm { padding: 6px 10px; font-size: 0.75rem; }

/* コントロールバー */
.control-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  flex-wrap: wrap;
  gap: 12px;
  background: #1e293b;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid #334155;
}

.tab-controls { display: flex; gap: 6px; flex-wrap: wrap; }

.tab-btn {
  background: #0f172a;
  border: 1px solid #334155;
  color: #94a3b8;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.775rem;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active {
  background: #0284c7;
  color: white;
  border-color: #38bdf8;
}

.action-controls { display: flex; gap: 8px; }

/* ログリスト */
.log-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.log-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}

.log-card:hover { border-color: #38bdf8; }

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.log-title-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-source {
  font-size: 0.675rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.badge-source.cloud { background: #0369a1; color: #bae6fd; }
.badge-source.local { background: #4338ca; color: #c7d2fe; }

.log-date { font-size: 0.75rem; color: #94a3b8; }

.log-score-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 9999px;
}
.log-score-badge.pass { background: #065f46; color: #34d399; }
.log-score-badge.warn { background: #854d0e; color: #facc15; }
.log-score-badge.fail { background: #7f1d1d; color: #f87171; }

.log-main-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  background: #0f172a;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid #28374d;
  margin-bottom: 10px;
}

.info-piece { font-size: 0.775rem; }
.info-piece .label {
  color: #64748b;
  font-size: 0.7rem;
  display: block;
}
.info-piece .val {
  color: #e2e8f0;
  font-weight: 600;
  word-break: break-all;
}

.log-breakdown {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.725rem;
  color: #94a3b8;
}

.breakdown-pill {
  background: #243247;
  padding: 2px 8px;
  border-radius: 4px;
}
.breakdown-pill b { color: #38bdf8; }

/* 空状態・ローディング */
.loading-state, .empty-state {
  text-align: center;
  padding: 60px 20px;
  background: #1e293b;
  border: 1px dashed #334155;
  border-radius: 12px;
  color: #94a3b8;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 4px solid #334155;
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 12px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* モーダル */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}

.modal-dialog {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  max-width: 820px;
  width: 100%;
  height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.modal-header {
  padding: 14px 18px;
  background: #243247;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #334155;
}

.modal-title-area {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.modal-title-area h3 {
  font-size: 1rem;
  color: #f8fafc;
}

.modal-sub {
  font-size: 0.725rem;
  color: #94a3b8;
}

.btn-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.5rem;
  cursor: pointer;
}
.btn-close:hover { color: #f1f5f9; }

/* モーダル内タブバー */
.modal-tab-bar {
  display: flex;
  background: #0f172a;
  border-bottom: 1px solid #334155;
  padding: 0 16px;
  gap: 8px;
  overflow-x: auto;
}

.modal-tab {
  background: transparent;
  border: none;
  color: #94a3b8;
  padding: 10px 14px;
  font-size: 0.775rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.modal-tab.active {
  color: #38bdf8;
  border-bottom-color: #38bdf8;
  background: rgba(56, 189, 248, 0.05);
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  font-size: 0.8rem;
  color: #cbd5e1;
  flex: 1;
}

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

/* フィルターと検索バー */
.test-filter-bar {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.search-input {
  background: #0f172a;
  border: 1px solid #334155;
  color: #f1f5f9;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.775rem;
  flex: 1;
  min-width: 220px;
}
.search-input:focus {
  outline: none;
  border-color: #38bdf8;
}

.test-status-filters {
  display: flex;
  gap: 10px;
  font-size: 0.75rem;
  color: #94a3b8;
}

/* 全テスト項目リストグリッド */
.modal-test-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.test-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #0f172a;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #28374d;
}

.test-row-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 80%;
}

.test-row-name {
  font-weight: 600;
  color: #f1f5f9;
  font-size: 0.8rem;
}

.test-row-desc {
  font-size: 0.7rem;
  color: #94a3b8;
}

.test-row-tag {
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: #1e293b;
  color: #64748b;
  display: inline-block;
  margin-right: 6px;
}

.status-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 9999px;
  min-width: 58px;
  text-align: center;
}
.status-badge.pass { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid rgba(52, 211, 153, 0.4); }
.status-badge.fail { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid rgba(248, 113, 113, 0.4); }

/* データテーブル */
.detail-data-table {
  width: 100%;
  border-collapse: collapse;
}

.detail-data-table th, .detail-data-table td {
  padding: 8px 12px;
  border: 1px solid #334155;
  font-size: 0.775rem;
  text-align: left;
}

.detail-data-table th {
  background: #0f172a;
  color: #94a3b8;
  width: 30%;
  font-weight: 600;
}

.detail-data-table td {
  background: #1e293b;
  word-break: break-all;
  color: #e2e8f0;
}

.net-section-title {
  font-size: 0.825rem;
  font-weight: 700;
  color: #38bdf8;
  margin-bottom: 8px;
}

.raw-json-box {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 14px;
  font-family: monospace;
  font-size: 0.725rem;
  color: #93c5fd;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 50vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 12px 18px;
  background: #243247;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid #334155;
}

.viewer-footer {
  text-align: center;
  margin-top: 40px;
  color: #64748b;
  font-size: 0.75rem;
}
