* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f5;
  margin: 0;
  padding: 0;
}

/* Login section */
.login-section {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-box {
  background: white;
  padding: 32px;
  border-radius: 8px;
  min-width: 360px;
  max-width: 400px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.login-box h1 {
  margin-bottom: 4px;
}

.login-subtitle {
  color: #888;
  margin-bottom: 20px;
}

.login-error {
  color: #d32f2f;
  font-size: 14px;
  min-height: 20px;
  margin-bottom: 8px;
}

.login-box form input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid #ddd;
  border-radius: 6px;
  margin-bottom: 12px;
}

.login-box form input:focus {
  outline: none;
  border-color: #8e44ad;
}

.login-box form button[type="submit"] {
  width: 100%;
  margin-top: 4px;
}

.auth-switch {
  font-size: 14px;
  color: #888;
  margin-top: 16px;
}

.auth-switch a {
  color: #8e44ad;
  text-decoration: none;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.confirm-message {
  color: #666;
  margin-bottom: 12px;
}

/* App header with logout */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px 0 0;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 4px;
}

.user-bar span {
  font-size: 14px;
  color: #666;
}

.logout-btn {
  background: #666;
  padding: 6px 14px;
  font-size: 13px;
}

.logout-btn:hover {
  background: #555;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px 20px;
}

h1 {
  color: #333;
  margin-bottom: 2px;
  font-size: 28px;
}

.subtitle {
  color: #888;
  margin-top: 0;
  font-size: 14px;
}

.step-hint {
  color: #888;
  font-size: 13px;
  margin: 0 0 12px 0;
}

.tag-select-grid {
  margin-bottom: 16px;
}

.tag-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f8f8f8;
  border: 1px solid #eee;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 13px;
}

.tag-card:hover {
  background: #f0f0f0;
  border-color: #ccc;
}

.tag-card.selected {
  background: #f5eef8;
  border-color: #8e44ad;
}

.tag-card input[type="checkbox"] {
  margin: 0;
  accent-color: #8e44ad;
}

.tag-card .tag-city-match {
  color: #888;
  font-size: 11px;
  margin-left: auto;
}

/* Steps */
.step {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.step.hidden {
  display: none;
}

.step h2 {
  color: #333;
  margin-top: 0;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: #8e44ad;
  color: white;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

/* URL Inputs */
.url-inputs {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.input-group {
  flex: 1;
}

.input-group label {
  display: block;
  font-weight: 600;
  color: #555;
  margin-bottom: 6px;
  font-size: 13px;
}

.input-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

.input-group input:focus {
  outline: none;
  border-color: #8e44ad;
}

/* Weather Offices */
.weather-offices {
  margin-top: 20px;
}

.weather-offices-label {
  font-weight: 600;
  color: #555;
  font-size: 13px;
  margin-bottom: 10px;
}

.weather-office-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #f8f8f8;
  border: 1px solid #eee;
  border-radius: 6px;
  margin-bottom: 8px;
}

.weather-office-info {
  min-width: 120px;
}

.weather-office-name {
  font-weight: 600;
  font-size: 14px;
  color: #333;
}

.weather-office-cities {
  font-size: 11px;
  color: #888;
  margin-top: 2px;
}

.weather-office-link a {
  font-size: 12px;
  color: #8e44ad;
  text-decoration: none;
}

.weather-office-link a:hover {
  text-decoration: underline;
}

.weather-drop-zone {
  padding: 8px 16px;
  border: 2px dashed #ccc;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: #888;
  transition: all 0.2s;
  text-align: center;
  min-width: 160px;
  white-space: nowrap;
}

.weather-drop-zone:hover {
  border-color: #8e44ad;
  color: #8e44ad;
}

.weather-drop-zone.dragover {
  border-color: #8e44ad;
  background: #f5eef8;
}

.weather-drop-zone.has-file {
  border-color: #4caf50;
  border-style: solid;
  color: #2e7d32;
}

.or-label {
  color: #999;
  font-size: 12px;
}

.weather-url-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
}

.weather-url-input:focus {
  outline: none;
  border-color: #8e44ad;
}

.weather-preview {
  margin-left: 8px;
}

.weather-preview img {
  max-width: 100px;
  max-height: 60px;
  border-radius: 4px;
  border: 1px solid #ddd;
}

/* Buttons */
.primary-btn {
  display: block;
  width: 100%;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 600;
  background: #8e44ad;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.primary-btn:hover:not(:disabled) {
  background: #7d3c98;
}

.primary-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.send-btn {
  background: #4caf50;
  margin-top: 16px;
}

.send-btn:hover:not(:disabled) {
  background: #43a047;
}

.small-btn {
  padding: 4px 12px;
  font-size: 12px;
  background: #666;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.small-btn:hover {
  background: #555;
}

/* Status messages */
.status-msg {
  margin-top: 10px;
  font-size: 13px;
  color: #888;
  text-align: center;
  min-height: 20px;
}

.status-msg.error {
  color: #d32f2f;
}

/* Bullet review */
.bullet-sections {
  display: flex;
  gap: 20px;
  margin-bottom: 16px;
}

.bullet-group {
  flex: 1;
}

.bullet-group h3 {
  color: #555;
  margin: 0 0 10px 0;
  font-size: 15px;
}

.bullet-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bullet-item {
  display: flex;
  gap: 6px;
  align-items: flex-start;
}

.bullet-item textarea {
  flex: 1;
  min-height: 60px;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  line-height: 1.4;
}

.bullet-item textarea:focus {
  outline: none;
  border-color: #8e44ad;
}

.bullet-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bullet-btn {
  padding: 4px 8px;
  font-size: 11px;
  background: #eee;
  color: #555;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.bullet-btn:hover {
  background: #ddd;
}

.bullet-btn.loading {
  opacity: 0.5;
  pointer-events: none;
}

/* City Selection */
.config-row {
  display: flex;
  gap: 20px;
  margin-bottom: 16px;
}

.config-group {
  flex: 1;
}

.config-group label {
  display: block;
  font-weight: 600;
  color: #555;
  margin-bottom: 6px;
  font-size: 13px;
}

.tag-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-option {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: #f0f0f0;
  border-radius: 16px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s;
}

.tag-option:hover {
  background: #e0e0e0;
}

.tag-option input[type="checkbox"] {
  margin: 0;
}

.tag-option input[type="checkbox"]:checked + span {
  color: #8e44ad;
  font-weight: 600;
}

#templateSelect {
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

#templateSelect:focus {
  outline: none;
  border-color: #8e44ad;
}

