/**
 * Insurance Comparison Serbia - Custom Styles
 * Accessible, mobile-first design for all age groups (18-80+)
 * High contrast, large fonts, Serbian market optimized
 */

/* Root Variables */
:root {
  /* Colors - High contrast for accessibility */
  --primary-color: #007bff;
  --primary-dark: #0056b3;
  --success-color: #28a745;
  --success-dark: #1e7e34;
  --danger-color: #dc3545;
  --danger-dark: #bd2130;
  --warning-color: #ffc107;
  --warning-dark: #d39e00;
  --info-color: #17a2b8;
  --info-dark: #138496;
  
  /* Neutral colors */
  --gray-100: #f8f9fa;
  --gray-200: #e9ecef;
  --gray-300: #dee2e6;
  --gray-400: #ced4da;
  --gray-500: #adb5bd;
  --gray-600: #6c757d;
  --gray-700: #495057;
  --gray-800: #343a40;
  --gray-900: #212529;
  
  /* Typography - Large fonts for accessibility */
  --font-size-base: 18px; /* Increased from default 16px */
  --font-size-lg: 22px;
  --font-size-xl: 26px;
  --font-size-small: 16px;
  --line-height-base: 1.6;
  
  /* Spacing */
  --spacer: 1rem;
  --spacer-2: 2rem;
  --spacer-3: 3rem;
  --spacer-4: 4rem;
  
  /* Borders and shadows */
  --border-radius: 0.5rem;
  --border-radius-lg: 1rem;
  --box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  --box-shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);
  
  /* Transitions */
  --transition: all 0.3s ease;
}

/* Base Styles - Performance Optimized */
* {
  box-sizing: border-box;
}

html {
  font-size: var(--font-size-base);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--gray-900);
  background-color: #ffffff;
  font-display: swap; /* Performance: Font loading optimization */
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Performance: Reduce layout shifts */
.container, .container-fluid {
  max-width: 100%;
  overflow-x: hidden;
}

/* Mobile-first responsive design */
@media (max-width: 576px) {
  html {
    font-size: 16px; /* Slightly smaller on mobile */
  }
  
  .display-4 {
    font-size: 2rem !important;
  }
  
  .lead {
    font-size: 1.1rem !important;
  }
  
  .btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
  }
}

/* Typography Enhancements */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.75rem;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1.1rem; }

p {
  margin-bottom: 1rem;
  font-size: var(--font-size-base);
}

.lead {
  font-size: var(--font-size-lg);
  font-weight: 400;
}

/* Button Enhancements - Larger, more accessible */
.btn {
  font-size: var(--font-size-base);
  font-weight: 500;
  padding: 0.75rem 1.5rem;
  border-radius: var(--border-radius);
  transition: var(--transition);
  border: 2px solid transparent;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  cursor: pointer;
  min-height: 44px; /* Accessibility minimum touch target */
}

.btn-lg {
  font-size: var(--font-size-lg);
  padding: 1rem 2rem;
  min-height: 56px;
}

.btn-sm {
  font-size: var(--font-size-small);
  padding: 0.5rem 1rem;
  min-height: 36px;
}

/* Enhanced button focus states for accessibility */
.btn:focus,
.btn:focus-visible {
  outline: 3px solid var(--warning-color);
  outline-offset: 2px;
  box-shadow: none;
}

/* Primary button with better contrast */
.btn-primary {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  color: #ffffff;
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #ffffff;
  transform: translateY(-1px);
}

/* Form Enhancements */
.form-control,
.form-select {
  font-size: var(--font-size-base);
  padding: 0.75rem 1rem;
  border: 2px solid var(--gray-300);
  border-radius: var(--border-radius);
  transition: var(--transition);
  min-height: 50px;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
  outline: none;
}

.form-control-lg,
.form-select-lg {
  font-size: var(--font-size-lg);
  padding: 1rem 1.25rem;
  min-height: 60px;
}

.form-label {
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--gray-700);
  font-size: var(--font-size-base);
}

.form-text {
  font-size: var(--font-size-small);
  color: var(--gray-600);
  margin-top: 0.25rem;
}

/* Invalid feedback styling */
.invalid-feedback {
  font-size: var(--font-size-small);
  color: var(--danger-color);
  font-weight: 500;
}

/* Card Enhancements */
.card {
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--box-shadow);
  transition: var(--transition);
  background-color: #ffffff;
}

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

.card-header {
  background-color: var(--gray-100);
  border-bottom: 1px solid var(--gray-200);
  font-weight: 600;
  padding: 1rem 1.5rem;
}

.card-body {
  padding: 1.5rem;
}

/* Alert Enhancements */
.alert {
  border-radius: var(--border-radius);
  border: 2px solid transparent;
  font-size: var(--font-size-base);
  padding: 1rem 1.5rem;
}

