/* CSS Custom Properties for Theme Support */
:root {
  --primary-color: #3C2415;
  --secondary-color: #6F4E37;
  --tertiary-color: #A67B5B;
  --accent-color: #C4915C;
  --light-color: #E6D5AA;
  --background-color: #FFFFFF;
  --text-color: #3C2415;
  --border-color: #E6D5AA;
  --shadow-color: rgba(60, 36, 21, 0.1);
  --error-color: #E74C3C;
  --success-color: #27AE60;
  --warning-color: #F39C12;
  --info-color: #3498DB;
}

/* Dark Theme Variables */
[data-theme="dark"] {
  --background-color: #1a1a1a;
  --text-color: #E6D5AA;
  --border-color: #6F4E37;
  --shadow-color: rgba(230, 213, 170, 0.1);
}

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--background-color);
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.header {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  padding: 1rem 0;
  box-shadow: 0 2px 10px var(--shadow-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo {
  font-size: 1.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.logo-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: inherit;
}

.logo-img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 12px;
  background: white;
  padding: 4px;
  box-shadow: 0 2px 6px var(--shadow-color);
}

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--accent-color);
  color: white;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.logo-link:focus-visible {
  outline: 2px solid var(--light-color);
  outline-offset: 4px;
  border-radius: 12px;
}

.nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nav-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
  backdrop-filter: blur(10px);
}

.nav-btn:hover,
.nav-btn.active {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.header-controls {
  display: flex;
  gap: 0.5rem;
}

.theme-toggle,
.lang-toggle {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 0.5rem;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover,
.lang-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

/* Main Content */
.main {
  min-height: calc(100vh - 200px);
  padding: 2rem 0;
}

/* Sections */
.section {
  display: none;
  animation: fadeIn 0.5s ease-in-out;
}

.section.active {
  display: block;
}

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

.section-header {
  text-align: center;
  margin-bottom: 2rem;
}

.section-header h2 {
  font-size: 2.5rem;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.section-header p {
  font-size: 1.1rem;
  color: var(--secondary-color);
}

/* Welcome Section */
.welcome-content {
  text-align: center;
  max-width: 800px;
  margin: 0 auto;
}

.welcome-content h2 {
  font-size: 3rem;
  color: var(--primary-color);
  margin-bottom: 1rem;
}

.welcome-content p {
  font-size: 1.3rem;
  color: var(--secondary-color);
  margin-bottom: 3rem;
}

.summary-panel {
  background: white;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  padding: 1.5rem;
  box-shadow: 0 10px 28px var(--shadow-color);
  margin-bottom: 2.5rem;
}

.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.summary-header h3 {
  color: var(--primary-color);
}

.summary-hint {
  font-size: 0.85rem;
  color: var(--secondary-color);
}

.summary-highlights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.highlight-card {
  background: white;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  padding: 1.5rem;
  box-shadow: 0 6px 18px var(--shadow-color);
  position: relative;
}

.highlight-card .metric-label {
  font-size: 0.9rem;
  color: var(--secondary-color);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.highlight-card .metric-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
  margin: 0.5rem 0;
}

.highlight-card .metric-detail {
  font-size: 0.95rem;
  color: var(--secondary-color);
}

.highlight-card.skeleton {
  animation: pulse 1.4s ease-in-out infinite;
  text-align: center;
}

@keyframes pulse {
  0% { opacity: 0.4; }
  50% { opacity: 1; }
  100% { opacity: 0.4; }
}

.quick-actions {
  background: var(--background-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 2rem 0;
  box-shadow: 0 4px 12px var(--shadow-color);
}

.quick-actions h3 {
  color: var(--primary-color);
  margin-bottom: 0.8rem;
}

.quick-actions ul {
  list-style: disc;
  padding-left: 1.5rem;
  color: var(--secondary-color);
  font-size: 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  margin-bottom: 3rem;
}

.feature-card {
  background: white;
  padding: 2rem;
  border-radius: 15px;
  box-shadow: 0 5px 15px var(--shadow-color);
  text-align: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  border: 1px solid var(--border-color);
}

.feature-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px var(--shadow-color);
}

.feature-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.feature-card h3 {
  color: var(--primary-color);
  margin-bottom: 1rem;
  font-size: 1.3rem;
}

.feature-card p {
  color: var(--secondary-color);
  font-size: 1rem;
}

.icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: var(--secondary-color);
  color: white;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.icon-badge::before {
  content: attr(data-icon);
}

.icon-badge.feature {
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
}

.icon-badge.compact {
  width: 36px;
  height: 36px;
  font-size: 0.75rem;
  border-radius: 12px;
}

.cta-button {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  border: none;
  padding: 1rem 2rem;
  font-size: 1.2rem;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 5px 15px var(--shadow-color);
}

.cta-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px var(--shadow-color);
}

/* Forms */
.symptoms-form,
.triggers-form {
  width: 100%;
  margin: 0;
  background: white;
  padding: 2rem;
  border-radius: 15px;
  box-shadow: 0 5px 15px var(--shadow-color);
  border: 1px solid var(--border-color);
}

.section-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1.5rem;
  align-items: start;
}

.form-side-panel {
  background: var(--light-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 12px var(--shadow-color);
}

.form-side-panel h3 {
  color: var(--primary-color);
  margin-bottom: 1rem;
}

.form-side-panel ul {
  list-style: disc;
  padding-left: 1.5rem;
  color: var(--secondary-color);
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.panel-callout {
  border-radius: 10px;
  background: rgba(39, 174, 96, 0.1);
  border-left: 4px solid var(--success-color);
  padding: 1rem;
  color: var(--primary-color);
  font-size: 0.9rem;
}

.panel-callout.warning {
  background: rgba(243, 156, 18, 0.1);
  border-color: var(--warning-color);
  color: var(--warning-color);
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--primary-color);
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.8rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.3s ease;
  background-color: var(--background-color);
  color: var(--text-color);
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-color);
}

.form-group input[type="range"] {
  margin: 1rem 0;
}

.severity-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--secondary-color);
}

