/**
 * 100x Life Planning System - Component Styles
 * Buttons, cards, modals, forms, and reusable UI components
 */

/* ===== GLOW PULSE EFFECT ===== */
.glow-pulse {
  animation: glowPulse 2s ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% {
    box-shadow: 0 0 5px rgba(74, 155, 181, 0.3),
                0 0 10px rgba(74, 155, 181, 0.2),
                0 0 15px rgba(74, 155, 181, 0.1);
  }
  50% {
    box-shadow: 0 0 10px rgba(74, 155, 181, 0.5),
                0 0 20px rgba(74, 155, 181, 0.3),
                0 0 30px rgba(74, 155, 181, 0.2);
  }
}

/* ===== BUTTONS ===== */
.btn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 500;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-medium);
}

.btn-ghost:hover {
  color: var(--navy-primary);
  border-color: var(--navy-primary);
  background: var(--bg-tertiary);
}

.btn-primary {
  background: var(--navy-primary);
  color: var(--text-light);
}

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

.btn-gold,
.btn-accent {
  background: var(--teal-accent);
  color: var(--text-light);
}

.btn-gold:hover,
.btn-accent:hover {
  background: var(--navy-medium);
  color: var(--text-light);
}

.btn i {
  color: inherit;
}

/* Responsive button text - show long by default, short on mobile */
.btn-text-long {
  display: inline;
}

.btn-text-short {
  display: none;
}

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

.btn-icon {
  background: transparent;
  color: var(--text-secondary);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--bg-tertiary);
  color: var(--navy-primary);
}

.btn-icon i {
  font-size: 1.1rem;
  transition: transform var(--transition-fast);
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.card-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--navy-primary);
}

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

/* Grid Card (for foundation items) */
.grid-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 140px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}

.grid-card:hover {
  border-color: var(--teal-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.grid-card.completed {
  border-color: var(--teal-accent);
  border-left: 4px solid var(--teal-accent);
}

.grid-card.suggested {
  border-color: var(--navy-primary);
  box-shadow: 0 0 0 2px rgba(26, 43, 74, 0.1);
}

.card-status {
  font-size: 0.7rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.card-status.complete {
  background: var(--teal-light);
  color: var(--teal-accent);
}

.card-preview {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.5;
  flex: 1;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.card-empty {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.85rem;
}

/* ===== MODALS ===== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(26, 43, 74, 0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  max-width: 500px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-md);
}

.modal-header h3 {
  color: var(--navy-primary);
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

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

.modal-body textarea {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  color: var(--text-dark);
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.5;
  min-height: 120px;
  resize: vertical;
}

.modal-body textarea:focus {
  outline: none;
  border-color: var(--teal-accent);
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: var(--spacing-md);
}

/* Export Modal */
.export-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(26, 43, 74, 0.7);
  z-index: 1001;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xl);
}

.export-modal-overlay.active {
  display: flex;
}

.export-modal {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.export-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

.export-modal-header h3 {
  color: var(--navy-primary);
  font-size: 1.25rem;
  font-weight: 600;
}

.export-modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.75rem;
  cursor: pointer;
  line-height: 1;
}

.export-modal-close:hover {
  color: var(--navy-primary);
}

.export-modal-body {
  padding: var(--spacing-lg);
  overflow-y: auto;
  flex: 1;
}

/* Compact export modal (no content preview) */
.export-modal-compact {
  max-width: 480px;
}

/* Export Actions Grid */
.export-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.export-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
  background: var(--bg-secondary);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
  gap: 0.5rem;
}

.export-action-btn:hover {
  border-color: var(--teal-accent);
  background: var(--teal-light);
  transform: translateY(-2px);
}

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

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

.export-action-btn i {
  font-size: 2rem;
  color: var(--navy-primary);
}

.export-action-btn:hover i {
  color: var(--teal-accent);
}

.export-action-label {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1rem;
  color: var(--navy-primary);
}

.export-action-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Export status message */
.export-status {
  display: block;
  text-align: center;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--teal-accent);
  min-height: 1.5rem;
}

.export-status.error {
  color: #dc3545;
}

/* Sync Conflict Modal */
.sync-conflict-modal {
  max-width: 650px;
}

.sync-conflict-modal .modal-header h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #e67e22;
}

.sync-conflict-message {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  line-height: 1.5;
}

/* Conflict List */
.conflict-list {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 1.25rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
}

.conflict-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
}

.conflict-item:last-child {
  border-bottom: none;
}

.conflict-item-name {
  font-weight: 500;
  color: var(--navy-primary);
}

.conflict-item-status {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.conflict-item-status.resolved {
  color: var(--teal-accent);
}

/* Bulk Options */
.sync-bulk-options {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.sync-bulk-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.sync-bulk-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.sync-bulk-buttons .btn {
  flex: 1;
  min-width: 120px;
  justify-content: center;
}

.review-each-btn {
  width: 100%;
  justify-content: center;
}

/* Per-Field Review View */
.conflict-review-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.conflict-review-progress {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.conflict-field-name {
  color: var(--navy-primary);
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.conflict-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.conflict-version {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.conflict-version-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-tertiary);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--navy-primary);
  border-bottom: 1px solid var(--border-light);
}

.conflict-version-label i {
  color: var(--teal-accent);
}

.conflict-version-content {
  padding: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  max-height: 150px;
  overflow-y: auto;
  line-height: 1.5;
  white-space: pre-wrap;
}

.conflict-version-content:empty::before {
  content: "(empty)";
  color: var(--text-muted);
  font-style: italic;
}

.conflict-review-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.conflict-review-actions .btn {
  flex: 1;
  justify-content: center;
}

/* Status */
.sync-conflict-status {
  margin-top: 1rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--teal-accent);
  min-height: 1.5rem;
}

.sync-conflict-status.error {
  color: #dc3545;
}

/* Settings Modal */
.settings-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(26, 43, 74, 0.7);
  z-index: 1001;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xl);
}

