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

body {
  font-family: Arial, sans-serif;
  text-align: center;
  background: #fafafa;
  color: #222;
  line-height: 1.5;
  /* Font optimization for CLS prevention */
  font-display: swap;
  /* Prevent invisible text during font load */
  font-optical-sizing: auto;
}

/* Accessibility: Screen Reader Only Text */
.sr-only {
  position: absolute !important;
  left: -10000px !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
}

/* Accessibility: Skip Links */
.skip-links {
  position: relative;
  z-index: 1000;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: #000;
  color: #fff;
  padding: 8px 16px;
  text-decoration: none;
  border-radius: 0 0 4px 4px;
  font-weight: bold;
  z-index: 1001;
  transition: top 0.3s ease;
}

.skip-link:focus {
  top: 0;
}

/* Accessibility: Enhanced Focus Indicators */
.convert-btn:focus-visible,
input:focus-visible,
a:focus-visible,
button:focus-visible {
  outline: 3px solid #0077cc;
  outline-offset: 2px;
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 5px #0077cc;
}

/* Enhanced focus for navigation links */
nav a:focus-visible {
  background-color: #0077cc;
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
}

/* Header & Footer */
header, footer {
  background: #f8f8f8;
  padding: 1rem;
  border-bottom: 1px solid #ddd;
}

/* Header styling */
header h1 {
  font-size: clamp(1.5rem, 5vw, 2.2rem);
  color: #1e3a8a;
  margin: 0.5rem 0;
  font-weight: 700;
}

header .subtitle {
  font-size: clamp(0.9rem, 3vw, 1.1rem);
  color: #059669;
  margin: 0.5rem 0 1rem 0;
  font-weight: 500;
}

footer {
  border-top: 1px solid #ddd;
  font-size: 0.9rem;
  color: #555;
}

/* Preview Image */
.preview-image {
  margin: 1.5rem auto;
  max-width: 600px;
  text-align: center;
}

.preview-image img {
  width: 100%;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
}

.preview-image img:hover {
  transform: scale(1.02);
}

/* Navigation */
nav a {
  margin: 0 0.8rem;
  text-decoration: none;
  color: #333;
  font-weight: bold;
  transition: color 0.3s ease;
}

nav a:hover {
  color: #0077cc;
}

/* Calculator Container - Mobile First */
.calculator-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem;
}

/* Converter Cards */
.converter-card {
  background: #ffffff;
  border: 2px solid #e1e5e9;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.converter-card:hover {
  border-color: #0077cc;
  box-shadow: 0 6px 20px rgba(0, 119, 204, 0.15);
  transform: translateY(-2px);
}

/* Converter Titles */
.converter-title {
  font-size: clamp(1.2rem, 4vw, 1.5rem);
  font-weight: 700;
  text-align: center;
  margin: 0 0 1.5rem 0;
  color: #1e3a8a;
  letter-spacing: 0.5px;
}

/* Input Groups */
.input-group {
  position: relative;
  margin-bottom: 1.5rem;
}

.input-group label {
  display: block;
  font-size: clamp(0.9rem, 3vw, 1rem);
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #374151;
}

/* Input Styling */
.input-group input {
  width: 100%;
  font-size: clamp(1.1rem, 4vw, 1.3rem);
  padding: 1rem 3.5rem 1rem 1rem;
  border: 2px solid #d1d5db;
  border-radius: 12px;
  background: #f9fafb;
  transition: all 0.3s ease;
  min-height: 44px; /* Accessibility: Minimum touch target */
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}

.input-group input:focus {
  outline: none;
  border-color: #0077cc;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(0, 119, 204, 0.1);
}

/* Enhanced focus for accessibility */
.input-group input:focus-visible {
  outline: 3px solid #0077cc;
  outline-offset: 2px;
  border-color: #0077cc;
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 5px #0077cc;
}

/* Error state styling */
.input-group input[aria-invalid="true"] {
  border-color: #dc2626;
  background-color: #fef2f2;
}

