/**
 * Legal Byte Consent Banner Styles
 * DPDP Compliant Cookie Consent UI
 * Compact, non-intrusive design
 *
 * Brand Color Guide:
 * - Primary Blue: #1E3A8A (links, headings, focus states)
 * - Gold/Yellow: #ffd700 (primary action buttons - Accept All, Save Preferences)
 * - Gold Hover: #ffed4e (hover state for gold buttons)
 * - Text Dark: #1a365d (dark text on light backgrounds)
 *
 * Accessibility Standards (WCAG 2.2):
 * - Minimum touch target: 44px × 44px
 * - Minimum font size: 14px (mobile), 13px (desktop)
 * - Color contrast: 4.5:1 for text, 3:1 for UI components
 * - Focus indicators: 2px solid outline
 * - Screen reader support: ARIA labels, roles, and live regions
 */

/* Screen Reader Only - Hidden visually but accessible */
.lb-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;
}

/* Compact Banner at Bottom Right */
.lb-consent-banner {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 99999;
  font-family: 'Josefin Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  padding: 20px;
  max-width: 420px;
  width: calc(100vw - 40px);
  animation: slideInRight 0.3s ease-out;
}

.lb-consent-content {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.lb-consent-icon {
  display: none;
}

.lb-consent-text {
  width: 100%;
}

.lb-consent-text p {
  margin: 0;
  font-size: 14px;
  color: #2d3748;
  line-height: 1.5;
}

.lb-consent-text a {
  color: #1E3A8A;
  text-decoration: underline;
  font-weight: 500;
  font-size: 14px;
}

/* Language Selector - Inline with text */
.lb-language-selector {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.lb-lang-select {
  padding: 6px 28px 6px 10px;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  background: #ffffff;
  font-size: 13px;
  font-family: inherit;
  color: #2d3748;
  cursor: pointer;
  min-height: 36px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23718096' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: all 0.2s ease;
}

.lb-lang-select:hover {
  border-color: #a0aec0;
}

.lb-lang-select:focus {
  outline: 2px solid #1E3A8A;
  outline-offset: 2px;
  border-color: #1E3A8A;
}

.lb-consent-actions {
  display: flex;
  flex-direction: row;
  gap: 8px;
  width: 100%;
}

/* Buttons - Touch Target Minimum 44px height */
.lb-btn {
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
  font-family: inherit;
  white-space: nowrap;
  flex: 1;
  text-align: center;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.lb-btn-primary {
  background: #ffd700;
  color: #1a365d;
  border-color: #ffd700;
  font-weight: 700;
}

.lb-btn-primary:hover {
  background: #ffed4e;
  border-color: #ffed4e;
}

.lb-btn-secondary {
  background: #ffffff;
  color: #4a5568;
  border-color: #cbd5e0;
}

.lb-btn-secondary:hover {
  background: #f7fafc;
  border-color: #a0aec0;
}

.lb-btn-text {
  background: transparent;
  color: #4a5568;
  border: none;
  padding: 10px 16px;
  text-decoration: underline;
}

.lb-btn-text:hover {
  color: #2d3748;
}

/* Settings Modal (shown when user clicks "Manage") */
.lb-consent-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100000;
  padding: 20px;
}

.lb-consent-modal {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 28px;
  font-family: 'Josefin Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  animation: fadeIn 0.3s ease-out;
}

/* Modal Header */
.lb-consent-modal-header {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e2e8f0;
  position: relative;
}

.lb-consent-modal-header h3 {
  font-size: 20px;
  font-weight: 700;
  color: #1a365d;
  margin: 0 0 8px 0;
  padding-right: 40px;
}

.lb-consent-modal-header p {
  font-size: 14px;
  color: #718096;
  line-height: 1.5;
  margin: 0;
}

.lb-modal-close {
  position: absolute;
  top: 0;
  right: 0;
  background: transparent;
  border: none;
  font-size: 28px;
  line-height: 1;
  color: #718096;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  border-radius: 4px;
}

.lb-modal-close:hover {
  color: #2d3748;
  background: #f7fafc;
}

.lb-modal-close:focus {
  outline: 2px solid #1E3A8A;
  outline-offset: 2px;
}

/* Categories */
.lb-consent-categories {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.lb-consent-category {
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px 16px;
  transition: all 0.2s ease;
}

.lb-consent-category:hover {
  border-color: #cbd5e0;
}

.lb-consent-category.lb-consent-essential {
  background: #edf2f7;
  border-color: #cbd5e0;
}

.lb-consent-category-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Checkbox - Touch Target Minimum 44px */
.lb-consent-category input[type="checkbox"] {
  width: 24px;
  height: 24px;
  accent-color: #1E3A8A;
  cursor: pointer;
  flex-shrink: 0;
  /* Increase touch target with padding */
  padding: 10px;
  margin: 0;
}

/* Make the entire category card clickable for better touch targets */
.lb-consent-category label {
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.lb-consent-category.lb-consent-essential input[type="checkbox"] {
  cursor: default;
  opacity: 0.7;
}

.lb-consent-category-label {
  flex: 1;
}

.lb-consent-category-label strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: #2d3748;
  margin-bottom: 4px;
}

.lb-consent-required {
  font-size: 12px;
  color: #718096;
  font-weight: 400;
}

.lb-consent-category-desc {
  margin: 10px 0 0 32px;
  font-size: 13px;
  color: #718096;
  line-height: 1.5;
}

/* Modal Footer */
.lb-consent-modal-footer {
  display: flex;
  gap: 12px;
  padding-top: 20px;
  border-top: 1px solid #e2e8f0;
}

.lb-consent-modal-footer .lb-btn {
  flex: 1;
}

/* Version text */
.lb-consent-version {
  text-align: center;
  font-size: 11px;
  color: #718096;
  margin: 12px 0 0 0;
}

.lb-consent-version a {
  color: #1E3A8A;
  text-decoration: underline;
  font-size: 11px;
}

/* Mobile Responsive - Enhanced for accessibility */
@media (max-width: 768px) {
  .lb-consent-banner {
    bottom: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
    width: calc(100vw - 20px);
    padding: 14px;
  }

  /* Compact row layout on mobile - text and language selector inline */
  .lb-consent-content {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
  }

  .lb-consent-text {
    flex: 1;
  }

  /* Increased mobile font sizes for readability */
  .lb-consent-text p {
    font-size: 15px;
    line-height: 1.5;
    margin: 0;
  }

  .lb-consent-text a {
    font-size: 15px;
  }

  /* Compact language selector on mobile */
  .lb-language-selector {
    flex-shrink: 0;
  }

  .lb-lang-select {
    padding: 4px 24px 4px 8px;
    min-height: 32px;
    font-size: 12px;
  }

  .lb-consent-actions {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }

  /* First row: Manage and Reject All (50% each) */
  .lb-consent-actions .lb-btn-text,
  .lb-consent-actions .lb-btn-secondary {
    flex: 1 1 calc(50% - 4px);
    min-width: calc(50% - 4px);
  }

  /* Second row: Accept All (full width) */
  .lb-consent-actions .lb-btn-primary {
    flex: 1 1 100%;
    order: 3;
  }

  /* Larger touch targets on mobile - minimum 48px (Android recommendation) */
  .lb-btn {
    min-height: 48px;
    font-size: 15px;
    padding: 14px 20px;
  }

  .lb-consent-categories {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .lb-consent-modal {
    padding: 20px 16px;
    max-height: 90vh;
  }

  .lb-consent-modal-header h3 {
    font-size: 18px;
  }

  .lb-consent-modal-header p {
    font-size: 14px;
    line-height: 1.6;
  }


  /* Larger category text on mobile */
  .lb-consent-category-label strong {
    font-size: 16px;
  }

  .lb-consent-category-desc {
    font-size: 14px;
    line-height: 1.5;
  }

  /* Larger checkboxes on mobile for touch */
  .lb-consent-category input[type="checkbox"] {
    width: 28px;
    height: 28px;
  }

  .lb-consent-modal-footer {
    flex-direction: column;
    gap: 10px;
  }

  .lb-consent-modal-footer .lb-btn {
    min-height: 48px;
  }

  .lb-consent-version {
    font-size: 12px;
    margin-top: 16px;
  }

  .lb-consent-version a {
    font-size: 12px;
  }

  /* Modal close button - larger touch target */
  .lb-modal-close {
    width: 44px;
    height: 44px;
    font-size: 32px;
  }
}

/* Animations */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Focus styles for accessibility */
.lb-btn:focus,
.lb-consent-category input:focus {
  outline: 2px solid #1E3A8A;
  outline-offset: 2px;
}

.lb-consent-text a:focus {
  outline: 2px solid #1E3A8A;
  outline-offset: 2px;
  border-radius: 2px;
}

/* Hidden state */
.lb-hidden {
  display: none !important;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .lb-consent-banner,
  .lb-consent-modal {
    border: 2px solid #000;
  }

  .lb-btn {
    border: 2px solid currentColor;
  }

  .lb-btn-primary {
    background: #ffd700;
    color: #000;
    border-color: #000;
  }

  .lb-consent-category {
    border: 2px solid #000;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .lb-consent-banner,
  .lb-consent-modal,
  .lb-btn,
  .lb-lang-select {
    animation: none;
    transition: none;
  }

  @keyframes slideInRight {
    from, to {
      transform: translateX(0);
      opacity: 1;
    }
  }

  @keyframes fadeIn {
    from, to {
      opacity: 1;
      transform: scale(1);
    }
  }
}

/* Focus-visible for keyboard navigation */
.lb-btn:focus-visible,
.lb-consent-category input:focus-visible,
.lb-lang-select:focus-visible,
.lb-modal-close:focus-visible {
  outline: 3px solid #1E3A8A;
  outline-offset: 2px;
}

/* Skip redundant focus outline for mouse users */
.lb-btn:focus:not(:focus-visible),
.lb-consent-category input:focus:not(:focus-visible),
.lb-lang-select:focus:not(:focus-visible) {
  outline: none;
}

/* Indic Languages - Smaller font sizes (2-4px smaller than English) */
.lb-indic-lang .lb-consent-text p {
  font-size: 12px;
}

.lb-indic-lang .lb-consent-text a {
  font-size: 12px;
}

.lb-indic-lang .lb-btn {
  font-size: 11px;
  padding: 10px 12px;
}

.lb-indic-lang .lb-consent-modal-header p {
  font-size: 12px;
}

.lb-indic-lang .lb-consent-category-label strong {
  font-size: 13px;
}

.lb-indic-lang .lb-consent-category-desc {
  font-size: 11px;
}

.lb-indic-lang .lb-consent-modal-footer .lb-btn {
  font-size: 12px;
  padding: 10px 14px;
}

/* Mobile Indic Languages - slightly smaller but still readable */
@media (max-width: 768px) {
  .lb-indic-lang .lb-consent-text p {
    font-size: 14px;
    line-height: 1.4;
  }

  .lb-indic-lang .lb-consent-text a {
    font-size: 14px;
  }

  .lb-indic-lang .lb-btn {
    font-size: 13px;
    padding: 12px 14px;
  }

  .lb-indic-lang .lb-consent-category-label strong {
    font-size: 14px;
  }

  .lb-indic-lang .lb-consent-category-desc {
    font-size: 12px;
  }
}
