/**
 * Breeders Online - Main Stylesheet
 * Consolidated styles for navigation, buttons, accessibility, and modern UX
 */

/* ============================================
   1. CSS CUSTOM PROPERTIES (Design Tokens)
   ============================================ */
:root {
  /* Spacing scale */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Border radius scale */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.15);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 350ms ease;

  /* Focus ring */
  --focus-ring: 0 0 0 3px rgba(44, 85, 48, 0.4);
  --focus-ring-amber: 0 0 0 3px rgba(193, 154, 107, 0.4);
}

/* ============================================
   2. BASE & ACCESSIBILITY
   ============================================ */

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus states for accessibility */
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

/* Skip to content link for screen readers */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--heritage-primary, #2C5530);
  color: white;
  padding: var(--space-sm) var(--space-md);
  z-index: 10000;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: 0;
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================
   3. NAVIGATION STYLES
   ============================================ */
.navbar {
  padding: var(--space-lg) 0;
  border-bottom: 1px solid #e9ecef;
  margin-bottom: var(--space-xl);
  min-height: 160px;
  background: white;
}

.navbar-brand {
  display: flex;
  align-items: center;
  margin-right: var(--space-xl);
}

.navbar-brand img {
  transition: transform var(--transition-normal);
  height: 140px;
  width: 140px;
  object-fit: contain;
}

.navbar-brand:hover img {
  transform: scale(1.05);
}

.navbar-collapse {
  align-items: center;
}

.navbar-nav {
  align-items: center;
  flex-direction: row;
}

.navbar-nav .nav-link {
  font-weight: 500;
  color: #495057;
  padding: var(--space-sm) var(--space-md);
  margin: 0 var(--space-xs);
  border-radius: var(--radius-md);
  transition: all var(--transition-normal);
  font-size: 1.05rem;
  position: relative;
  white-space: nowrap;
}

