/**
 * TCOST Consent Manager Styles
 * Privacy-compliant cookie consent UI
 * Framework-agnostic, responsive, accessible, dark-mode aware
 */

:root {
  --tcost-primary: #2563eb;
  --tcost-primary-hover: #1d4ed8;
  --tcost-secondary: #64748b;
  --tcost-secondary-hover: #475569;
  --tcost-background: #ffffff;
  --tcost-surface: #f8fafc;
  --tcost-border: #e2e8f0;
  --tcost-text: #0f172a;
  --tcost-text-muted: #64748b;
  --tcost-shadow: rgba(0, 0, 0, 0.1);
  --tcost-overlay: rgba(0, 0, 0, 0.5);
  --tcost-radius: 8px;
  --tcost-radius-lg: 12px;
  --tcost-transition: all 0.2s ease;
}

@media (prefers-color-scheme: dark) {
  :root {
    --tcost-primary: #3b82f6;
    --tcost-primary-hover: #60a5fa;
    --tcost-secondary: #64748b;
    --tcost-secondary-hover: #94a3b8;
    --tcost-background: #0f172a;
    --tcost-surface: #1e293b;
    --tcost-border: #334155;
    --tcost-text: #f1f5f9;
    --tcost-text-muted: #94a3b8;
    --tcost-shadow: rgba(0, 0, 0, 0.3);
    --tcost-overlay: rgba(0, 0, 0, 0.7);
  }
}

/* Reset */
.tcost-consent-banner *,
.tcost-consent-modal *,
.tcost-consent-float * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Banner */
.tcost-consent-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--tcost-background);
  border-top: 1px solid var(--tcost-border);
  box-shadow: 0 -4px 16px var(--tcost-shadow);
  z-index: 999999;
  padding: 20px;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.tcost-consent-banner-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.tcost-consent-banner-text {
  flex: 1;
  min-width: 0;
}

.tcost-consent-banner-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--tcost-text);
  margin-bottom: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.tcost-consent-banner-body {
  font-size: 14px;
  line-height: 1.5;
  color: var(--tcost-text-muted);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.tcost-consent-banner-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* Buttons */
.tcost-consent-btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--tcost-radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--tcost-transition);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  white-space: nowrap;
}

.tcost-consent-btn:focus-visible {
  outline: 2px solid var(--tcost-primary);
  outline-offset: 2px;
}

.tcost-consent-btn-primary {
  background: var(--tcost-primary);
  color: white;
}

.tcost-consent-btn-primary:hover {
  background: var(--tcost-primary-hover);
}

.tcost-consent-btn-secondary {
  background: var(--tcost-surface);
  color: var(--tcost-text);
  border: 1px solid var(--tcost-border);
}

.tcost-consent-btn-secondary:hover {
  background: var(--tcost-border);
}

.tcost-consent-btn-link {
  background: transparent;
  color: var(--tcost-primary);
  text-decoration: underline;
}

.tcost-consent-btn-link:hover {
  color: var(--tcost-primary-hover);
}

/* Modal */
.tcost-consent-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.tcost-consent-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--tcost-overlay);
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.tcost-consent-modal-content {
  position: relative;
  background: var(--tcost-background);
  border-radius: var(--tcost-radius-lg);
  box-shadow: 0 20px 60px var(--tcost-shadow);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: scaleIn 0.2s ease-out;
}

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

.tcost-consent-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--tcost-border);
}

.tcost-consent-modal-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--tcost-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.tcost-consent-modal-close {
  background: transparent;
  border: none;
  font-size: 32px;
  line-height: 1;
  color: var(--tcost-text-muted);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--tcost-radius);
  transition: var(--tcost-transition);
}

.tcost-consent-modal-close:hover {
  background: var(--tcost-surface);
  color: var(--tcost-text);
}

.tcost-consent-modal-close:focus-visible {
  outline: 2px solid var(--tcost-primary);
  outline-offset: 2px;
}

.tcost-consent-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.tcost-consent-category {
  padding: 16px 0;
  border-bottom: 1px solid var(--tcost-border);
}

.tcost-consent-category:last-child {
  border-bottom: none;
}

.tcost-consent-category-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.tcost-consent-category-info {
  flex: 1;
}

.tcost-consent-category-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--tcost-text);
  margin-bottom: 4px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.tcost-consent-category-desc {
  font-size: 14px;
  line-height: 1.5;
  color: var(--tcost-text-muted);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Toggle Switch */
.tcost-consent-toggle {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
  cursor: pointer;
}

.tcost-consent-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.tcost-consent-toggle input:disabled + .tcost-consent-toggle-slider {
  opacity: 0.5;
  cursor: not-allowed;
}

.tcost-consent-toggle-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--tcost-border);
  border-radius: 14px;
  transition: var(--tcost-transition);
}

.tcost-consent-toggle-slider:before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background: white;
  border-radius: 50%;
  transition: var(--tcost-transition);
}

.tcost-consent-toggle input:checked + .tcost-consent-toggle-slider {
  background: var(--tcost-primary);
}

.tcost-consent-toggle input:checked + .tcost-consent-toggle-slider:before {
  transform: translateX(20px);
}

.tcost-consent-toggle input:focus-visible + .tcost-consent-toggle-slider {
  outline: 2px solid var(--tcost-primary);
  outline-offset: 2px;
}

.tcost-consent-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-top: 1px solid var(--tcost-border);
}

.tcost-consent-modal-footer-info {
  font-size: 12px;
  color: var(--tcost-text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.tcost-consent-modal-footer-info a {
  color: var(--tcost-primary);
  text-decoration: none;
}

.tcost-consent-modal-footer-info a:hover {
  text-decoration: underline;
}

/* Floating Icon */
.tcost-consent-float {
  display: none !important;
}

.tcost-consent-float:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  transform: scale(1.05);
}

.tcost-consent-float:focus-visible {
  outline: 2px solid var(--tcost-primary);
  outline-offset: 2px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .tcost-consent-banner-content {
    flex-direction: column;
    align-items: stretch;
  }

  .tcost-consent-banner-actions {
    flex-direction: column;
  }

  .tcost-consent-btn {
    width: 100%;
    text-align: center;
  }

  .tcost-consent-modal-content {
    max-height: 95vh;
    margin: 10px;
  }

  .tcost-consent-modal-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .tcost-consent-modal-footer-info {
    order: 2;
    justify-content: center;
  }

  .tcost-consent-btn-primary {
    order: 1;
    width: 100%;
  }

  .tcost-consent-float {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .tcost-consent-banner {
    border-top: 2px solid var(--tcost-text);
  }

  .tcost-consent-modal-content {
    border: 2px solid var(--tcost-text);
  }

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

/* Reduced Motion */
@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 {
  .tcost-consent-banner,
  .tcost-consent-modal,
  .tcost-consent-float {
    display: none !important;
  }
}
