/* 社群動態 - Facebook 風格 */
:root {
  --primary: #1877f2;
  --primary-dark: #166fe5;
  --primary-hover: #42a1ec;
  --bg: #f0f2f5;
  --card-bg: #fff;
  --text: #050505;
  --text-secondary: #65676b;
  --border: #dddfe2;
  --success: #31a24c;
  --danger: #e41e3a;
  --shadow: 0 1px 2px rgba(0,0,0,0.1);
  --shadow-lg: 0 2px 12px rgba(0,0,0,0.15);
}

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

body {
  font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
  background: radial-gradient(circle at top, #e3f2fd 0, #f0f2f5 40%, #e4e6eb 100%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* 畫面切換 */
.screen {
  min-height: 100vh;
}
.screen.hidden {
  display: none !important;
}

/* 登入/註冊 */
#authScreen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1877f2 0%, #0d47a1 100%);
  padding: 20px;
}

.auth-container {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}
.auth-header h1 {
  font-size: 1.75rem;
  color: var(--primary);
  margin-bottom: 4px;
}
.auth-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.auth-tabs .tab {
  flex: 1;
  padding: 12px;
  border: none;
  background: none;
  font-size: 1rem;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}
.auth-tabs .tab:hover {
  color: var(--primary);
}
.auth-tabs .tab.active {
  color: var(--primary);
  font-weight: 600;
  border-bottom-color: var(--primary);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.auth-form.hidden {
  display: none !important;
}
.auth-form input {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s;
}
.auth-form input:focus {
  outline: none;
  border-color: var(--primary);
}
.auth-form button {
  padding: 12px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.auth-form button:hover {
  background: var(--primary-dark);
}

.auth-error {
  color: var(--danger);
  font-size: 0.9rem;
  margin-top: 12px;
  min-height: 20px;
}

/* 主畫面 */
.header {
  background: rgba(24, 119, 242, 0.96);
  color: white;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: white;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.4rem;
  box-shadow: var(--shadow);
}
.logo {
  font-size: 1.4rem;
  font-weight: 700;
}
.search-box {
  margin-left: 12px;
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.15);
  padding: 6px 10px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.2);
  max-width: 260px;
}
.search-box input {
  border: none;
  background: transparent;
  color: white;
  font-size: 0.9rem;
  outline: none;
  width: 100%;
}
.search-box ::placeholder {
  color: rgba(255,255,255,0.8);
}
.search-icon {
  margin-right: 6px;
  font-size: 0.9rem;
}
.header-center {
  display: flex;
  gap: 8px;
}
.nav-icon {
  width: 42px;
  height: 38px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: white;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
}
.nav-icon:hover {
  background: rgba(255,255,255,0.15);
}
.nav-icon.active {
  background: rgba(255,255,255,0.25);
}
.header-user {
  display: flex;
  align-items: center;
  gap: 16px;
}
.header-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f093fb, #f5576c);
}
.header-username {
  font-size: 0.95rem;
  font-weight: 600;
}
.circle-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.1);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
.circle-icon:hover {
  background: rgba(0,0,0,0.2);
}
.btn-outline {
  padding: 8px 16px;
  background: transparent;
  color: white;
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}
.btn-outline:hover {
  background: rgba(255,255,255,0.2);
}

/* 主內容區 */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 32px;
  display: grid;
  grid-template-columns: 240px 1fr 300px;
  gap: 24px;
}

@media (max-width: 900px) {
  .main {
    grid-template-columns: 1fr;
  }
  .right-sidebar {
    display: none;
  }
}

/* 側邊欄 */
.sidebar {
  position: sticky;
  top: 80px;
  height: fit-content;
}
.sidebar-card {
  background: rgba(255,255,255,0.9);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.profile-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4facfe, #00f2fe);
}
.profile-info {
  flex: 1;
}
.profile-name {
  font-weight: 600;
}
.profile-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.sidebar-section {
  background: rgba(255,255,255,0.9);
  border-radius: 12px;
  padding: 8px 6px;
  box-shadow: var(--shadow);
}
.sidebar-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 4px 10px 6px;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 4px;
}
.sidebar-item:hover {
  background: rgba(0,0,0,0.03);
}
.sidebar-item.active {
  background: rgba(24, 119, 242, 0.1);
  color: var(--primary);
  font-weight: 600;
}
.sidebar-item .icon {
  font-size: 1.25rem;
}

