/* Enhanced styles for Sobriety Habits - UI Design Improvements */

/* Root variables for consistent theming */
:root {
  --primary-green: #16a34a;
  --primary-green-dark: #15803d;
  --primary-green-light: #22c55e;
  --accent-emerald: #10b981;
  --bg-light: #fafffe;
  --bg-card: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-light: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.05);
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
}

/* Typography enhancements */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--text-primary);
  line-height: 1.7;
  background-color: var(--bg-light);
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.3;
}

.prose {
  line-height: 1.8;
}

.prose p {
  margin-bottom: 1.5rem;
}

.prose h2 {
  margin-top: 3rem;
  margin-bottom: 1.5rem;
  font-size: 1.875rem;
  color: var(--text-primary);
}

.prose h3 {
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  font-size: 1.5rem;
  color: var(--text-primary);
}

/* Enhanced hero section */
.hero-gradient {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 50%, #f0fdf4 100%);
  position: relative;
  overflow: hidden;
}

.hero-gradient::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(34, 197, 94, 0.1) 0%, transparent 70%);
  animation: pulse 20s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.1) rotate(180deg); }
}

/* Enhanced text gradient */
.text-gradient {
  background: linear-gradient(135deg, #15803d 0%, #22c55e 50%, #16a34a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  background-size: 200% auto;
  animation: gradient-shift 3s ease infinite;
}

@keyframes gradient-shift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Card improvements */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-light);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary-green), var(--accent-emerald));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
}

.card:hover {
  box-shadow: var(--shadow-xl);
  transform: translateY(-4px);
  border-color: var(--primary-green-light);
}

.card:hover::before {
  transform: scaleX(1);
}

/* Button enhancements */
.btn-primary {
  background: linear-gradient(135deg, var(--primary-green-dark), var(--primary-green));
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  box-shadow: var(--shadow-md);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

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

.btn-primary:hover::before {
  width: 300px;
  height: 300px;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--primary-green-dark);
  border: 2px solid var(--primary-green);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: var(--primary-green);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Enhanced focus states */
.focus-ring:focus {
  outline: 3px solid rgba(34, 197, 94, 0.5);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Form improvements */
input, textarea {
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  transition: all 0.2s ease;
  background: var(--bg-card);
}

input:focus, textarea:focus {
  border-color: var(--primary-green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
  outline: none;
}

/* Blog post cards */
.blog-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  border: 1px solid var(--border-light);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.blog-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--primary-green), var(--accent-emerald));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
}

.blog-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.blog-card:hover::after {
  transform: scaleX(1);
}

/* Navigation improvements */
nav a {
  position: relative;
  color: var(--text-secondary);
  transition: color 0.2s ease;
  font-weight: 500;
}

nav a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--primary-green);
  transition: width 0.2s ease;
}

nav a:hover::after {
  width: 100%;
}

/* Header enhancement */
header {
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.95) !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05) !important;
}

/* Mobile menu improvements */
@media (max-width: 768px) {
  .mobile-nav {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
  }
}

nav a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--primary-green);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.3s ease;
}

nav a:hover {
  color: var(--primary-green-dark);
}

nav a:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* Feature sections */
.feature-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.1), rgba(16, 185, 129, 0.1));
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-green);
  font-size: 24px;
  transition: all 0.3s ease;
}

.feature-card:hover .feature-icon {
  background: linear-gradient(135deg, var(--primary-green), var(--accent-emerald));
  color: white;
  transform: scale(1.1) rotate(5deg);
}

/* Newsletter section enhancement */
.newsletter-section {
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  border-radius: var(--radius-xl);
  padding: 3rem;
  position: relative;
  overflow: hidden;
}

.newsletter-section::before {
  content: '🦌';
  position: absolute;
  top: -20px;
  right: 20px;
  font-size: 100px;
  opacity: 0.1;
  transform: rotate(15deg);
}