/* Symptoms and Triggers Grid */
.symptoms-grid,
.triggers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.symptom-category,
.trigger-category {
  background: var(--light-color);
  padding: 1.5rem;
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

.symptom-category h3,
.trigger-category h3 {
  color: var(--primary-color);
  margin-bottom: 1rem;
  font-size: 1.2rem;
}

.symptom-checklist,
.trigger-checklist {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.symptom-item,
.trigger-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 1px solid var(--border-color);
}

.symptom-item:hover,
.trigger-item:hover {
  background: var(--light-color);
  transform: translateX(5px);
}

.symptom-item input,
.trigger-item input {
  width: auto;
  margin: 0;
}

.symptom-icon {
  background: var(--primary-color);
}

.trigger-icon {
  background: var(--accent-color);
  color: var(--primary-color);
}

.submit-btn {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  border: none;
  padding: 1rem 2rem;
  font-size: 1.1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
  margin-top: 1rem;
}

.submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px var(--shadow-color);
}

/* Correlations */
.correlations-container {
  max-width: 1000px;
  margin: 0 auto;
}

.correlation-filters {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.filter-btn {
  background: white;
  border: 2px solid var(--border-color);
  color: var(--text-color);
  padding: 0.8rem 1.5rem;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
}

.filter-btn:hover,
.filter-btn.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.correlations-results {
  display: grid;
  gap: 1.5rem;
}

.correlation-card {
  background: white;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 3px 10px var(--shadow-color);
  border-left: 4px solid var(--accent-color);
  border: 1px solid var(--border-color);
}

.correlation-card.strong {
  border-left-color: var(--error-color);
}

.correlation-card.moderate {
  border-left-color: var(--warning-color);
}

.correlation-card.weak {
  border-left-color: var(--info-color);
}

.correlation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.correlation-strength {
  padding: 0.3rem 0.8rem;
  border-radius: 15px;
  font-size: 0.8rem;
  font-weight: 600;
  color: white;
}

.correlation-strength.strong {
  background: var(--error-color);
}

.correlation-strength.moderate {
  background: var(--warning-color);
}

.correlation-strength.weak {
  background: var(--info-color);
}

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

.correlation-item {
  padding: 0.8rem;
  background: var(--light-color);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.correlation-item h4 {
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.correlation-stats {
  display: flex;
  justify-content: space-around;
  background: var(--light-color);
  padding: 1rem;
  border-radius: 8px;
  margin-top: 1rem;
  border: 1px solid var(--border-color);
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
}

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

/* Guidance */
.guidance-content {
  max-width: 800px;
  margin: 0 auto;
  display: grid;
  gap: 2rem;
}

.guidance-card {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 5px 15px var(--shadow-color);
  border: 1px solid var(--border-color);
}

.guidance-card h3 {
  color: var(--primary-color);
  margin-bottom: 1rem;
  font-size: 1.3rem;
}

.guidance-card ul {
  list-style: none;
  padding: 0;
}

.guidance-card li {
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--border-color);
  position: relative;
  padding-left: 2rem;
}

.guidance-card li:last-child {
  border-bottom: none;
}

.guidance-card li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 10px;
  height: 10px;
  background: var(--accent-color);
  border-radius: 3px;
  transform: translateY(-50%);
}

.personalized-guidance {
  display: grid;
  gap: 1.5rem;
}

.guidance-alert {
  padding: 1rem;
  border-radius: 8px;
  border-left: 4px solid;
  margin-bottom: 1rem;
}

.guidance-alert.warning {
  background: rgba(243, 156, 18, 0.1);
  border-left-color: var(--warning-color);
  color: var(--warning-color);
}

.guidance-alert.danger {
  background: rgba(231, 76, 60, 0.1);
  border-left-color: var(--error-color);
  color: var(--error-color);
}

.guidance-alert.info {
  background: rgba(52, 152, 219, 0.1);
  border-left-color: var(--info-color);
  color: var(--info-color);
}

/* History */
.history-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.date-filter {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.date-filter label {
  font-weight: 600;
  color: var(--primary-color);
}

.date-filter input {
  padding: 0.5rem;
  border: 2px solid var(--border-color);
  border-radius: 5px;
  background-color: var(--background-color);
  color: var(--text-color);
}

.danger-btn {
  background: var(--error-color);
  color: white;
  border: none;
  padding: 0.8rem 1.5rem;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.danger-btn:hover {
  background: #c0392b;
  transform: translateY(-2px);
}

.history-timeline {
  position: relative;
  max-width: 800px;
  margin: 0 auto;
}

.history-timeline::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-color);
  transform: translateX(-50%);
}

.timeline-item {
  position: relative;
  margin-bottom: 2rem;
  width: 45%;
}

.timeline-item:nth-child(odd) {
  left: 0;
}

.timeline-item:nth-child(even) {
  left: 55%;
}

.timeline-item::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  background: var(--accent-color);
  border-radius: 50%;
  top: 20px;
  z-index: 1;
  border: 3px solid var(--background-color);
}