/* 限時動態 */
.stories {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.story-card {
  min-width: 110px;
  max-width: 110px;
  height: 190px;
  border-radius: 14px;
  background: var(--card-bg);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
}
.story-bg {
  width: 100%;
  height: 70%;
  background: linear-gradient(135deg, #667eea, #764ba2);
}
.story-card .demo-1 {
  background: linear-gradient(135deg, #43e97b, #38f9d7);
}
.story-card .demo-2 {
  background: linear-gradient(135deg, #fa709a, #fee140);
}
.story-card .demo-3 {
  background: linear-gradient(135deg, #30cfd0, #330867);
}
.create-story .story-bg {
  background: linear-gradient(135deg, rgba(24,119,242,.85), rgba(66,161,236,.95));
}
.story-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 10px;
  background: white;
  text-align: center;
}
.story-add {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: -22px auto 4px;
  border: 3px solid white;
}
.story-text {
  font-size: 0.8rem;
  font-weight: 600;
}
.story-user {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
  text-shadow: 0 0 4px rgba(0,0,0,0.6);
}

/* 發文區 */
.create-post {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.create-post-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #42a1ec);
  flex-shrink: 0;
}
.create-post-input-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.create-post-input-wrap input {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 24px;
  font-size: 1rem;
  background: var(--bg);
}
.create-post-input-wrap input:focus {
  outline: none;
  border-color: var(--primary);
}
.btn-primary {
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-end;
  transition: background 0.2s;
}
.btn-primary:hover {
  background: var(--primary-dark);
}
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* 動態牆 */
.feed {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.post-card {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.post-card:hover {
  box-shadow: var(--shadow-lg);
}

.post-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
}
.post-author {
  display: flex;
  align-items: center;
  gap: 12px;
}
.post-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  flex-shrink: 0;
}
.post-author-info {
  display: flex;
  flex-direction: column;
}
.post-author-name {
  font-weight: 600;
  color: var(--text);
}
.post-time {
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.post-delete {
  padding: 4px 8px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.2rem;
  border-radius: 4px;
  opacity: 0.6;
}
.post-delete:hover {
  background: var(--bg);
  color: var(--danger);
  opacity: 1;
}

.post-content {
  padding: 0 16px 16px;
  white-space: pre-wrap;
  word-break: break-word;
}
.post-image {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
}

.post-actions {
  display: flex;
  border-top: 1px solid var(--border);
}
.post-action {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}
.post-action:hover {
  background: var(--bg);
  color: var(--primary);
}
.post-action.liked {
  color: var(--primary);
  font-weight: 600;
}

/* 右側欄 */
.right-sidebar {
  position: sticky;
  top: 80px;
  height: fit-content;
}
.widget {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.widget h3 {
  font-size: 1.1rem;
  margin-bottom: 12px;
  color: var(--text);
}
.widget p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.loading-more {
  text-align: center;
  padding: 20px;
  color: var(--text-secondary);
}
.loading-more.hidden {
  display: none;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.hidden {
  display: none !important;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}
.modal-content {
  position: relative;
  background: var(--card-bg);
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  font-size: 1.25rem;
}
.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg);
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.2s;
}
.modal-close:hover {
  background: var(--border);
}

.comments-list {
  flex: 1;
  overflow-y: auto;
  max-height: 300px;
  padding: 16px;
}
.comment-item {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}
.comment-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  flex-shrink: 0;
}
.comment-body {
  flex: 1;
}
.comment-author {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 2px;
}
.comment-content {
  font-size: 0.95rem;
  color: var(--text);
}
.comment-time {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.comment-input-wrap {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--border);
}
.comment-input-wrap input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 24px;
  font-size: 1rem;
}
.comment-input-wrap input:focus {
  outline: none;
  border-color: var(--primary);
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}
.empty-state p {
  margin-bottom: 8px;
}