/* Success/Error messages */
.newsletter-success {
  background: linear-gradient(135deg, #dcfce7, #d1fae5);
  color: var(--primary-green-dark);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid #bbf7d0;
  font-weight: 500;
  animation: slideInUp 0.3s ease;
}

.newsletter-error {
  background: linear-gradient(135deg, #fef2f2, #fee2e2);
  color: #dc2626;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid #fecaca;
  font-weight: 500;
  animation: slideInUp 0.3s ease;
}

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

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Loading states */
.loading {
  position: relative;
  color: transparent;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--primary-green);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Mobile responsiveness improvements */
@media (max-width: 768px) {
  :root {
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
  }
  
  .hero-gradient {
    padding: 2rem 1rem;
  }
  
  .card, .blog-card {
    margin-bottom: 1rem;
  }
  
  .newsletter-section {
    padding: 2rem 1.5rem;
  }
}

/* Dark mode variables */
[data-theme="dark"] {
  --bg-light: #0a0f0a;
  --bg-card: #111827;
  --text-primary: #f3f4f6;
  --text-secondary: #d1d5db;
  --text-muted: #9ca3af;
  --border-light: #374151;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
}

/* Dark mode prose content readability */
[data-theme="dark"] .prose {
  color: #e5e7eb; /* Light gray for body text */
}

[data-theme="dark"] .prose h1,
[data-theme="dark"] .prose h2,
[data-theme="dark"] .prose h3,
[data-theme="dark"] .prose h4,
[data-theme="dark"] .prose h5,
[data-theme="dark"] .prose h6 {
  color: #f9fafb; /* Near white for headings */
}

[data-theme="dark"] .prose strong {
  color: #f3f4f6; /* Bright for emphasis */
}

[data-theme="dark"] .prose a {
  color: #60a5fa; /* Bright blue for links */
}

[data-theme="dark"] .prose a:hover {
  color: #93c5fd; /* Lighter blue on hover */
}

[data-theme="dark"] .prose blockquote {
  color: #d1d5db; /* Medium gray for quotes */
  border-left-color: #4b5563;
}

[data-theme="dark"] .prose code {
  color: #f3f4f6;
  background-color: #1f2937;
}

[data-theme="dark"] .prose pre {
  background-color: #1f2937;
  color: #e5e7eb;
}

[data-theme="dark"] .prose ul li::before,
[data-theme="dark"] .prose ol li::before {
  color: #9ca3af;
}

[data-theme="dark"] .prose hr {
  border-color: #374151;
}

[data-theme="dark"] .hero-gradient {
  background: linear-gradient(135deg, #064e3b 0%, #065f46 50%, #064e3b 100%);
}

[data-theme="dark"] .card,
[data-theme="dark"] .blog-card {
  background: var(--bg-card);
}

[data-theme="dark"] header {
  background: rgba(17, 24, 39, 0.95) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
}

[data-theme="dark"] .newsletter-section {
  background: linear-gradient(135deg, #064e3b, #065f46);
}

[data-theme="dark"] .text-gradient {
  background: linear-gradient(135deg, #34d399 0%, #10b981 50%, #059669 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Dark mode — text color overrides */
[data-theme="dark"] .text-gray-900 { color: #f3f4f6; }
[data-theme="dark"] .text-gray-800 { color: #e5e7eb; }
[data-theme="dark"] .text-gray-700 { color: #d1d5db; }
[data-theme="dark"] .text-gray-600 { color: #9ca3af; }
[data-theme="dark"] .text-gray-500 { color: #6b7280; }

/* Dark mode — background overrides */
[data-theme="dark"] .bg-white { background-color: var(--bg-card); }
[data-theme="dark"] .bg-gray-50 { background-color: #1a1a2e; }
[data-theme="dark"] .bg-gray-100 { background-color: #1f2937; }
[data-theme="dark"] .bg-green-50 { background-color: #052e16; }
[data-theme="dark"] .bg-green-100 { background-color: #064e3b; }
[data-theme="dark"] .bg-red-50 { background-color: #2d1b1b; }

/* Dark mode — border overrides */
[data-theme="dark"] .border-gray-200,
[data-theme="dark"] .border-gray-100 { border-color: #374151; }
[data-theme="dark"] .border-green-100 { border-color: #065f46; }
[data-theme="dark"] .border-t { border-color: #374151; }

/* Dark mode — form inputs */
[data-theme="dark"] .placeholder-gray-500::placeholder { color: #6b7280; }

/* Dark mode — details/summary FAQ */
[data-theme="dark"] details summary { color: #f3f4f6; }

/* Dark mode — mobile menu */
[data-theme="dark"] .mobile-nav {
  background: rgba(17, 24, 39, 0.98);
}

/* Dark mode — shadow adjustments */
[data-theme="dark"] .shadow-sm { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); }
[data-theme="dark"] .shadow-lg { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4); }

/* System preference support */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-light: #0a0f0a;
    --bg-card: #111827;
    --text-primary: #f3f4f6;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --border-light: #374151;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
  }
  
  /* Dark mode prose content readability */
  :root:not([data-theme="light"]) .prose {
    color: #e5e7eb; /* Light gray for body text */
  }

  :root:not([data-theme="light"]) .prose h1,
  :root:not([data-theme="light"]) .prose h2,
  :root:not([data-theme="light"]) .prose h3,
  :root:not([data-theme="light"]) .prose h4,
  :root:not([data-theme="light"]) .prose h5,
  :root:not([data-theme="light"]) .prose h6 {
    color: #f9fafb; /* Near white for headings */
  }

  :root:not([data-theme="light"]) .prose strong {
    color: #f3f4f6; /* Bright for emphasis */
  }

  :root:not([data-theme="light"]) .prose a {
    color: #60a5fa; /* Bright blue for links */
  }

  :root:not([data-theme="light"]) .prose a:hover {
    color: #93c5fd; /* Lighter blue on hover */
  }

  :root:not([data-theme="light"]) .prose blockquote {
    color: #d1d5db; /* Medium gray for quotes */
    border-left-color: #4b5563;
  }

  :root:not([data-theme="light"]) .prose code {
    color: #f3f4f6;
    background-color: #1f2937;
  }

  :root:not([data-theme="light"]) .prose pre {
    background-color: #1f2937;
    color: #e5e7eb;
  }

  :root:not([data-theme="light"]) .prose ul li::before,
  :root:not([data-theme="light"]) .prose ol li::before {
    color: #9ca3af;
  }

  :root:not([data-theme="light"]) .prose hr {
    border-color: #374151;
  }
  
  :root:not([data-theme="light"]) .hero-gradient {
    background: linear-gradient(135deg, #064e3b 0%, #065f46 50%, #064e3b 100%);
  }
  
  :root:not([data-theme="light"]) .card,
  :root:not([data-theme="light"]) .blog-card {
    background: var(--bg-card);
  }
  
  :root:not([data-theme="light"]) header {
    background: rgba(17, 24, 39, 0.95) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
  }
  
  :root:not([data-theme="light"]) .newsletter-section {
    background: linear-gradient(135deg, #064e3b, #065f46);
  }
  
  :root:not([data-theme="light"]) .text-gradient {
    background: linear-gradient(135deg, #34d399 0%, #10b981 50%, #059669 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }

  /* Text color overrides */
  :root:not([data-theme="light"]) .text-gray-900 { color: #f3f4f6; }
  :root:not([data-theme="light"]) .text-gray-800 { color: #e5e7eb; }
  :root:not([data-theme="light"]) .text-gray-700 { color: #d1d5db; }
  :root:not([data-theme="light"]) .text-gray-600 { color: #9ca3af; }
  :root:not([data-theme="light"]) .text-gray-500 { color: #6b7280; }

  /* Background overrides */
  :root:not([data-theme="light"]) .bg-white { background-color: var(--bg-card); }
  :root:not([data-theme="light"]) .bg-gray-50 { background-color: #1a1a2e; }
  :root:not([data-theme="light"]) .bg-gray-100 { background-color: #1f2937; }
  :root:not([data-theme="light"]) .bg-green-50 { background-color: #052e16; }
  :root:not([data-theme="light"]) .bg-green-100 { background-color: #064e3b; }
  :root:not([data-theme="light"]) .bg-red-50 { background-color: #2d1b1b; }

  /* Border overrides */
  :root:not([data-theme="light"]) .border-gray-200,
  :root:not([data-theme="light"]) .border-gray-100 { border-color: #374151; }
  :root:not([data-theme="light"]) .border-green-100 { border-color: #065f46; }
  :root:not([data-theme="light"]) .border-t { border-color: #374151; }

  /* Form inputs */
  :root:not([data-theme="light"]) .placeholder-gray-500::placeholder { color: #6b7280; }

  /* Details/summary FAQ */
  :root:not([data-theme="light"]) details summary { color: #f3f4f6; }

  /* Mobile menu */
  :root:not([data-theme="light"]) .mobile-nav {
    background: rgba(17, 24, 39, 0.98);
  }

  /* Shadow adjustments */
  :root:not([data-theme="light"]) .shadow-sm { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); }
  :root:not([data-theme="light"]) .shadow-lg { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4); }
}

/* Theme switcher styles */
.theme-switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
}

.theme-option {
  padding: 0.5rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.theme-option:hover {
  color: var(--text-primary);
  background: rgba(34, 197, 94, 0.1);
}

.theme-option.active {
  background: var(--primary-green);
  color: white;
}

.theme-option i {
  font-size: 1rem;
}

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

/* Print styles */
@media print {
  .no-print {
    display: none !important;
  }
  
  body {
    color: black;
    background: white;
  }
}