/**
 * Soda Download Control - Frontend Styles
 * Premium, Responsive (Mobile & Desktop) Button and Format Selector
 */

:root {
  --soda-btn-bg: #0f172a;
  --soda-btn-color: #ffffff;
  --soda-btn-hover-bg: #1e293b;
  --soda-btn-hover-color: #ffffff;
  --soda-btn-radius: 8px;
  --soda-btn-border-width: 0px;
  --soda-btn-border-color: transparent;
  --soda-btn-font-size: 15px;
  --soda-btn-padding: 12px 20px;
  --soda-tooltip-radius: 14px;
}

/* Base Wrapper */
.soda-download-wrapper {
  position: relative;
  display: inline-flex;
  vertical-align: middle;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  box-sizing: border-box;
  opacity: 1 !important;
  visibility: visible !important;
  transition: opacity 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.soda-download-wrapper *,
.soda-download-wrapper *::before,
.soda-download-wrapper *::after {
  box-sizing: border-box;
}

/* Alignment Utilities */
.soda-download-wrapper.soda-align-left {
  display: inline-flex;
}

.soda-download-wrapper.soda-align-center {
  display: flex;
  justify-content: center;
  width: 100%;
}

.soda-download-wrapper.soda-align-right {
  display: flex;
  justify-content: flex-end;
  width: 100%;
}

.soda-download-wrapper.soda-width-full {
  display: flex;
  width: 100%;
}

.soda-download-wrapper.soda-width-full .soda-dl-btn {
  width: 100%;
  justify-content: center;
}

/* ==========================================================================
   Trigger Button
   ========================================================================== */
.soda-download-wrapper .soda-dl-btn,
button.soda-dl-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 10px !important;
  background-color: var(--soda-btn-bg, #0f172a) !important;
  color: var(--soda-btn-color, #ffffff) !important;
  padding: var(--soda-btn-padding, 12px 20px) !important;
  border-radius: var(--soda-btn-radius, 8px) !important;
  border-width: var(--soda-btn-border-width, 0px) !important;
  border-style: solid !important;
  border-color: var(--soda-btn-border-color, transparent) !important;
  font-size: var(--soda-btn-font-size, 15px) !important;
  font-weight: 600 !important;
  line-height: 1.35 !important;
  cursor: pointer !important;
  user-select: none !important;
  touch-action: manipulation !important;
  text-decoration: none !important;
  box-shadow: 0 4px 14px -2px rgba(15, 23, 42, 0.15), 0 2px 6px -1px rgba(15, 23, 42, 0.08) !important;
  outline: none !important;
  transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
              color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.18s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.soda-download-wrapper .soda-dl-btn:hover,
button.soda-dl-btn:hover {
  background-color: var(--soda-btn-hover-bg, #1e293b) !important;
  color: var(--soda-btn-hover-color, #ffffff) !important;
  transform: translateY(-2px);
  box-shadow: 0 8px 22px -3px rgba(15, 23, 42, 0.25) !important;
}

.soda-download-wrapper .soda-dl-btn:active,
button.soda-dl-btn:active {
  transform: translateY(0) scale(0.99);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.15) !important;
}

.soda-download-wrapper .soda-dl-btn:focus-visible,
button.soda-dl-btn:focus-visible {
  outline: 2px solid #3b82f6 !important;
  outline-offset: 3px !important;
}

.soda-download-wrapper .soda-dl-btn .soda-dl-icon,
button.soda-dl-btn .soda-dl-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.soda-download-wrapper .soda-dl-btn svg,
button.soda-dl-btn svg {
  color: inherit !important;
  stroke: currentColor !important;
}

.soda-download-wrapper .soda-dl-btn .soda-dl-icon-chevron,
button.soda-dl-btn .soda-dl-icon-chevron {
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.soda-download-wrapper.is-open .soda-dl-btn .soda-dl-icon-chevron {
  transform: rotate(180deg);
}

.soda-download-wrapper .soda-dl-btn .soda-dl-text,
button.soda-dl-btn .soda-dl-text {
  letter-spacing: -0.01em;
}

/* ==========================================================================
   Desktop Tooltip / Popover
   ========================================================================== */
.soda-dl-tooltip {
  position: absolute;
  z-index: 99999;
  top: calc(100% + 12px);
  left: 0;
  width: 320px;
  max-width: 90vw;
  border-radius: var(--soda-tooltip-radius, 14px);
  padding: 18px;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.35), 0 10px 18px -6px rgba(0, 0, 0, 0.15);
  display: block !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px) scale(0.97);
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.22s;
}

.soda-download-wrapper.is-open .soda-dl-tooltip {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* Desktop placement modifiers */
.soda-dl-tooltip.soda-place-top {
  top: auto;
  bottom: calc(100% + 12px);
  transform: translateY(-8px) scale(0.97);
}

.soda-download-wrapper.is-open .soda-dl-tooltip.soda-place-top {
  transform: translateY(0) scale(1);
}

.soda-dl-tooltip.soda-place-right {
  left: auto;
  right: 0;
}

/* Tooltip Arrow */
.soda-dl-arrow {
  position: absolute;
  top: -6px;
  left: 24px;
  width: 12px;
  height: 12px;
  transform: rotate(45deg);
  background: inherit;
  border-left: inherit;
  border-top: inherit;
  z-index: 1;
}

.soda-dl-tooltip.soda-place-right .soda-dl-arrow {
  left: auto;
  right: 24px;
}

.soda-dl-tooltip.soda-place-top .soda-dl-arrow {
  top: auto;
  bottom: -6px;
  border-left: none;
  border-top: none;
  border-right: inherit;
  border-bottom: inherit;
}

/* ==========================================================================
   Themes: Dark, Light, Glass
   ========================================================================== */
/* Dark Modern (Default) */
.soda-dl-tooltip.soda-theme-dark {
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.soda-dl-tooltip.soda-theme-dark .soda-dl-item {
  background: rgba(255, 255, 255, 0.04);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.soda-dl-tooltip.soda-theme-dark .soda-dl-item:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.16);
}
.soda-dl-tooltip.soda-theme-dark .soda-dl-eyebrow {
  color: #94a3b8;
}
.soda-dl-tooltip.soda-theme-dark .soda-dl-item-file {
  color: #94a3b8;
}
.soda-dl-tooltip.soda-theme-dark .soda-dl-footer {
  color: #64748b;
}
.soda-dl-tooltip.soda-theme-dark .soda-dl-close-btn {
  color: #94a3b8;
}
.soda-dl-tooltip.soda-theme-dark .soda-dl-close-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

/* Light Crisp */
.soda-dl-tooltip.soda-theme-light {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
}
.soda-dl-tooltip.soda-theme-light .soda-dl-item {
  background: #f8fafc;
  color: #0f172a;
  border: 1px solid #edf2f7;
}
.soda-dl-tooltip.soda-theme-light .soda-dl-item:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}
.soda-dl-tooltip.soda-theme-light .soda-dl-eyebrow {
  color: #64748b;
}
.soda-dl-tooltip.soda-theme-light .soda-dl-item-file {
  color: #64748b;
}
.soda-dl-tooltip.soda-theme-light .soda-dl-footer {
  color: #94a3b8;
}
.soda-dl-tooltip.soda-theme-light .soda-dl-close-btn {
  color: #64748b;
}
.soda-dl-tooltip.soda-theme-light .soda-dl-close-btn:hover {
  color: #0f172a;
  background: #f1f5f9;
}

/* Glassmorphic */
.soda-dl-tooltip.soda-theme-glass {
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.soda-dl-tooltip.soda-theme-glass .soda-dl-item {
  background: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.soda-dl-tooltip.soda-theme-glass .soda-dl-item:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
}
.soda-dl-tooltip.soda-theme-glass .soda-dl-eyebrow {
  color: #cbd5e1;
}
.soda-dl-tooltip.soda-theme-glass .soda-dl-item-file {
  color: #cbd5e1;
}
.soda-dl-tooltip.soda-theme-glass .soda-dl-footer {
  color: #94a3b8;
}
.soda-dl-tooltip.soda-theme-glass .soda-dl-close-btn {
  color: #cbd5e1;
}

/* ==========================================================================
   Header & Elements inside Tooltip
   ========================================================================== */
.soda-dl-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.soda-dl-eyebrow {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 3px;
}

.soda-dl-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.soda-dl-close-btn {
  display: none; /* hidden on desktop */
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 6px !important;
  border-radius: 6px !important;
  cursor: pointer !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.15s ease;
}

/* ==========================================================================
   Options List & Items
   ========================================================================== */
.soda-dl-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.soda-dl-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  text-decoration: none;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  outline: none;
}

.soda-dl-item:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 1px;
}

.soda-dl-item:hover .soda-dl-item-action {
  transform: translateY(2px);
  color: #38bdf8;
}

/* Badge Format Indicators */
.soda-dl-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #ffffff;
  flex-shrink: 0;
}

.soda-dl-badge.badge-svg {
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
}

.soda-dl-badge.badge-png {
  background: linear-gradient(135deg, #10b981, #059669);
}

.soda-dl-badge.badge-jpg,
.soda-dl-badge.badge-jpeg {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.soda-dl-badge.badge-pdf {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

.soda-dl-badge.badge-eps,
.soda-dl-badge.badge-ai {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

.soda-dl-badge.badge-zip {
  background: linear-gradient(135deg, #06b6d4, #0891b2);
}

.soda-dl-badge.badge-webp {
  background: linear-gradient(135deg, #14b8a6, #0d9488);
}

.soda-dl-badge.badge-file,
.soda-dl-badge.badge-otro {
  background: linear-gradient(135deg, #64748b, #475569);
}

/* Item details */
.soda-dl-item-info {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-width: 0;
}

.soda-dl-item-label {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.soda-dl-item-file {
  font-size: 11px;
  line-height: 1.3;
  margin-top: 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Action Icon */
.soda-dl-item-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  opacity: 0.75;
  flex-shrink: 0;
  transition: transform 0.18s ease, color 0.18s ease;
}

/* Footer note */
.soda-dl-footer {
  font-size: 11px;
  text-align: center;
  letter-spacing: 0.01em;
  padding-top: 6px;
  border-top: 1px solid rgba(148, 163, 184, 0.15);
}

/* Mobile backdrop overlay */
.soda-dl-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 99998;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s;
}

.soda-download-wrapper.is-open .soda-dl-backdrop {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ==========================================================================
   Responsive Mobile Optimization (Smartphones & Tablets < 640px)
   ========================================================================== */
@media (max-width: 640px) {
  /* Ensure comfortable tap target on mobile */
  .soda-dl-btn {
    min-height: 48px;
    padding: 13px 22px;
    font-size: 16px;
    width: 100%;
  }

  .soda-download-wrapper {
    width: 100%;
  }

  /* Transform Tooltip into an elegant Mobile Bottom Sheet */
  .soda-dl-tooltip {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 22px 22px 0 0 !important;
    padding: 22px 20px calc(24px + env(safe-area-inset-bottom, 0px)) 20px;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.45);
    transform: translateY(105%) !important;
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s !important;
    border-bottom: none !important;
  }

  .soda-download-wrapper.is-open .soda-dl-tooltip {
    transform: translateY(0) !important;
  }

  /* Hide desktop arrow pointer on mobile */
  .soda-dl-arrow {
    display: none !important;
  }

  /* Show mobile close button */
  .soda-dl-close-btn {
    display: inline-flex;
    min-width: 36px;
    min-height: 36px;
  }

  /* Touch-friendly larger items */
  .soda-dl-item {
    min-height: 52px;
    padding: 12px 14px;
  }

  .soda-dl-item-label {
    font-size: 14.5px;
  }

  .soda-dl-item-file {
    font-size: 11.5px;
  }

  .soda-dl-badge {
    min-width: 48px;
    height: 26px;
    font-size: 11.5px;
  }
}
