/* ============================================
   租寓空房查詢系統 - 品牌識別規範
   標準色: 租寓綠 #5FBE91
   輔助色: 租寓黃 #FFE450, 租寓藍 #2D8FD2, 租寓灰 #3C4650
   字型: Noto Sans TC (中文), Arial (英文內文)
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@300;400;500;600;700&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Noto Sans TC', Arial, sans-serif;
  background: #f4f5f7;
  color: #3C4650;
  padding-bottom: 20px;
}

/* Header - 租寓綠 + 白字 */
header {
  background: #5FBE91;
  color: white;
  padding: 14px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(60,70,80,0.15);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
}

header h1 {
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-logo {
  height: 30px;
  width: auto;
  filter: brightness(0) invert(1);
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

#roomCount {
  background: rgba(255,255,255,0.25);
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
}

.btn-refresh {
  background: rgba(255,255,255,0.25);
  border: none;
  color: white;
  font-size: 18px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-refresh:hover {
  background: rgba(255,255,255,0.4);
}

.btn-refresh.spinning {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Search */
.search-bar {
  max-width: 1200px;
  margin: 12px auto 0;
  padding: 0 12px;
}

.search-bar input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 15px;
  font-family: 'Noto Sans TC', Arial, sans-serif;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  outline: none;
  transition: border-color 0.2s;
}

.search-bar input:focus {
  border-color: #5FBE91;
  box-shadow: 0 0 0 3px rgba(95,190,145,0.15);
}

/* Filter */
.filter-section {
  max-width: 1200px;
  margin: 8px auto 0;
  padding: 0 12px;
}

.filter-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: white;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: #3C4650;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  user-select: none;
}

.arrow {
  font-size: 12px;
  transition: transform 0.3s;
  color: #5FBE91;
}

.arrow.open {
  transform: rotate(180deg);
}

.filter-panel {
  display: none;
  background: white;
  margin-top: 4px;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.filter-panel.open {
  display: block;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.filter-group label {
  display: block;
  font-size: 12px;
  color: #7a8490;
  margin-bottom: 4px;
  font-weight: 500;
}

.filter-group select,
.filter-group input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  font-family: 'Noto Sans TC', Arial, sans-serif;
  background: #fafafa;
  outline: none;
}

.filter-group select:focus,
.filter-group input:focus {
  border-color: #5FBE91;
}

/* Multi-select dropdown */
.multi-select {
  position: relative;
}

.multi-select-display {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  font-family: 'Noto Sans TC', Arial, sans-serif;
  background: #fafafa;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #3C4650;
  user-select: none;
}

.multi-select.disabled .multi-select-display {
  background: #eee;
  color: #aaa;
  cursor: not-allowed;
}

.multi-select-display::after {
  content: '▾';
  float: right;
  color: #7a8490;
}

.multi-select-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  margin-top: 2px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.multi-select-dropdown.open {
  display: block;
}

.multi-select-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s;
}

.multi-select-item:hover {
  background: #f4f5f7;
}

.multi-select-item input[type="checkbox"] {
  accent-color: #5FBE91;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.price-range {
  display: flex;
  align-items: center;
  gap: 6px;
}

.price-range input {
  width: 50%;
}

.price-range span {
  color: #999;
}

.filter-actions {
  margin-top: 12px;
  text-align: right;
}

.btn-clear {
  padding: 8px 20px;
  border: 1px solid #ddd;
  background: white;
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Noto Sans TC', Arial, sans-serif;
  cursor: pointer;
  color: #3C4650;
  transition: all 0.2s;
}

.btn-clear:hover {
  background: #f5f5f5;
  border-color: #ccc;
}

/* Sort */
.sort-bar {
  max-width: 1200px;
  margin: 8px auto;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.sort-label {
  font-size: 13px;
  color: #7a8490;
  white-space: nowrap;
}

.sort-btn {
  padding: 6px 14px;
  border: 1px solid #ddd;
  background: white;
  border-radius: 20px;
  font-size: 13px;
  font-family: 'Noto Sans TC', Arial, sans-serif;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  color: #3C4650;
}

.sort-btn.active {
  background: #5FBE91;
  color: white;
  border-color: #5FBE91;
}

.sort-btn:hover:not(.active) {
  background: #f0f0f0;
}

/* Room List — 條列式 */
.room-list {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Loading */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: #7a8490;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e0e0e0;
  border-top-color: #5FBE91;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 12px;
}

.no-results {
  text-align: center;
  padding: 60px 20px;
  color: #7a8490;
  font-size: 15px;
}

/* Room Row — 條列式 */
.room-row {
  background: white;
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 3px rgba(60,70,80,0.06);
}

.room-row:hover {
  background: #f8faf9;
  box-shadow: 0 2px 8px rgba(60,70,80,0.1);
}

.room-row:active {
  background: #f0f4f2;
}

/* 每行共用 */
.row-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

/* 第一行：標題 + 租金 */
.row-line1 {
  margin-bottom: 4px;
}

.row-title {
  font-size: 14px;
  font-weight: 600;
  color: #3C4650;
  line-height: 1.3;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-price {
  font-size: 16px;
  font-weight: 700;
  color: #5FBE91;
  white-space: nowrap;
}

.row-price small {
  font-size: 11px;
  font-weight: 400;
  color: #7a8490;
}

/* 第二行：地址 + 標籤 */
.row-line2 {
  margin-bottom: 4px;
}

.row-address {
  font-size: 12px;
  color: #7a8490;
  flex-shrink: 0;
}

.row-tags {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
}

.tag {
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.tag-type {
  background: rgba(45,143,210,0.1);
  color: #2D8FD2;
}

.tag-layout {
  background: rgba(95,190,145,0.1);
  color: #4a9e74;
}

.tag-size {
  background: rgba(60,70,80,0.06);
  color: #3C4650;
}

/* 第三行：空房日期 + 負責夥伴 */
.row-line3 {
  font-size: 12px;
  color: #7a8490;
}

.row-date {
  display: flex;
  align-items: center;
  gap: 4px;
}

.row-partner {
  color: #5FBE91;
  font-weight: 500;
}

.vacancy-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5FBE91;
  display: inline-block;
}

.vacancy-dot.soon {
  background: #FFE450;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(60,70,80,0.5);
  z-index: 200;
  justify-content: center;
  align-items: flex-end;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: white;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  border-radius: 16px 16px 0 0;
  overflow: hidden;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #f0f0f0;
  position: sticky;
  top: 0;
  background: white;
}

.modal-header h2 {
  font-size: 17px;
  font-weight: 700;
  color: #3C4650;
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  color: #7a8490;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(90vh - 60px);
}

.detail-section {
  margin-bottom: 20px;
}

.detail-section h3 {
  font-size: 14px;
  color: #5FBE91;
  font-weight: 600;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 2px solid #5FBE91;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.detail-item {
  font-size: 14px;
}

.detail-item .label {
  color: #7a8490;
  font-size: 12px;
}

.detail-item .value {
  color: #3C4650;
  font-weight: 500;
}

.detail-note {
  background: rgba(255,228,80,0.15);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: #3C4650;
  line-height: 1.5;
  margin-top: 4px;
  border-left: 3px solid #FFE450;
}

.detail-links {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.detail-links a {
  flex: 1;
  text-align: center;
  padding: 10px;
  background: #5FBE91;
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  font-family: 'Noto Sans TC', Arial, sans-serif;
  transition: background 0.2s;
}

.detail-links a:hover {
  background: #4ea87d;
}

.detail-links a.secondary {
  background: white;
  color: #5FBE91;
  border: 1px solid #5FBE91;
}

.detail-links a.secondary:hover {
  background: rgba(95,190,145,0.08);
}

/* Responsive */
@media (max-width: 600px) {
  .filter-grid {
    grid-template-columns: 1fr 1fr;
  }

  .modal {
    max-width: 100%;
  }

  header h1 {
    font-size: 18px;
  }

  .row-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}

@media (min-width: 1024px) {
  .modal {
    border-radius: 16px;
    align-self: center;
  }

  .modal-overlay.open {
    align-items: center;
  }
}