.alert-warning {
  background-color: #fff3cd;
  border-color: #ffeaa7;
  color: #856404;
}

.alert-info {
  background-color: #d1ecf1;
  border-color: #bee5eb;
  color: #0c5460;
}

.alert-success {
  background-color: #d4edda;
  border-color: #c3e6cb;
  color: #155724;
}

.alert-danger {
  background-color: #f8d7da;
  border-color: #f5c6cb;
  color: #721c24;
}

/* Navigation Enhancements */
.navbar {
  padding: 1rem 0;
  min-height: 80px;
}

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

.nav-link {
  font-size: var(--font-size-base);
  font-weight: 500;
  padding: 0.75rem 1rem;
  color: var(--gray-700);
  transition: var(--transition);
}

.nav-link:hover,
.nav-link:focus {
  color: var(--primary-color);
}

/* Hero Section */
.hero-section {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  border-radius: var(--border-radius-lg);
  padding: var(--spacer-4);
  margin-bottom: var(--spacer-3);
}

.hero-section h1 {
  font-size: 3rem;
  margin-bottom: var(--spacer);
}

@media (max-width: 768px) {
  .hero-section {
    padding: var(--spacer-2);
  }
  
  .hero-section h1 {
    font-size: 2rem;
  }
}

/* Insurance Type Cards */
.insurance-type-card {
  cursor: pointer;
  transition: var(--transition);
  border: 2px solid var(--gray-300);
}

.insurance-type-card:hover {
  border-color: var(--primary-color);
  transform: translateY(-2px);
}

.insurance-type-card.border-primary {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.insurance-type-card.border-success {
  border-color: var(--success-color);
  box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

/* Progress Indicators */
.progress {
  border-radius: var(--border-radius);
  height: 8px;
  background-color: var(--gray-200);
}

.progress-bar {
  border-radius: var(--border-radius);
  transition: width 0.6s ease;
}

/* Badge Enhancements */
.badge {
  font-size: 0.85em;
  font-weight: 600;
  padding: 0.5em 0.75em;
  border-radius: var(--border-radius);
}

/* Table Enhancements */
.table {
  font-size: var(--font-size-base);
}

.table th {
  font-weight: 600;
  border-top: none;
  padding: 1rem 0.75rem;
}

.table td {
  padding: 1rem 0.75rem;
  vertical-align: middle;
}

/* Modal Enhancements */
.modal-content {
  border-radius: var(--border-radius-lg);
  border: none;
  box-shadow: var(--box-shadow-lg);
}

.modal-header {
  border-bottom: 1px solid var(--gray-200);
  padding: 1.5rem;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  border-top: 1px solid var(--gray-200);
  padding: 1.5rem;
}

/* Currency Display */
.price-amount {
  font-family: 'Segoe UI', monospace;
  font-weight: 700;
}

/* Exchange Rate Widget */
#exchange-rates {
  font-family: monospace;
  font-weight: 600;
}

/* Accessibility Improvements */
.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;
}

/* Focus visible for better keyboard navigation */
*:focus-visible {
  outline: 3px solid var(--warning-color);
  outline-offset: 2px;
}

/* Skip link for screen readers */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--gray-900);
  color: white;
  padding: 8px;
  text-decoration: none;
  z-index: 1000;
}

.skip-link:focus {
  top: 6px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .card {
    border-width: 2px;
  }
  
  .btn {
    border-width: 3px;
  }
  
  .form-control,
  .form-select {
    border-width: 3px;
  }
}

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

/* Print Styles */
@media print {
  .no-print {
    display: none !important;
  }
  
  body {
    font-size: 12pt;
    line-height: 1.4;
    color: black;
    background: white;
  }
  
  .card {
    border: 1px solid black;
    break-inside: avoid;
  }
}

/* Mobile Optimizations */
@media (max-width: 576px) {
  :root {
    --font-size-base: 16px;
    --font-size-lg: 20px;
    --font-size-xl: 24px;
  }
  
  .container {
    padding-left: 15px;
    padding-right: 15px;
  }
  
  .btn {
    width: 100%;
    margin-bottom: 0.5rem;
  }
  
  .btn-group-vertical .btn {
    width: 100%;
  }
  
  .hero-section h1 {
    font-size: 1.75rem;
  }
  
  .card-body {
    padding: 1rem;
  }
  
  /* Larger touch targets on mobile */
  .form-control,
  .form-select,
  .btn {
    min-height: 48px;
  }
  
  .btn-lg {
    min-height: 60px;
  }
}

/* Tablet Optimizations */
@media (min-width: 577px) and (max-width: 991px) {
  .container {
    max-width: 90%;
  }
}

