/* ページ固有のスタイル */
:root {
  --bg-page: linear-gradient(135deg, #f0f0f5 0%, #e8e8ee 100%);
  --bg-card: #ffffff;
  --radius: 12px;
  --transition: 0.3s ease;
  --accent: #007AFF;
}

/* ナビバーアイコンのスタイル */
nav ul li a i {
  margin-right: 8px;
  font-size: 1.1em;
}

/* アクティブなページのアイコン - 青色 */
nav ul li a.active i {
  color: #007AFF;
}

/* アクティブでないページのアイコン - グレーの線だけ */
nav ul li a:not(.active) i {
  color: #999;
  opacity: 0.7;
}

body {
  background: var(--bg-page);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1d1d20;
  padding-top: 64px;
  padding-left: 32px;
  padding-right: 32px;
}

.page-container {
  max-width: 100%;
  margin: 0 auto 32px;
  padding-left: 0;
  padding-right: 0;
  box-sizing: border-box;
}

/* h1と.subtitleのスタイルをupload.htmlと統一 */
h1 {
  text-align: center;
  font-size: 2rem;
  margin-bottom: 1rem;
  background: linear-gradient(90deg, var(--accent), #5ac8fa);
  -webkit-background-clip: text;
  color: transparent;
}

.subtitle {
  text-align: center; 
  font-size: 19px;
  margin-bottom: 32px; 
  color: #6e6e73;
}

/* 統計情報セクションのスタイル */
.stats-section {
  margin-bottom: 32px;
  padding: 0 32px;
}

.stats-container {
  display: flex;
  justify-content: center;
  gap: 48px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  padding: 24px 32px;
}

.stat-item {
  text-align: center;
  min-width: 120px;
}

.stat-number {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
  line-height: 1;
}

.stat-label {
  font-size: 0.9rem;
  color: #6e6e73;
  font-weight: 500;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .stats-section {
    padding: 0 16px;
  }
  
  .stats-container {
    flex-direction: column;
    gap: 24px;
    padding: 20px 24px;
  }
  
  .stat-item {
    min-width: auto;
  }
  
  .stat-number {
    font-size: 2rem;
  }
}

/* search.html用のmainスタイルを上書き */
main {
  max-width: 1550px;
  margin: 96px auto 32px;
  padding-left: 32px;
  padding-right: 32px;
  box-sizing: border-box;
}

.combined-section {
  background: var(--bg-card); 
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.filter-section {
  padding: 1.5rem 2rem 1rem 2rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.section-divider {
  height: 1px;
  background: #eaeaea;
  margin: 0 2rem;
}

.filter-row {
  display: flex; 
  flex-wrap: wrap; 
  justify-content: center;
  align-items: center; 
  gap: 1.5rem;
  min-width: max-content;
}

.filter-fields {
  display: flex;
  flex-wrap: nowrap;
  gap: 1.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.5rem;
  max-width: 100%;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.filter-group label {
  font-size: 0.9rem; 
  color: #666;
  white-space: nowrap;
  line-height: 1;
  margin: 0;
  padding: 0;
}

.filter-group select {
  padding: 0.5rem; 
  border: 1px solid #ccc;
  border-radius: 4px; 
  font-size: 0.9rem;
  min-width: 120px;
  margin: 0;
  line-height: 1;
}

.filter-buttons {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

#btnClearFilters, #btnRefresh {
  padding: 0.5rem 1rem; 
  font-size: 0.9rem;
  background: #e0f0ff; 
  color: var(--accent);
  border: 1px solid #c0e0ff; 
  border-radius: 4px;
  cursor: pointer; 
  font-weight: bold;
  transition: background var(--transition), transform .2s;
  white-space: nowrap;
  flex-shrink: 0;
}
#btnClearFilters:hover, #btnRefresh:hover {
  background: #d0eaff; 
  transform: translateY(-1px);
}

.controls-section {
  padding: 1rem 3rem 1.5rem 3rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
  gap: 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.controls-left, .controls-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.controls-left label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: #666;
  white-space: nowrap;
  margin: 0;
  padding: 0;
  line-height: 1;
  margin-bottom: 0;
  padding-bottom: 0;
  cursor: pointer;
}

/* カスタムチェックボックススタイル */
.controls-left input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid #ccc;
  border-radius: 3px;
  background: #fff;
  cursor: pointer;
  position: relative;
  transition: all var(--transition);
  flex-shrink: 0;
}

.controls-left input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.controls-left input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0px;
  width: 6px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.controls-left input[type="checkbox"]:hover {
  border-color: var(--accent);
  transform: scale(1.05);
}

.controls-left input[type="checkbox"]:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 113, 227, 0.2);
}

.controls-right label {
  margin: 0;
  padding: 0;
  line-height: 1;
  margin-bottom: 0;
  padding-bottom: 0;
}

.controls-right {
  gap: 0.5rem;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.controls-right select {
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9rem;
  white-space: nowrap;
  flex-shrink: 0;
  width: auto;
  min-width: 140px;
  max-width: 160px;
  margin: 0;
  line-height: 1;
}

.table-container {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-card {
  width: 100%; 
  border-collapse: collapse;
  min-width: 1300px;
}

.table-card th, .table-card td {
  padding: 12px; 
  vertical-align: middle;
  border-bottom: 1px solid #eaeaea; 
  font-size: 0.9rem;
  white-space: nowrap;
  text-align: left;
}

.table-card th {
  background: #f7f7f9; 
  color: #666;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 10;
}

/* 学年列 - 最大テキスト: 高2 */
.table-card th:first-child,
.table-card td.grade-cell {
  width: 45px;
  min-width: 45px;
  max-width: 60px;
  text-align: center;
}

/* 年度列 - 最大テキスト: 2022（R4） */
.table-card td.year-cell {
  width: 70px;
  min-width: 60px;
  max-width: 80px;
}

/* 種類列 - 最大テキスト: 前期期末 */
.table-card td.type-cell {
  width: 35px;
  min-width: 35px;
  max-width: 50px;
}

/* 科目列 - 長めの幅 */
.table-card td.subject-cell {
  width: 60px;
  min-width: 80px;
  max-width: 100px;
}

/* 文理区分列 - 最大テキスト: 理数科のみ */
.table-card td.stream-cell {
  width: 45px;
  min-width: 50px;
  max-width: 60px;
}

/* 内容列 - 適度な幅 */
.table-card td.content-cell {
  width: 50px;
  min-width: 50px;
  max-width: 60px;
}

.table-card td.comment-cell { 
  width: 120px; 
  min-width: 100px;
  max-width: 150px;
  white-space: normal;
}

.table-card td.format-cell { 
  width: 80px;
  min-width: 80px;
  max-width: 100px;
}

.table-card td.date-cell {
  width: 70px;
  min-width: 50px;
  max-width: 80px;
}

.table-card td.eval-cell {
  width: 100px;
  min-width: 100px;
  max-width: 120px;
}

th.hidden-col, td.hidden-col { display: none; }

.comment-text { 
  overflow: hidden; 
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.4;
}

.table-card tbody tr {
  transition: background var(--transition);
}
.table-card tbody tr:hover {
  background: #f8f9fa;
}

.btn-like, .btn-bad {
  display: inline-flex; 
  align-items: center; 
  justify-content: center;
  padding: 6px 12px; 
  margin-right: 8px; 
  border-radius: 6px;
  border: 1px solid #e0e0e0; 
  background: #f8f9fa;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.85rem;
  font-weight: 500;
  min-width: 60px;
  position: relative;
}

.btn-like::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 4px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.7;
}

.btn-bad::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 4px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.7;
}

.btn-like { 
  color: #666; 
  border-color: #e0e0e0; 
}
.btn-bad { 
  color: #666; 
  border-color: #e0e0e0; 
}
.btn-like:hover, .btn-bad:hover { 
  background: #e9ecef; 
  border-color: #ced4da;
  transform: translateY(-1px);
}
.btn-like.active { 
  background: rgba(0, 113, 227, 0.1); 
  color: #0071e3; 
  border-color: #0071e3;
  box-shadow: 0 2px 4px rgba(0, 113, 227, 0.1);
}

.btn-like.active::before {
  opacity: 1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230071e3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z'/%3E%3C/svg%3E");
}

.btn-bad.active { 
  background: rgba(220, 53, 69, 0.1); 
  color: #dc3545; 
  border-color: #dc3545;
  box-shadow: 0 2px 4px rgba(220, 53, 69, 0.1);
}

.btn-bad.active::before {
  opacity: 1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23dc3545' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17'/%3E%3C/svg%3E");
}

/* ボタン無効化時のスタイル */
.btn-like:disabled, .btn-bad:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* リンクボタンスタイル */
.link-cell {
  width: 60px;
  min-width: 60px;
  max-width: 60px;
  text-align: center;
}

.view-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
  background: #f8f9fa;
  color: #333;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.85rem;
  font-weight: 500;
  min-width: 60px;
  white-space: nowrap;
}