.city-select {
  margin-bottom: 16px;
}

.city-select-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.city-select-header label {
  font-weight: 600;
  color: #555;
  font-size: 13px;
}

.city-select-actions {
  display: flex;
  gap: 6px;
}

.city-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px;
}

.city-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f8f8f8;
  border: 1px solid #eee;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 13px;
}

.city-card:hover {
  background: #f0f0f0;
  border-color: #ccc;
}

.city-card.selected {
  background: #f5eef8;
  border-color: #8e44ad;
}

.city-card input[type="checkbox"] {
  margin: 0;
  accent-color: #8e44ad;
}

.hcj-option {
  margin-bottom: 16px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: #555;
}

.checkbox-label input {
  accent-color: #8e44ad;
}

/* Preview */
.preview-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.preview-card {
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #f8f8f8;
  border-bottom: 1px solid #eee;
  cursor: pointer;
}

.preview-header h3 {
  margin: 0;
  font-size: 15px;
  color: #333;
}

.preview-meta {
  font-size: 12px;
  color: #888;
}

.preview-status {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 600;
}

.preview-status.pending {
  background: #f0f0f0;
  color: #888;
}

.preview-status.sending {
  background: #fff3e0;
  color: #e65100;
}

.preview-status.sent {
  background: #e8f5e9;
  color: #2e7d32;
}

.preview-status.error {
  background: #ffebee;
  color: #c62828;
}

.preview-body {
  padding: 16px;
  display: none;
}

.preview-body.open {
  display: block;
}

.feature-image-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  padding: 8px 0;
}

.feature-image-thumb {
  width: 80px;
  height: 50px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #ddd;
}

.feature-image-controls {
  flex: 1;
}

.feature-image-label {
  font-size: 12px;
  font-weight: 600;
  color: #555;
  margin-bottom: 4px;
  display: block;
}

.feature-image-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.feature-image-actions .weather-url-input {
  flex: 1;
}

.preview-body textarea {
  width: 100%;
  min-height: 300px;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 12px;
  resize: vertical;
  line-height: 1.5;
}

.preview-body textarea:focus {
  outline: none;
  border-color: #8e44ad;
}

.preview-info {
  display: flex;
  gap: 16px;
  margin-bottom: 10px;
  font-size: 12px;
  color: #888;
}

.preview-info span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Send status */
.send-status {
  margin-top: 12px;
  text-align: center;
  font-size: 13px;
  color: #888;
}

/* Day in History */
.day-in-history-section {
  margin-top: 20px;
}

.dih-label {
  font-weight: 600;
  color: #555;
  font-size: 13px;
  margin-bottom: 10px;
}

.dih-generate-btn {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  background: #8e44ad;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 12px;
}

.dih-generate-btn:hover:not(:disabled) {
  background: #7d3c98;
}

.dih-generate-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.dih-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dih-fields input,
.dih-fields textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}

.dih-fields textarea {
  min-height: 80px;
  resize: vertical;
  line-height: 1.4;
}

.dih-fields input:focus,
.dih-fields textarea:focus {
  outline: none;
  border-color: #8e44ad;
}

.dih-fields label {
  font-size: 12px;
  font-weight: 600;
  color: #555;
}

.dih-image-preview img {
  max-width: 200px;
  max-height: 120px;
  border-radius: 4px;
  border: 1px solid #ddd;
  margin-top: 4px;
}

/* Responsive */
@media (max-width: 600px) {
  .url-inputs {
    flex-direction: column;
  }

  .bullet-sections {
    flex-direction: column;
  }

  .config-row {
    flex-direction: column;
  }

  .city-grid {
    grid-template-columns: 1fr 1fr;
  }
}
