:root {
  /* 色彩系統 - 深藍與金色主題 */
  --primary: #1a4d7a;
  --primary-dark: #0f3555;
  --primary-light: #2d6aa3;
  --accent: #f39c12;
  --accent-dark: #d68910;
  --bg-main: #f8f9fc;
  --bg-card: #ffffff;
  --text-primary: #1a2332;
  --text-secondary: #5a6c7d;
  --border: #e1e8ed;
  --success: #27ae60;
  --warning: #e67e22;
  --danger: #e74c3c;
  
  /* 陰影系統 */
  --shadow-sm: 0 2px 8px rgba(26, 77, 122, 0.08);
  --shadow-md: 0 4px 16px rgba(26, 77, 122, 0.12);
  --shadow-lg: 0 8px 32px rgba(26, 77, 122, 0.16);
  
  /* 圓角 */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  
  /* 間距 */
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 20px;
  --space-lg: 32px;
  --space-xl: 48px;
}

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

body {
  font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  padding: var(--space-lg) var(--space-md);
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

h1 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-xs);
  background: linear-gradient(to right, #ffffff, #ffd89b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  font-size: 0.95rem;
  opacity: 0.9;
  font-weight: 400;
}

.btn-settings {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  white-space: nowrap;
}

.btn-settings:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

/* Container - 改為左右佈局 */
.main-layout {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  min-height: calc(100vh - 180px);
  gap: 0;
}

/* Sidebar */
.sidebar {
  width: 240px;
  background: white;
  padding: var(--space-md);
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 120px;
  height: fit-content;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
}

/* Content Wrapper */
.content-wrapper {
  flex: 1;
  padding: var(--space-lg) var(--space-md);
  overflow-x: hidden;
}

/* Feature Navigation - 改為垂直排列 */
.feature-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.nav-item {
  background: transparent;
  border: none;
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-align: left;
  width: 100%;
  border-left: 3px solid transparent;
}

.nav-item .icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

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

.nav-item:hover {
  background: var(--bg-main);
  color: var(--primary);
  border-left-color: var(--accent);
}

.nav-item.active {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  box-shadow: var(--shadow-sm);
  border-left-color: var(--accent);
}

.nav-item.active:hover {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
}

/* Tab Content */
.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-content.active {
  display: block;
}

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

/* Feature Card */
.feature-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

.card-header {
  background: linear-gradient(135deg, #f8f9fc 0%, #e8eef5 100%);
  padding: var(--space-lg);
  border-bottom: 2px solid var(--accent);
}

.card-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: var(--space-sm);
}

.card-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.card-body {
  padding: var(--space-lg);
}

/* Form Elements */
.form-group {
  margin-bottom: var(--space-md);
}

label {
  display: block;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
  font-size: 0.9rem;
}

.input-field,
.textarea-field,
.select-field {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  transition: all 0.3s ease;
  background: white;
}

.input-field:focus,
.textarea-field:focus,
.select-field:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 77, 122, 0.1);
}

.textarea-field {
  resize: vertical;
  min-height: 100px;
}

/* Checkbox Group */
.checkbox-group {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-md);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  cursor: pointer;
  font-weight: 400;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  border: none;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
  position: relative;
  width: 100%;
  margin-top: var(--space-sm);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.loading-spinner {
  display: none;
}

.btn-primary.loading .btn-text {
  display: none;
}

.btn-primary.loading .loading-spinner {
  display: inline;
}

/* Result Area */
.result-area {
  margin-top: var(--space-lg);
  padding: var(--space-lg);
  background: var(--bg-main);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--accent);
  display: none;
}

.result-area.show {
  display: block;
  animation: slideUp 0.4s ease;
}

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

.result-area h3 {
  color: var(--primary);
  margin-bottom: var(--space-md);
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.result-area ul {
  list-style: none;
  padding: 0;
}

.result-area li {
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border);
}

.result-area li:last-child {
  border-bottom: none;
}

.keyword-item {
  background: white;
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-sm);
  box-shadow: var(--shadow-sm);
}

.keyword-item h4 {
  color: var(--primary);
  margin-bottom: var(--space-xs);
  font-size: 1.1rem;
}

.keyword-meta {
  display: flex;
  gap: var(--space-md);
  font-size: 0.85rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-low {
  background: #d4edda;
  color: #155724;
}

.badge-medium {
  background: #fff3cd;
  color: #856404;
}

.badge-high {
  background: #f8d7da;
  color: #721c24;
}

.content-section {
  background: white;
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-md);
  border-left: 3px solid var(--primary);
}

.content-section h4 {
  color: var(--primary);
  margin-bottom: var(--space-sm);
}

.content-section ol,
.content-section ul {
  margin-left: var(--space-md);
}

.content-section li {
  margin-bottom: var(--space-xs);
  border: none;
}

.platform-content {
  background: white;
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-sm);
}

.platform-content h4 {
  color: var(--primary);
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.platform-content p {
  color: var(--text-primary);
  line-height: 1.8;
  padding: var(--space-sm);
  background: var(--bg-main);
  border-radius: var(--radius-sm);
}

.health-score {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.score-card {
  background: white;
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.score-value {
  font-size: 2.5rem;
  font-weight: 900;
  font-family: 'Playfair Display', serif;
  margin: var(--space-sm) 0;
}

.score-label {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.suggestions-list {
  background: white;
  padding: var(--space-md);
  border-radius: var(--radius-sm);
}

.suggestions-list h4 {
  color: var(--primary);
  margin-bottom: var(--space-md);
}

.suggestion-item {
  padding: var(--space-md);
  background: var(--bg-main);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-sm);
  border-left: 3px solid var(--accent);
}

.suggestion-item strong {
  color: var(--primary);
  display: block;
  margin-bottom: var(--space-xs);
}

/* Modal */
.modal {
  display: flex;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

.modal-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  padding: var(--space-lg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-header h2 {
  font-size: 1.5rem;
  margin-bottom: var(--space-xs);
}

.modal-subtitle {
  opacity: 0.9;
  font-size: 0.9rem;
}

.modal-body {
  padding: var(--space-lg);
}

.api-key-input {
  width: 100%;
  padding: var(--space-md);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  margin-bottom: var(--space-md);
  font-family: monospace;
}

.hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
  line-height: 1.5;
}

.hint a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.hint a:hover {
  text-decoration: underline;
}

.security-note {
  background: #e8f5e9;
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--success);
}

/* Footer */
footer {
  background: var(--primary-dark);
  color: rgba(255, 255, 255, 0.8);
  text-align: center;
  padding: var(--space-md);
  font-size: 0.85rem;
}

/* Error Message */
.error-message {
  background: #fee;
  border-left: 4px solid var(--danger);
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  color: var(--danger);
  margin-top: var(--space-md);
}

/* Responsive */
@media (max-width: 968px) {
  .main-layout {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    position: relative;
    top: 0;
    max-height: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  }
  
  .feature-nav {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-xs);
  }
  
  .content-wrapper {
    padding: var(--space-md);
  }
}

@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    text-align: center;
  }
  
  .feature-nav {
    grid-template-columns: 1fr;
  }
  
  .nav-item {
    justify-content: center;
  }
  
  .keyword-meta {
    flex-direction: column;
    gap: var(--space-xs);
  }
  
  .health-score {
    grid-template-columns: 1fr;
  }
  
  .checkbox-group {
    grid-template-columns: 1fr;
  }
}

/* Copy Button for Results */
.copy-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  margin-top: var(--space-sm);
  transition: all 0.3s ease;
}

.copy-btn:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.copy-btn:active {
  transform: translateY(0);
}