.view-link:hover {
  background: #e9ecef;
  border-color: #ced4da;
  transform: translateY(-1px);
  color: var(--accent);
  text-decoration: none;
}

.extra-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.8rem;
  margin-left: 0.5rem;
}
.extra-link:hover {
  text-decoration: underline;
}

/* ポップアップスタイル */
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
  box-sizing: border-box;
}

.popup-content {
  background: white;
  border-radius: 12px;
  padding: 1rem 2rem;
  width: 100%;
  max-width: 900px;
  height: auto;
  max-height: 90vh;
  text-align: center;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.popup-close {
  position: absolute;
  top: 10px;
  right: 15px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #666;
}

.countdown-text {
  font-size: 2rem;
  color: var(--accent);
  margin: 1rem 0;
  font-weight: bold;
}

.ad-video {
  width: 800px;
  max-width: 90%;
  height: 0;
  padding-bottom: 50.625%; /* 16:9 aspect ratio */
  position: relative;
  margin: 0 auto;
  border: none;
  border-radius: 8px;
  overflow: hidden;
}

.ad-video iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 8px;
}

/* モバイル対応 */
@media (max-width: 768px) {
  
  .page-container {
    padding: 1rem 0.5rem;
  }
  

  .filter-section {
    padding: 1rem;
  }
  
  .filter-row {
    gap: 0.5rem;
    overflow-x: auto;
    flex-wrap: wrap;
  }
  
  .filter-group {
    flex-direction: row;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
  }
  
  .filter-group select {
    min-width: 100px;
  }
  
  .filter-buttons {
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
    width: 100%;
  }
  
  #btnClearFilters, #btnRefresh {
    width: 100%;
  }
  
  .controls-section {
    flex-direction: row;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    overflow-x: auto;
  }
  
  .controls-left, .controls-right {
    justify-content: flex-start;
    gap: 0.5rem;
    flex-shrink: 0;
  }
  
  .table-card {
    min-width: 800px;
  }
  
  .table-card th, .table-card td {
    padding: 8px;
    font-size: 0.8rem;
  }
  
  .table-card td.comment-cell {
    width: 200px;
    min-width: 200px;
    max-width: 200px;
  }

  .popup-content {
    padding: 0.5rem 1rem;
    max-width: 95%;
    max-height: 90vh;
  }

  .ad-video {
    width: 100%;
    max-width: 95%;
    padding-bottom: 53.4375%; /* 16:9 aspect ratio for mobile */
  }

  .countdown-text {
    font-size: 1.5rem;
  }
}