.settings-modal-overlay.active {
  display: flex;
}

.settings-modal {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.settings-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

.settings-modal-header h3 {
  color: var(--navy-primary);
  font-size: 1.25rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.settings-modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.75rem;
  cursor: pointer;
  line-height: 1;
}

.settings-modal-close:hover {
  color: var(--navy-primary);
}

.settings-modal-body {
  padding: var(--spacing-lg);
  overflow-y: auto;
  flex: 1;
}

.settings-modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
}

.settings-section {
  margin-bottom: var(--spacing-lg);
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section-header h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--navy-primary);
  margin-bottom: var(--spacing-md);
}

/* ===== FORMS ===== */
.form-control {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  color: var(--text-dark);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--teal-accent);
}

.form-control::placeholder {
  color: var(--text-muted);
}

textarea.form-control {
  min-height: 100px;
  resize: vertical;
  line-height: 1.5;
}

/* Storage Options */
.storage-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.storage-option {
  cursor: pointer;
}

.storage-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.storage-option-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.storage-option input:checked + .storage-option-content {
  border-color: var(--teal-accent);
  background: var(--teal-light);
}

.storage-option:hover .storage-option-content {
  border-color: var(--border-medium);
}

.storage-option-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.storage-option-icon.local {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.storage-option-icon.cloud {
  background: var(--teal-light);
  color: var(--teal-accent);
}

.storage-option-title {
  font-weight: 600;
  color: var(--navy-primary);
  margin-bottom: 0.25rem;
}

.storage-option-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.storage-warning {
  display: flex;
  gap: 0.75rem;
  padding: 1rem;
  background: #fef3cd;
  border: 1px solid #ffc107;
  border-radius: var(--radius-md);
  margin-top: 1rem;
  font-size: 0.85rem;
  color: #856404;
}

/* Settings Toggle */
.settings-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.settings-toggle-label span {
  display: block;
}

.settings-toggle-label span:first-child {
  font-weight: 500;
  color: var(--navy-primary);
}

.settings-toggle-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.settings-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.settings-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.settings-switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-medium);
  transition: var(--transition-normal);
  border-radius: 26px;
}

.settings-switch-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: var(--transition-normal);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.settings-switch input:checked + .settings-switch-slider {
  background-color: var(--teal-accent);
}

.settings-switch input:checked + .settings-switch-slider:before {
  transform: translateX(22px);
}

/* Theme Segmented Control */
.theme-segmented-control {
  display: flex;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
}

.theme-segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-segmented-control label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.theme-segmented-control label:hover {
  color: var(--text-dark);
}

.theme-segmented-control input:checked + label {
  background: var(--bg-primary);
  color: var(--navy-primary);
  box-shadow: var(--shadow-sm);
}

.theme-segmented-control label i {
  font-size: 1rem;
}

/* ===== PROGRESS ===== */
.progress-bar {
  background: var(--border-light);
  border-radius: var(--radius-full);
  height: 8px;
  overflow: hidden;
}

.progress-fill {
  background: var(--teal-accent);
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

.progress-text {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

/* ===== ICONS ===== */
.icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
}

.icon-sm {
  width: 0.875em;
  height: 0.875em;
}

.icon-lg {
  width: 1.25em;
  height: 1.25em;
}

/* ===== RESPONSIVE - MOBILE ===== */
@media (max-width: 768px) {
  /* Settings Modal */
  .settings-modal {
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    margin: 0;
  }

  .settings-modal-overlay.active {
    padding: 0;
  }

  .settings-modal-header {
    padding: 1rem;
  }

  .settings-modal-body {
    padding: 1rem;
  }

  .settings-modal-footer {
    padding: 1rem;
  }

  /* Storage options - stack on mobile */
  .storage-option-content {
    padding: 0.75rem;
  }

  .storage-option-icon {
    width: 36px;
    height: 36px;
  }

  .storage-option-title {
    font-size: 0.95rem;
  }

  .storage-option-desc {
    font-size: 0.8rem;
  }

  /* User info - wrap on mobile */
  .user-info {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem;
  }

  .user-avatar {
    width: 36px;
    height: 36px;
  }

  .user-details {
    flex: 1;
    min-width: 0;
  }

  .user-name {
    font-size: 0.95rem;
  }

  .user-email {
    font-size: 0.8rem;
    word-break: break-all;
  }

  .user-info .btn {
    width: 100%;
    margin-top: 0.5rem;
    justify-content: center;
  }

  /* Theme segmented control */
  .theme-segmented-control {
    flex-direction: column;
  }

  .theme-segmented-control label {
    justify-content: flex-start;
    padding: 0.75rem 1rem;
  }

  /* Settings toggle row */
  .settings-toggle-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .settings-toggle-label {
    width: 100%;
  }

  .settings-switch {
    align-self: flex-start;
  }

  /* Export modal */
  .export-modal {
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    margin: 0;
  }

  .export-modal-overlay.active {
    padding: 0;
  }

  .export-actions-grid {
    grid-template-columns: 1fr;
  }
}