/* Special styling for mandatory insurance notices */
.mandatory-notice {
  border-left: 5px solid var(--danger-color);
  background-color: #fff5f5;
  padding: 1rem 1.5rem;
  margin: 1rem 0;
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.new-2025-notice {
  border-left: 5px solid var(--warning-color);
  background-color: #fffbf0;
  padding: 1rem 1.5rem;
  margin: 1rem 0;
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

/* Serbian number formatting support */
.number-sr {
  direction: ltr;
  unicode-bidi: bidi-override;
}

/* Loading states */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

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

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

/* Custom checkbox and radio styling for better accessibility */
.form-check-input {
  width: 1.25em;
  height: 1.25em;
  margin-top: 0.125em;
  cursor: pointer;
}

.form-check-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.form-check-label {
  cursor: pointer;
  font-size: var(--font-size-base);
}

/* Admin dashboard specific styles */
.admin-stats-card {
  transition: var(--transition);
}

.admin-stats-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--box-shadow-lg);
}

/* Footer styling */
footer {
  margin-top: auto;
}

footer .alert {
  margin-bottom: 0;
}

/* Utility classes for Serbian market */
.text-rsd {
  font-family: monospace;
  font-weight: 600;
  color: var(--success-color);
}

.text-mandatory {
  color: var(--danger-color);
  font-weight: 600;
}

.text-new-2025 {
  color: var(--warning-dark);
  font-weight: 600;
}

/* Improved form validation styling */
.was-validated .form-control:valid {
  border-color: var(--success-color);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%2328a745' d='m2.3 6.73.8-.77-.8-.77-.8.77z'/%3e%3c/svg%3e");
}

.was-validated .form-control:invalid {
  border-color: var(--danger-color);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath d='m5.8 4.6 1.4 1.4 1.4-1.4'/%3e%3c/svg%3e");
}

/* Dark mode support (future enhancement) */
@media (prefers-color-scheme: dark) {
  /* This is prepared for future dark mode implementation */
  /* Currently keeping light mode for better accessibility */
}

/* Coverage limits styling */
.coverage-view .card {
    transition: all 0.3s ease;
    cursor: pointer;
    border: 2px solid transparent;
}

.coverage-view .card:hover {
    box-shadow: 0 4px 12px rgba(0,123,255,0.15);
    transform: translateY(-2px);
}

.coverage-view .card.border-primary {
    border-color: #007bff !important;
    box-shadow: 0 0 15px rgba(0,123,255,0.3);
}

.coverage-view .card input[type="radio"] {
    display: none;
}

.coverage-view .table tr {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.coverage-view .table tr:hover {
    background-color: rgba(0,123,255,0.05);
}

/* Toggle buttons */
.btn.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

/* Real-world examples styling */
.alert-info .row {
    align-items: center;
}

.alert-info strong {
    color: #0c5460;
}

/* Offer Preference Cards - New Feature */
.offer-preference-card {
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid var(--gray-300);
}

.offer-preference-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--box-shadow-lg);
}

.offer-preference-card input[type="radio"] {
    display: none;
}

.offer-preference-card input[type="radio"]:checked + label {
    background-color: var(--primary-color) !important;
    color: white !important;
}

.offer-preference-card input[type="radio"]:checked + label * {
    color: white !important;
}

.offer-preference-card input[type="radio"]:checked ~ * {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Coverage limits mobile responsiveness */
@media (max-width: 768px) {
    .coverage-view .col-md-4 {
        margin-bottom: 1rem;
    }
    
    .coverage-view .table {
        font-size: 0.9rem;
    }
    
    .btn-sm {
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem;
    }
    
    .offer-preference-card .card-body {
        padding: 0.75rem 0.5rem;
    }
    
    .offer-preference-card .small {
        font-size: 0.8rem;
    }
}

/* WhatsApp Floating Button */
.whatsapp-float {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background-color: #25D366;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
    transition: all 0.3s ease;
    z-index: 1000;
    text-decoration: none;
    color: white;
    font-size: 28px;
}

.whatsapp-float:hover {
    background-color: #128C7E;
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.6);
    color: white;
    text-decoration: none;
}

.whatsapp-float:focus {
    outline: 3px solid #25D366;
    outline-offset: 2px;
}

/* WhatsApp tooltip */
.whatsapp-float::before {
    content: attr(title);
    position: absolute;
    right: 70px;
    top: 50%;
    transform: translateY(-50%);
    background-color: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    font-family: 'Segoe UI', sans-serif;
}

.whatsapp-float:hover::before {
    opacity: 1;
    visibility: visible;
}

.whatsapp-float::after {
    content: '';
    position: absolute;
    right: 60px;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: #333;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.whatsapp-float:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Mobile responsiveness for WhatsApp button */
@media (max-width: 768px) {
    .whatsapp-float {
        width: 50px;
        height: 50px;
        font-size: 24px;
        bottom: 15px;
        right: 15px;
    }
    
    .whatsapp-float::before {
        display: none; /* Hide tooltip on mobile */
    }
    
    .whatsapp-float::after {
        display: none; /* Hide tooltip arrow on mobile */
    }
}