@media (max-width: 480px) {
  .filter-buttons {
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
    width: 100%;
  }
  
  #btnClearFilters, #btnRefresh {
    width: 100%;
  }
  
  .controls-left {
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
  }
  
  .controls-right {
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
  }
  
  .controls-right select {
    width: auto;
  }
}

/* ローディングスピナー */
.loading-placeholder {
  text-align: center;
  padding: 40px 20px;
  color: #64748b;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(59, 130, 246, 0.1);
  border-top: 3px solid #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* フリーモード表示デザインはcommon.cssで統一 */

/* フィルターエリアが狭い時のボタン改行 */
@media (max-width: 1400px) {
  .filter-row {
    flex-direction: column;
    gap: 1rem;
  }
  
  .filter-fields {
    width: 100%;
    justify-content: center;
  }
  
  .filter-buttons {
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    margin-top: 0.5rem;
  }
  
  #btnClearFilters, #btnRefresh {
    min-width: 120px;
  }
}

/* ウィンドウ幅が小さい時の列幅調整 */
@media (max-width: 1200px) {
  /* 年度列を縮小 */
  .table-card td.year-cell {
    width: 50px;
    min-width: 40px;
    max-width: 70px;
  }
  
  /* 文理区分列を縮小 */
  .table-card td.stream-cell {
    width: 45px;
    min-width: 45px;
    max-width: 60px;
  }
  
  /* 投稿時間列を縮小 */
  .table-card td.date-cell {
    width: 60px;
    min-width: 40px;
    max-width: 80px;
  }
  
  /* 種類列も少し縮小 */
  .table-card td.type-cell {
    width: 50px;
    min-width: 50px;
    max-width: 80px;
  }
  
  /* 内容列も縮小 */
  .table-card td.content-cell {
    width: 50px;
    min-width: 50px;
    max-width: 80px;
  }
}

@media (max-width: 1000px) {
  /* さらに小さい画面での調整 */
  .table-card td.year-cell {
    width: 35px;
    min-width: 30px;
    max-width: 50px;
  }
  
  .table-card td.stream-cell {
    width: 35px;
    min-width: 35px;
    max-width: 50px;
  }
  
  .table-card td.date-cell {
    width: 45px;
    min-width: 30px;
    max-width: 60px;
  }
  
  .table-card td.type-cell {
    width: 45px;
    min-width: 45px;
    max-width: 70px;
  }
  
  .table-card td.content-cell {
    width: 45px;
    min-width: 45px;
    max-width: 70px;
  }
  
  /* コメント列も少し縮小 */
  .table-card td.comment-cell {
    width: 180px;
    min-width: 150px;
    max-width: 250px;
  }
}

@media (max-width: 800px) {
  /* さらに小さい画面での調整 */
  .table-card td.year-cell {
    width: 30px;
    min-width: 25px;
    max-width: 40px;
  }
  
  .table-card td.stream-cell {
    width: 30px;
    min-width: 30px;
    max-width: 40px;
  }
  
  .table-card td.date-cell {
    width: 35px;
    min-width: 25px;
    max-width: 50px;
  }
  
  .table-card td.type-cell {
    width: 40px;
    min-width: 40px;
    max-width: 60px;
  }
  
  .table-card td.content-cell {
    width: 40px;
    min-width: 40px;
    max-width: 60px;
  }
}