.timeline-item:nth-child(odd)::before {
  right: -11px;
}

.timeline-item:nth-child(even)::before {
  left: -11px;
}

.timeline-content {
  background: white;
  padding: 1.5rem;
  border-radius: 10px;
  box-shadow: 0 3px 10px var(--shadow-color);
  border: 1px solid var(--border-color);
}

.timeline-date {
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.timeline-type {
  display: inline-block;
  padding: 0.2rem 0.8rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.timeline-type.symptom {
  background: rgba(231, 76, 60, 0.1);
  color: var(--error-color);
}

.timeline-type.trigger {
  background: rgba(243, 156, 18, 0.1);
  color: var(--warning-color);
}

.timeline-details {
  color: var(--secondary-color);
}

.no-data {
  text-align: center;
  padding: 3rem;
  color: var(--secondary-color);
  font-style: italic;
}

/* Footer */
.footer {
  background: var(--primary-color);
  color: white;
  text-align: center;
  padding: 2rem 0;
  margin-top: 3rem;
}

.footer .footer-link {
  color: white;
  text-decoration: underline;
  margin-left: 0.3rem;
}

.footer .footer-link:hover {
  color: var(--light-color);
}

.footer-separator {
  margin: 0 0.5rem;
  color: rgba(255, 255, 255, 0.6);
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  flex-direction: column;
}

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

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-overlay p {
  color: white;
  font-size: 1.1rem;
}

/* Notifications */
.notifications {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1001;
  max-width: 400px;
}

.notification {
  background: white;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 5px 15px var(--shadow-color);
  margin-bottom: 1rem;
  border-left: 4px solid;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.notification.success {
  border-left-color: var(--success-color);
}

.notification.error {
  border-left-color: var(--error-color);
}

.notification.warning {
  border-left-color: var(--warning-color);
}

.notification.info {
  border-left-color: var(--info-color);
}

.notification-header {
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}

.notification-message {
  color: var(--secondary-color);
  font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
  .header .container {
    flex-direction: column;
    text-align: center;
  }
  
  .nav {
    order: 3;
    width: 100%;
    justify-content: center;
  }
  
  .nav-btn {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
  }
  
  .welcome-content h2 {
    font-size: 2rem;
  }
  
  .welcome-content p {
    font-size: 1.1rem;
  }
  
  .feature-grid {
    grid-template-columns: 1fr;
  }
  
  .section-header h2 {
    font-size: 2rem;
  }
  
  .symptoms-grid,
  .triggers-grid {
    grid-template-columns: 1fr;
  }
  
  .correlation-details {
    grid-template-columns: 1fr;
  }
  
  .history-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .section-grid {
    grid-template-columns: 1fr;
  }

  .summary-highlights {
    grid-template-columns: 1fr;
  }

  .summary-panel {
    padding: 1.2rem;
  }

  .quick-actions {
    margin: 1.5rem 0;
  }
  
  .date-filter {
    justify-content: center;
  }
  
  .history-timeline::before {
    left: 20px;
  }
  
  .timeline-item {
    width: calc(100% - 40px);
    left: 40px !important;
  }
  
  .timeline-item::before {
    left: -31px !important;
  }
  
  .notifications {
    left: 20px;
    right: 20px;
    max-width: none;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 15px;
  }
  
  .symptoms-form,
  .triggers-form {
    padding: 1rem;
  }
  
  .feature-card {
    padding: 1.5rem;
  }
  
  .guidance-card {
    padding: 1.5rem;
  }
  
  .timeline-content {
    padding: 1rem;
  }
}

/* Print Styles */
@media print {
  .header,
  .footer,
  .nav,
  .header-controls,
  .submit-btn,
  .cta-button,
  .filter-btn,
  .danger-btn,
  .loading-overlay,
  .notifications {
    display: none !important;
  }
  
  .main {
    padding: 0;
  }
  
  .section {
    display: block !important;
    break-inside: avoid;
  }
  
  .feature-card,
  .correlation-card,
  .guidance-card,
  .timeline-content {
    box-shadow: none;
    border: 1px solid #ccc;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  :root {
    --shadow-color: rgba(0, 0, 0, 0.3);
  }
  
  .feature-card,
  .correlation-card,
  .guidance-card,
  .timeline-content {
    border: 2px solid var(--primary-color);
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