.input-group input[aria-invalid="true"]:focus {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

/* Currency Labels */
.currency-label {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  margin-top: 1.25rem; /* Account for label height */
  font-weight: 700;
  color: #6b7280;
  font-size: clamp(0.9rem, 3vw, 1rem);
  pointer-events: none;
}

/* Convert Buttons */
.convert-btn {
  width: 100%;
  font-size: clamp(1rem, 4vw, 1.2rem);
  font-weight: 700;
  padding: 1.2rem;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  min-height: 48px;
  min-width: 48px; /* Accessibility: Minimum touch target */
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

/* Button accessibility improvements */
.convert-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.convert-btn:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 2px;
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 5px #0077cc, 0 4px 16px rgba(0, 119, 204, 0.3);
}

.eur-btn {
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  color: white;
}

.eur-btn:hover, .eur-btn:focus {
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(30, 64, 175, 0.3);
}

.bgn-btn {
  background: linear-gradient(135deg, #059669, #10b981);
  color: white;
}

.bgn-btn:hover, .bgn-btn:focus {
  background: linear-gradient(135deg, #047857, #059669);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(5, 150, 105, 0.3);
}

.convert-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

/* Loading state for buttons */
.convert-btn.loading {
  opacity: 0.8;
  cursor: wait;
}

button:active {
  background: #004080;
  transform: translateY(1px);
}

/* Mobile-optimized select dropdown */
select {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  background-size: 1rem;
  padding-right: 2.5rem;
}

/* Results Styling */
.result {
  font-size: clamp(1.3rem, 5vw, 1.8rem);
  font-weight: 700;
  text-align: center;
  padding: 1rem;
  border-radius: 12px;
  margin-top: 1rem;
  min-height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.result.success {
  background: linear-gradient(135deg, #dcfdf4, #a7f3d0);
  color: #065f46;
  border-color: #10b981;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.result.error {
  background: linear-gradient(135deg, #fef2f2, #fecaca);
  color: #991b1b;
  border-color: #ef4444;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

/* Desktop Layout */
@media (min-width: 768px) {
  .calculator-container {
    flex-direction: row;
    gap: 2rem;
    padding: 2rem;
  }
  
  .converter-card {
    flex: 1;
    padding: 2rem;
  }
  
  .converter-title {
    font-size: 1.6rem;
  }
  
  .result {
    font-size: 1.8rem;
  }
}

/* Sections */
section {
  padding: 1rem;
  border-bottom: 1px solid #ddd;
}

/* FAQ Section */
.faq-section {
  max-width: 800px;
  margin: 2rem auto;
  padding: 2rem 1rem;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.faq-section h2 {
  text-align: center;
  color: #1a4b7a;
  margin-bottom: 2rem;
  font-size: clamp(1.5rem, 4vw, 2rem);
}

.faq-item {
  margin-bottom: 1.5rem;
  padding: 1rem;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  transition: box-shadow 0.3s ease;
}

.faq-item:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.faq-item h3 {
  color: #1a4b7a;
  margin-bottom: 0.5rem;
  font-size: clamp(1rem, 3vw, 1.2rem);
  line-height: 1.4;
}

.faq-item p {
  color: #555;
  margin: 0;
  line-height: 1.6;
}

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

/* Cookie Consent Banner */
.cookie-consent {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(26, 75, 122, 0.95);
  color: white;
  padding: 1rem;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  backdrop-filter: blur(5px);
}

.cookie-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.cookie-content p {
  margin: 0;
  flex: 1;
  font-size: 0.9rem;
  line-height: 1.4;
}

.cookie-buttons {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.cookie-buttons button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 0.3s ease;
  margin: 0;
  width: auto;
  display: inline-block;
}

.accept-btn {
  background: #28a745;
  color: white;
}

.accept-btn:hover {
  background: #218838;
}

.decline-btn {
  background: #6c757d;
  color: white;
}

.decline-btn:hover {
  background: #5a6268;
}

/* Mobile responsiveness for cookie banner */
@media (max-width: 767px) {
  .cookie-content {
    flex-direction: column;
    text-align: center;
  }
  
  .cookie-buttons {
    justify-content: center;
    width: 100%;
  }
  
  .cookie-buttons button {
    flex: 1;
    max-width: 120px;
  }
}

/* Mobile-first adjustments */
@media (min-width: 768px) {
  nav a {
    margin: 0 1.2rem;
  }
  
  .preview-image {
    max-width: 800px;
  }
  
  .faq-section {
    padding: 3rem 2rem;
  }
  .faq-item {
    padding: 1.5rem;
  }
}

/* Additional mobile optimizations */
@media (max-width: 767px) {
  body {
    padding: 0;
    margin: 0;
  }
  
  header {
    padding: 1rem 0.5rem;
  }
  
  h1 {
    font-size: clamp(1.5rem, 6vw, 2.5rem);
    margin: 0.5rem 0;
    line-height: 1.2;
  }
  
  nav a {
    margin: 0 0.5rem;
    padding: 0.5rem;
    font-size: 1rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    text-decoration: none;
  }
  
  nav a:active {
    background: rgba(0, 119, 204, 0.1);
    border-radius: 4px;
  }
  
  .preview-image {
    margin: 1rem 0.5rem;
    max-width: calc(100% - 1rem);
  }
  
  .preview-image img {
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }
  
  main {
    padding: 1rem 0.5rem;
  }
  
  input, select, button {
    width: 100%;
    margin: 0.75rem 0;
    font-size: 1.1rem;
    padding: 1rem;
  }
  
  .result {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
  }
  
  .faq-section {
    margin: 0.5rem;
    padding: 1rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  }
  
  .faq-item {
    padding: 1rem;
    margin-bottom: 0.75rem;
    border-radius: 6px;
  }
  
  .faq-item h3 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
  }
  
  .faq-item p {
    font-size: 1rem;
    line-height: 1.5;
  }
  
  footer {
    padding: 1rem 0.5rem;
    font-size: 0.85rem;
  }
}