body {
  font-family: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'メイリオ', sans-serif;
  margin: 0;
  padding: 0;
  background-color: #f5f5f5;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

.screen {
  width: 100%;
  min-height: 100vh;
  padding: 20px;
}

header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
  background-color: #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.logo img {
  height: 40px;
  margin-bottom: 10px;
}

.nav-tabs {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
  justify-content: space-around;
}

.nav-item {
  flex: 1;
  text-align: center;
}

.nav-link {
  display: block;
  padding: 10px;
  color: #666;
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.nav-link.active {
  color: #007bff;
  border-bottom: 2px solid #007bff;
}

.content-screen {
  padding: 20px;
}

/* お知らせスタイル */
.notice-container {
  background: #fff;
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 20px;
}

.notice-item {
  display: flex;
  margin-bottom: 15px;
}

.notice-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-right: 10px;
  overflow: hidden;
}

.notice-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.notice-content {
  flex: 1;
  background: #f0f0f0;
  border-radius: 10px;
  padding: 10px;
  position: relative;
}

.notice-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
  font-size: 12px;
  color: #666;
}

.notice-text {
  font-size: 14px;
}

/* 利用者一覧テーブル */
.user-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
}

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

.user-table th {
  background-color: #f2f2f2;
}

.user-table tr:nth-child(even) {
  background-color: #f9f9f9;
}

/* 予約カレンダー */
#calendar {
  margin: 20px 0;
  background: #fff;
  padding: 10px;
  border-radius: 5px;
}

.fc-day-available {
  background-color: #d4edda !important;
}

.fc-day-limited {
  background-color: #fff3cd !important;
}

.fc-day-unavailable {
  background-color: #f8d7da !important;
}

.fc-day-selected {
  background-color: #cce5ff !important;
}

/* 予約リスト */
.reservation-list {
  list-style: none;
  padding: 0;
}

.reservation-item {
  background: #fff;
  padding: 10px;
  margin-bottom: 10px;
  border-radius: 5px;
  border-left: 4px solid #007bff;
}

.reservation-item.temporary {
  border-left-color: #dc3545;
  color: #dc3545;
}

/* モーダル */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5);
}

.modal-content {
  background-color: #fff;
  margin: 10% auto;
  padding: 20px;
  border-radius: 5px;
  width: 80%;
  max-width: 500px;
}

.close {
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

/* パスコード入力 */
.passcode-container {
  display: flex;
  justify-content: space-between;
  margin: 20px 0;
}

.passcode {
  width: 50px;
  height: 50px;
  font-size: 24px;
  text-align: center;
}

/* トーク画面のレイアウト修正 - 本格修正 */
#talkScreen {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 100px);
  overflow: hidden;
  position: relative;
  padding: 0;
}

/* トーク表示エリア - スクロールを強制的に有効 */
.talk-container {
  position: absolute;
  top: 15px;
  left: 15px;
  right: 15px;
  bottom: 80px; /* 入力欄の高さ + マージン分 */
  overflow-y: scroll !important; /* スクロールを強制 */
  -webkit-overflow-scrolling: touch; /* iOS向け慣性スクロール */
  background: #eee;
  border-radius: 5px;
  border: 1px solid #ddd;
  padding: 15px;
}

/* メッセージリストコンテナ - 表示修正 */
.talk-messages-list {
  display: flex;
  flex-direction: column;
  min-height: 0; /* 重要：親要素のスクロールを有効にする */
  /* 下部から表示を開始 */
  margin-top: auto;
}

/* 追加: メッセージが少ない場合でも下部から表示する */
.talk-container:has(.talk-messages-list) {
  justify-content: flex-end;
}

/* トーク入力エリア - 固定位置に配置 */
.talk-input {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 10px;
  align-items: center;
  width: calc(100% - 30px); /* 左右の余白を考慮 */
  margin: 10px 15px;
  padding: 10px;
  background: #fff;
  border-top: 1px solid #f0f0f0;
  border-radius: 5px;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

/* メッセージを包む内部コンテナ - 新しい方式 */
.talk-messages-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  /* 初期表示で下部からコンテンツを開始させる */
  justify-content: flex-end;
}

