/* General Styles */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  padding: 20px;
  background-color: #f7f7f7;
  color: #333;
  line-height: 1.6;
}

h1 {
  color: #007bff;
  text-align: center;
  margin-bottom: 2rem;
}

h2 {
  margin-top: 0;
  color: #333;
  border-bottom: 2px solid #007bff;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.section {
  background-color: #fff;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Visually Hidden Class for Accessibility */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


/* QR Code Styles */
#qrcode {
  display: block;
  margin: 1rem auto;
  border: 1px solid #ccc;
}

#qr-reader {
  border: 2px dashed #007bff;
  border-radius: 4px;
}

/* Form Elements */
input[type="text"],
input[type="file"] {
  width: calc(100% - 22px); /* padding and border consideration */
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-sizing: border-box;
  font-size: 1rem;
}

input[type="file"] {
    width: auto; /* Let the browser decide for file input */
}


button {
  background-color: #007bff;
  color: white;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  transition: background-color 0.2s ease-in-out;
}

button:hover {
  background-color: #0056b3;
}

button:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}

/* Message Area Styles */
.message-area, .post-area {
  height: 200px;
  overflow-y: auto;
  border: 1px solid #eee;
  padding: 0.75rem;
  margin-top: 0.75rem;
  background-color: #f9f9f9;
  border-radius: 4px;
}

.message, .post {
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  border-radius: 4px;
  word-wrap: break-word;
}

.message.own-message, .post.own-post { /* Assuming own-post class for user's posts */
  background-color: #dcf8c6;
  text-align: right;
  margin-left: auto;
  max-width: 70%;
}

.message.peer-message, .post.peer-post { /* Assuming peer-post class for others' posts */
  background-color: #fff;
  border: 1px solid #eee;
  text-align: left;
  margin-right: auto;
  max-width: 70%;
}

.post-meta {
  font-size: 0.8em;
  color: #777;
  margin-bottom: 0.25rem;
}

.delete-post-button {
  background: none;
  border: none;
  color: #dc3545;
  cursor: pointer;
  font-size: 0.8em;
  padding: 0.2rem 0.4rem;
  margin-left: 0.5rem;
}
.delete-post-button:hover {
  text-decoration: underline;
  background-color: transparent; /* Override general button hover */
}

#connectionStatus {
  display: none; /* 初期状態は非表示。JSで表示を制御 */
  font-weight: bold;
  max-height: 25px; /* 通常時の最大の高さ */
  overflow-y: scroll;  /* 常に縦スクロールバーを表示 */
  border: 1px solid #ccc;
  padding: 0 0.75rem 0.75rem; /* 上部のパディングを0に、左右と下部は0.75remを維持 */
  margin-bottom: 1rem;
  background-color: #f9f9f9;
  border-radius: 4px;
  font-size: 0.9em;
  line-height: 1.4;
  width: 90%; /* 画面幅に対する割合 */
  max-width: 600px; /* 最大幅を指定 */
  margin-left: auto; /* 中央揃え */
  margin-right: auto; /* 中央揃え */
  box-sizing: border-box; /* paddingとborderをwidthに含める */
  cursor: pointer; /* クリック可能であることを示すカーソル */
  transition: max-height 0.3s ease-in-out; /* スムーズな高さ変更アニメーション */
}

#connectionStatus.status-expanded {
  max-height: 1000px; /* 拡大時の最大の高さ */
}

/* ステータスメッセージの各行のスタイル */
#connectionStatus > div {
  white-space: pre-line; /* \n で改行できるようにする */
}

/* Video Meeting Styles */
.video-container {
  display: flex;
  flex-direction: column; /* Mobile default: main container is column */
  align-items: center;
  background-color: #eee;
  padding: 0.5rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  position: relative;
  min-height: 180px; /* Minimum height for at least one video */
}

.video-scroll-container {
  display: flex;
  /* Mobile default: Vertical scroll */
  flex-direction: column;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  width: 100%;
  max-height: 320px; /* Example: height for about two videos */
  -webkit-overflow-scrolling: touch; /* iOS smooth scrolling */
  align-items: center; /* Center videos horizontally */
}

.video-scroll-container video {
  /* Mobile default: Vertically stacked videos */
  width: 90%; /* Relative to container */
  height: 150px; /* Fixed height */
  max-width: 400px; /* Max width */
  margin: 0.5rem 0; /* Vertical margin */
  scroll-snap-align: center; /* Snap to center for vertical scroll */
  background-color: #333;
  border: 1px solid #ccc;
  object-fit: cover; /* Maintain aspect ratio and fill */
}

.video-scroll-controls {
  display: flex;
  justify-content: center;
  margin-top: 0.5rem;
}

.video-scroll-controls button {
  padding: 0.5rem 1rem;
  margin: 0 0.25rem;
  font-size: 1rem;
}

.call-controls {
  display: flex;
  justify-content: center;
  gap: 1rem; /* Space between buttons */
  margin-top: 1rem;
}

.call-controls button {
  font-size: 1.5rem; /* Bigger icons */
  padding: 0.5rem;
  line-height: 1; /* Adjust for better icon centering */
}

#file-transfer-status {
  display: inline-block; /* To allow margin */
}

/* PC Styles (screen width 600px and above) */
@media screen and (min-width: 600px) {
  .video-container {
    flex-direction: row; /* PC: main container is row */
    align-items: flex-start; /* Align items to the top */
  }

  .video-scroll-container {
    /* PC: Horizontal scroll */
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden; /* No vertical scroll */
    scroll-snap-type: x mandatory;
    justify-content: flex-start; /* Align videos from the left */
    width: 100%;
    max-height: 200px; /* Height of video area on PC */
    height: auto; /* Adjust to content */
  }

  .video-scroll-container video {
    /* PC: Horizontally arranged videos */
    width: auto; /* Width based on content */
    height: 180px; /* Height of videos on PC */
    min-width: 240px; /* Min width for videos on PC */
    max-width: 320px; /* Max width for videos on PC */
    margin: 0 0.5rem; /* Horizontal margin */
    scroll-snap-align: start; /* Snap to start for horizontal scroll */
  }

  /* Hide scroll buttons on mobile if desired, or style them differently */
  /* For now, they are always visible. Add display: none; for mobile if needed */
}

/* Specific ID styles - keep if still relevant, or integrate into class styles */
#localVideo {
  border: 2px solid blue; /* Example: if you want to highlight local video */
}