.navbar-nav .nav-link:hover {
  color: var(--heritage-amber, #C19A6B);
  background: rgba(193, 154, 107, 0.08);
}

.navbar-nav .nav-link.active {
  color: white;
  background: var(--heritage-amber, #C19A6B);
  border-radius: var(--radius-md);
}

/* Dropdown improvements */
.navbar-nav .dropdown-menu {
  border: none;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-lg);
  padding: var(--space-sm);
  margin-top: var(--space-sm);
}

.navbar-nav .dropdown-item {
  border-radius: var(--radius-md);
  padding: 0.6rem var(--space-md);
  font-weight: 500;
  transition: all var(--transition-fast);
}

.navbar-nav .dropdown-item:hover {
  background: rgba(193, 154, 107, 0.1);
  color: var(--heritage-amber, #C19A6B);
}

/* Right-side buttons styling */
.navbar .text-end {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-left: auto;
}

/* Better desktop layout */
@media (min-width: 992px) {
  .navbar-nav {
    flex-grow: 0;
    margin: 0 auto 0 0;
  }

  .navbar .text-end {
    margin-left: auto;
  }

  .container-fluid {
    align-items: center;
  }
}

/* Mobile responsive adjustments */
@media (max-width: 991px) {
  .navbar {
    min-height: auto;
    padding: var(--space-md) 0;
  }

  .navbar-brand img {
    height: 80px;
    width: 80px;
  }

  .navbar-collapse {
    background: white;
    padding: var(--space-md) 0;
    margin-top: var(--space-md);
    border-top: 1px solid #e9ecef;
  }

  .navbar-nav {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    padding: 0;
    border-right: none;
  }

  .navbar-nav .nav-item {
    width: 100%;
  }

  .navbar-nav .nav-link {
    padding: 0.75rem var(--space-md);
    margin: var(--space-xs) 0;
    width: 100%;
    text-align: left;
    border-radius: var(--radius-md);
  }

  .navbar-nav .dropdown-menu {
    position: static;
    width: 100%;
    margin-top: var(--space-sm);
    margin-bottom: var(--space-sm);
    box-shadow: none;
    background: #f8f9fa;
  }

  .navbar .text-end {
    flex-direction: column;
    align-items: stretch;
    padding: var(--space-md) 0;
    gap: 0.75rem;
    width: 100%;
  }

  .navbar .btn {
    width: 100%;
    padding: 0.75rem;
  }
}

/* ============================================
   4. BUTTON SYSTEM
   ============================================ */

/* Base button styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.625rem 1.25rem;
  font-weight: 500;
  font-size: 0.95rem;
  border-radius: var(--radius-xl);
  transition: all var(--transition-normal);
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  border: 2px solid transparent;
}

.btn:focus-visible {
  box-shadow: var(--focus-ring);
}

/* Button sizes */
.btn-sm {
  padding: 0.375rem 0.875rem;
  font-size: 0.875rem;
  border-radius: var(--radius-lg);
}

.btn-lg {
  padding: 0.875rem 1.75rem;
  font-size: 1.1rem;
  border-radius: var(--radius-xl);
}

/* Primary button */
.btn-primary {
  background: var(--heritage-primary, #2C5530);
  border-color: var(--heritage-primary, #2C5530);
  color: white;
}

.btn-primary:hover {
  background: var(--heritage-primary-dark, #1F3D22);
  border-color: var(--heritage-primary-dark, #1F3D22);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-primary:active {
  transform: translateY(0);
}

/* Outline primary */
.btn-outline-primary {
  background: transparent;
  border-color: var(--heritage-primary, #2C5530);
  color: var(--heritage-primary, #2C5530);
}

.btn-outline-primary:hover {
  background: var(--heritage-primary, #2C5530);
  border-color: var(--heritage-primary, #2C5530);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Secondary/Amber button */
.btn-secondary,
.btn-amber {
  background: var(--heritage-amber, #C19A6B);
  border-color: var(--heritage-amber, #C19A6B);
  color: white;
}

.btn-secondary:hover,
.btn-amber:hover {
  background: #A8825A;
  border-color: #A8825A;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Success button */
.btn-success {
  background: #059669;
  border-color: #059669;
  color: white;
}

.btn-success:hover {
  background: #047857;
  border-color: #047857;
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(5, 150, 105, 0.3);
}

/* Danger button */
.btn-danger {
  background: #DC2626;
  border-color: #DC2626;
  color: white;
}

.btn-danger:hover {
  background: #B91C1C;
  border-color: #B91C1C;
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(220, 38, 38, 0.3);
}

/* Dark button */
.btn-dark {
  background: #495057;
  border-color: #495057;
  color: white;
}

.btn-dark:hover {
  background: #343a40;
  border-color: #343a40;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Light/Ghost button */
.btn-light,
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: #495057;
}

.btn-light:hover,
.btn-ghost:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #212529;
}

/* Icon button */
.btn-icon {
  padding: 0.5rem;
  border-radius: var(--radius-md);
}

.btn-icon.btn-sm {
  padding: 0.375rem;
}

.btn-icon.btn-lg {
  padding: 0.75rem;
}

/* ============================================
   5. TOAST NOTIFICATION SYSTEM
   ============================================ */
.toast-container {
  position: fixed;
  top: var(--space-xl);
  right: var(--space-xl);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-width: 400px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  pointer-events: auto;
  animation: toast-slide-in var(--transition-normal) ease-out;
  border-left: 4px solid #6B7280;
}

.toast.toast-success {
  border-left-color: #059669;
}

.toast.toast-error {
  border-left-color: #DC2626;
}

.toast.toast-warning {
  border-left-color: #D97706;
}

.toast.toast-info {
  border-left-color: #1E5F8E;
}

.toast-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
}

.toast-success .toast-icon {
  color: #059669;
}

.toast-error .toast-icon {
  color: #DC2626;
}

.toast-warning .toast-icon {
  color: #D97706;
}

.toast-info .toast-icon {
  color: #1E5F8E;
}

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-weight: 600;
  color: #1A1F2E;
  margin-bottom: var(--space-xs);
}

.toast-message {
  color: #6B7280;
  font-size: 0.9rem;
  line-height: 1.4;
}

.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: #9CA3AF;
  cursor: pointer;
  padding: var(--space-xs);
  margin: calc(var(--space-xs) * -1);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.toast-close:hover {
  color: #6B7280;
  background: rgba(0, 0, 0, 0.05);
}

.toast.toast-hiding {
  animation: toast-slide-out var(--transition-normal) ease-in forwards;
}

@keyframes toast-slide-in {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toast-slide-out {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* Mobile toast positioning */
@media (max-width: 480px) {
  .toast-container {
    top: var(--space-md);
    right: var(--space-md);
    left: var(--space-md);
    max-width: none;
  }
}

/* ============================================
   6. FORM ENHANCEMENTS
   ============================================ */
.form-control:focus,
.form-select:focus {
  border-color: var(--heritage-primary, #2C5530);
  box-shadow: var(--focus-ring);
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
  border-color: #DC2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
}

.form-control.is-valid:focus,
.form-select.is-valid:focus {
  border-color: #059669;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.2);
}

/* Form labels with required indicator */
.form-label.required::after {
  content: " *";
  color: #DC2626;
}

/* Input groups */
.input-group .form-control:focus {
  z-index: 3;
}

/* ============================================
   7. CARD ENHANCEMENTS
   ============================================ */
.card {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  transition: all var(--transition-normal);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card-hover:hover {
  transform: translateY(-4px);
}

.card-img-top {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* ============================================
   8. LOADING STATES
   ============================================ */

/* Spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Button loading state */
.btn.is-loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ============================================
   9. UTILITY CLASSES
   ============================================ */

/* Text utilities */
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.text-truncate-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Gradient text */
.text-gradient {
  background: linear-gradient(135deg, var(--heritage-primary) 0%, var(--heritage-amber) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Dividers */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, #e9ecef 50%, transparent);
  margin: var(--space-xl) 0;
}

/* Hover effects */
.hover-lift {
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

/* Image aspect ratios */
.aspect-square {
  aspect-ratio: 1 / 1;
}

.aspect-video {
  aspect-ratio: 16 / 9;
}

.aspect-portrait {
  aspect-ratio: 3 / 4;
}

/* Object fit utilities */
.object-cover {
  object-fit: cover;
}

.object-contain {
  object-fit: contain;
}

/* ============================================
   10. ANIMATIONS
   ============================================ */
.fade-in {
  animation: fade-in var(--transition-normal) ease-out;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.slide-up {
  animation: slide-up var(--transition-normal) ease-out;
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Staggered animations for lists */
.stagger-children > * {
  animation: slide-up var(--transition-normal) ease-out backwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 50ms; }
.stagger-children > *:nth-child(3) { animation-delay: 100ms; }
.stagger-children > *:nth-child(4) { animation-delay: 150ms; }
.stagger-children > *:nth-child(5) { animation-delay: 200ms; }
.stagger-children > *:nth-child(6) { animation-delay: 250ms; }

/* ============================================
   11. PRINT STYLES
   ============================================ */
@media print {
  .navbar,
  .toast-container,
  .btn,
  footer {
    display: none !important;
  }

  body {
    font-size: 12pt;
    line-height: 1.5;
  }

  a {
    text-decoration: underline;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.9em;
    color: #666;
  }
}