.talk-message {
  max-width: 70%;
  margin-bottom: 15px;
  position: relative;
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.talk-message.from-facility {
  align-self: flex-start;
}

.talk-message.from-me {
  align-self: flex-end;
  text-align: right;
}

.talk-header {
  display: flex;
  align-items: center;
  margin-bottom: 5px;
  font-size: 12px;
  color: #666;
}

.facility-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  margin-right: 5px;
}

.talk-bubble {
  padding: 10px 15px;
  border-radius: 15px;
  position: relative;
}

.from-facility .talk-bubble {
  background-color: #fff;
  border: 1px solid #ddd;
  border-top-left-radius: 2px;
}

.from-facility .talk-bubble::before {
  content: "";
  position: absolute;
  top: 0;
  left: -8px;
  width: 0;
  height: 0;
  border-top: 8px solid #fff;
  border-left: 8px solid transparent;
}

.from-facility .talk-bubble::after {
  content: "";
  position: absolute;
  top: -1px;
  left: -9px;
  width: 0;
  height: 0;
  border-top: 8px solid #ddd;
  border-left: 8px solid transparent;
  z-index: -1;
}

.from-me .talk-bubble {
  background-color: #8de055;
  border-top-right-radius: 2px;
  text-align: left;
}

.from-me .talk-bubble::before {
  content: "";
  position: absolute;
  top: 0;
  right: -8px;
  width: 0;
  height: 0;
  border-top: 8px solid #8de055;
  border-right: 8px solid transparent;
}

.talk-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.talk-time {
  font-size: 11px;
  color: #999;
  margin-top: 5px;
  display: block;
}

.from-facility .talk-time {
  text-align: left;
}

.from-me .talk-time {
  text-align: right;
}

/* メッセージ入力テキストエリア */
#messageInput {
  flex: 1;
  min-height: 45px;
  max-height: 100px; /* テキストエリアの最大高さを制限 */
  padding: 10px 15px;
  border: 1px solid #ddd;
  border-radius: 20px;
  resize: none;
  font-family: inherit;
  margin: 0;
  overflow-y: auto; /* 長いテキストの場合はスクロール */
}

/* 送信ボタン調整 */
#sendMessageBtn {
  height: 45px;
  min-width: 45px;
  margin-left: 5px;
}

/* トーク指示テキストの調整 */
.talk-instructions {
  margin-bottom: 10px;
  width: 100%;
  flex-shrink: 0;
}

.talk-info {
  background-color: rgba(255, 255, 255, 0.8);
  padding: 8px 12px;
  border-radius: 5px;
  font-size: 0.9em;
  color: #666;
  text-align: center;
  margin-top: 5px;
}

/* 送信ボタンをLINE風に変更 */
.send-button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: #00b900; /* LINE風の緑色 */
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background-color 0.2s;
}

.send-button:hover {
  background-color: #009900;
}

.send-button:active {
  background-color: #008800;
}

/* 紙飛行機アイコン（Unicode文字） */
.send-icon {
  font-size: 18px;
  transform: rotate(45deg);
}

/* 情報ボックス */
.info-box {
  background: #fff;
  padding: 10px;
  border-radius: 5px;
  margin-bottom: 10px;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
  .user-table {
    font-size: 12px;
  }
  
  .passcode {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }
  
  .modal-content {
    width: 95%;
    margin: 5% auto;
  }
}

/* 自分のメッセージのヘッダーも右寄せ */
.from-me .talk-header {
  justify-content: flex-end;
}

/* トーク画面が空の時の表示を改善 */
.no-talks {
  text-align: center;
  color: #999;
  margin: 20px 0;
  font-style: italic;
}
