/* ============================================
   飞书多维表格管理后台 - 样式
   ============================================ */

:root {
  --primary: #3370ff;
  --primary-hover: #2860e8;
  --secondary: #6b7280;
  --secondary-hover: #4b5563;
  --danger: #ef4444;
  --bg: #f3f4f6;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-muted: #6b7280;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --radius: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* Header */
header {
  background: linear-gradient(135deg, #3370ff, #1a4bbd);
  color: white;
  padding: 32px 24px;
  text-align: center;
}

header h1 {
  font-size: 1.8rem;
  margin-bottom: 4px;
}

.subtitle {
  opacity: 0.85;
  font-size: 0.95rem;
}

/* Main Layout */
main {
  max-width: 1000px;
  margin: 24px auto;
  padding: 0 16px;
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

.card h2 {
  font-size: 1.1rem;
  margin-bottom: 16px;
  color: var(--text);
}

/* Config Section */
.config-section {
  display: flex;
  flex-direction: column;
}

.config-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.config-row label {
  font-weight: 600;
  white-space: nowrap;
}

.config-row input {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}

.hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn.primary {
  background: var(--primary);
  color: white;
}

.btn.primary:hover {
  background: var(--primary-hover);
}

.btn.secondary {
  background: #e5e7eb;
  color: var(--text);
}

.btn.secondary:hover {
  background: #d1d5db;
}

.btn.danger {
  background: var(--danger);
  color: white;
}

.btn.danger:hover {
  background: #dc2626;
}

.btn.small {
  padding: 4px 10px;
  font-size: 0.8rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Action Bar */
.action-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

/* Table */
.table-section {
  overflow-x: auto;
}

#recordsTable {
  width: 100%;
  border-collapse: collapse;
}

#recordsTable th {
  background: #f9fafb;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}

#recordsTable td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  vertical-align: top;
}

#recordsTable tr:hover {
  background: #f9fafb;
}

.empty-hint {
  text-align: center;
  color: var(--text-muted);
  padding: 40px !important;
}

.fields-cell {
  max-width: 400px;
}

.fields-cell .field-item {
  display: inline-block;
  margin: 2px 4px 2px 0;
  padding: 2px 8px;
  background: #f3f4f6;
  border-radius: 4px;
  font-size: 0.82rem;
}

.actions-cell {
  white-space: nowrap;
  display: flex;
  gap: 4px;
}

/* Pagination */
#pagination {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

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

.modal-overlay.hidden {
  display: none;
}

.modal-content {
  width: 90%;
  max-width: 500px;
  position: relative;
}

.modal-close {
  position: absolute;
  right: 16px;
  top: 12px;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-close:hover {
  color: var(--text);
}

/* Form Fields */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}

.form-group textarea {
  min-height: 60px;
  resize: vertical;
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* Loading & Error States */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

.error-message {
  background: #fef2f2;
  color: var(--danger);
  padding: 12px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.success-message {
  background: #f0fdf4;
  color: #16a34a;
  padding: 12px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 600px) {
  header h1 { font-size: 1.3rem; }
  .config-row { flex-direction: column; align-items: stretch; }
  .config-row input { min-width: auto; }
}
