/* ================================
   灵鹿漫语 - 移动端样式
   移动优先设计
   ================================ */

/* ========== 基础布局 ========== */
.container {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ========== 顶部导航栏 ========== */
.header {
  height: 56px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-light);
  position: relative;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-title {
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ========== 主内容区 ========== */
.main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  background: var(--bg-primary);
}

/* ========== 底部输入区 ========== */
.input-area {
  padding: 12px 16px 16px;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-light);
}

.input-container {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: 24px;
  padding: 4px 4px 4px 12px;
  transition: all 0.2s ease;
  max-width: 800px;
  margin: 0 auto;
}

.input-container:focus-within {
  border-color: var(--border-medium);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

/* 输入框包装器 */
.message-input-wrapper {
  flex: 1;
  min-width: 0;
  position: relative;
}

.message-input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: var(--font-md);
  color: var(--text-primary);
  resize: none;
  max-height: 120px;
  min-height: 24px;
  line-height: 24px;
  padding: 6px 0;
  vertical-align: middle;
}

.message-input::placeholder {
  color: var(--text-tertiary);
}

/* 发送按钮 */
.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--text-primary);
  color: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  outline: none;
  border: none;
  -webkit-tap-highlight-color: transparent;
}

.send-btn:focus {
  outline: none;
}

.send-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.send-btn:hover:not(:disabled) {
  transform: scale(1.05);
}

.send-btn:disabled {
  cursor: not-allowed;
  background: #e5e7eb;
  color: #d1d5db;
  opacity: 1;
}

/* ========== 侧边栏 ========== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 80%;
  max-width: 320px;
  height: 100vh;
  background: var(--bg-primary);
  box-shadow: var(--shadow-lg);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  z-index: 200;
  display: flex;
  flex-direction: column;
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  height: 56px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-light);
}

/* 侧边栏遮罩 */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ========== 表单样式 ========== */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  font-size: var(--font-sm);
  color: var(--text-secondary);
  font-weight: 500;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: var(--font-md);
  outline: none;
}

.form-input:focus {
  border-color: var(--border-medium);
  box-shadow: 0 0 0 1px var(--border-medium);
}

.form-error {
  margin-top: 6px;
  font-size: var(--font-xs);
  color: #dc2626;
}

/* ========== 列表样式 ========== */
.list-item {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.list-item:hover {
  background: var(--hover-bg);
}

.list-item:active {
  background: var(--active-bg);
}

/* ========== 空状态 ========== */
.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-tertiary);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state-text {
  font-size: var(--font-sm);
}

/* ========== 加载状态 ========== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-light);
  border-top-color: var(--text-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ========== 模态框 ========== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 20px;
}

.modal {
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  max-width: 400px;
  width: 100%;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}

.modal-title {
  font-size: var(--font-lg);
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.modal-content {
  margin-bottom: 20px;
  color: var(--text-secondary);
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ========== Toast 提示 ========== */
.toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: var(--bg-primary);
  padding: 12px 20px;
  border-radius: var(--radius-full);
  font-size: var(--font-sm);
  z-index: 400;
  animation: fadeIn 0.2s ease;
}

.toast.error {
  background: #dc2626;
}

.toast.success {
  background: #16a34a;
}

/* ========== 触摸优化 ========== */
@media (hover: none) {
  .btn:hover,
  .icon-btn:hover,
  .list-item:hover {
    background: initial;
  }

  .btn:active {
    opacity: 0.7;
  }

  .icon-btn:active {
    background: var(--active-bg);
  }
}

/* ========== 安全区域适配（刘海屏）========== */
@supports (padding-top: env(safe-area-inset-top)) {
  .header {
    padding-top: env(safe-area-inset-top);
    height: calc(56px + env(safe-area-inset-top));
  }

  .input-area {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}
