/* ============================================
   Promotional Ad Components
   Card & Sidebar Ad Styles
   ============================================ */

/* BASE AD VARIABLES */
:root {
  --ad-bg: #ffffff;
  --ad-border: #e2e8f0;
  --ad-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  --ad-shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.12);
  --ad-border-radius: 12px;
  --ad-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --ad-primary: #0284c7;
  --ad-primary-hover: #0369a1;
}

/* ── CARD AD COMPONENT ── */

.ad-card-container {
  background: var(--ad-bg);
  border: 1px solid var(--ad-border);
  border-radius: var(--ad-border-radius);
  overflow: hidden;
  box-shadow: var(--ad-shadow);
  transition: var(--ad-transition);
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 100%;
}

.ad-card-container:hover {
  box-shadow: var(--ad-shadow-hover);
  border-color: var(--ad-primary);
}

/* ── CARD HEADER ── */

.ad-card-header {
  padding: 24px;
  border-bottom: 1px solid var(--ad-border);
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.05) 0%, rgba(99, 102, 241, 0.05) 100%);
}

.ad-card-title {
  margin: 0 0 12px 0;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text, #0f172a);
  line-height: 1.3;
}

.ad-card-subtitle {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary, #475569);
  line-height: 1.5;
}

/* ── IFRAME WRAPPER ── */

.ad-iframe-wrapper {
  flex: 1;
  min-height: 300px;
  background: var(--bg, #fafbfc);
  border-bottom: 1px solid var(--ad-border);
  overflow: hidden;
  position: relative;
}

.ad-iframe-wrapper iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.ad-iframe-loader {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.ad-iframe-wrapper.loading .ad-iframe-loader {
  opacity: 1;
  pointer-events: auto;
}

.ad-loader-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(2, 132, 199, 0.2);
  border-top-color: var(--ad-primary);
  border-radius: 50%;
  animation: spin-loader 0.8s linear infinite;
}

@keyframes spin-loader {
  to { transform: rotate(360deg); }
}

/* ── CARD FEATURES LIST ── */

.ad-card-features {
  padding: 0;
  margin: 0;
  list-style: none;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  min-height: auto;
}

.ad-feature-item {
  padding: 12px 24px;
  font-size: 0.9rem;
  color: var(--text-secondary, #475569);
  line-height: 1.6;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--ad-border);
}

.ad-feature-item:last-child {
  border-bottom: none;
}

.ad-feature-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--ad-primary);
  font-weight: bold;
  margin-top: 2px;
}

.ad-feature-text {
  flex: 1;
  margin: 0;
}

/* ── CARD CTA BUTTON ── */

.ad-card-footer {
  padding: 24px;
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.05) 0%, rgba(99, 102, 241, 0.05) 100%);
  border-top: 1px solid var(--ad-border);
}

.ad-cta-button {
  display: inline-block;
  width: 100%;
  padding: 14px 24px;
  background: linear-gradient(135deg, var(--ad-primary) 0%, #6366f1 100%);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--ad-transition);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
  font-family: inherit;
}

.ad-cta-button:hover {
  background: linear-gradient(135deg, var(--ad-primary-hover) 0%, #4f46e5 100%);
  box-shadow: 0 8px 24px rgba(2, 132, 199, 0.4);
  transform: translateY(-2px);
  color: white;
  text-decoration: none;
}

.ad-cta-button:active {
  transform: translateY(0);
}

.ad-cta-button:focus {
  outline: 2px solid var(--ad-primary);
  outline-offset: 2px;
}

/* ── SIDEBAR AD COMPONENT ── */

.ad-sidebar-container {
  position: fixed;
  top: 100px;
  right: 20px;
  width: 80px;
  min-height: 220px;
  max-height: calc(100vh - 120px);
  background: var(--ad-bg);
  border: 1px solid var(--ad-border);
  border-radius: var(--ad-border-radius);
  box-shadow: var(--ad-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  z-index: 100;
  transition: var(--ad-transition);
}

.ad-sidebar-container.sticky {
  position: sticky;
}

.ad-sidebar-container.left {
  right: auto;
  left: 20px;
}

/* Only show sidebar on desktop */
@media (max-width: 1024px) {
  .ad-sidebar-container {
    display: none;
  }
}

/* ── SIDEBAR AD ITEMS ── */

.ad-sidebar-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.1) 0%, rgba(99, 102, 241, 0.1) 100%);
  border-radius: 8px;
  text-align: center;
  text-decoration: none;
  color: var(--text-secondary, #475569);
  font-size: 0.7rem;
  font-weight: 600;
  transition: var(--ad-transition);
  cursor: pointer;
  border: 1px solid transparent;
  line-height: 1.2;
}

.ad-sidebar-item:hover {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.2) 0%, rgba(99, 102, 241, 0.2) 100%);
  color: var(--ad-primary);
  border-color: var(--ad-primary);
  transform: scale(1.05);
}

.ad-sidebar-item:first-child {
  background: linear-gradient(135deg, var(--ad-primary) 0%, #6366f1 100%);
  color: white;
}

.ad-sidebar-item:first-child:hover {
  background: linear-gradient(135deg, var(--ad-primary-hover) 0%, #4f46e5 100%);
}

/* ── SIDEBAR CLOSE BUTTON (Mobile fallback) ── */

.ad-sidebar-close {
  display: none;
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  background: rgba(0, 0, 0, 0.1);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: inherit;
  font-size: 16px;
  padding: 0;
  align-items: center;
  justify-content: center;
  transition: var(--ad-transition);
}

.ad-sidebar-close:hover {
  background: rgba(0, 0, 0, 0.2);
}

@media (max-width: 1024px) {
  .ad-sidebar-close {
    display: flex;
  }
}

/* ── RESPONSIVE: TABLET & MOBILE ── */

@media (max-width: 768px) {
  .ad-card-container {
    margin-bottom: 24px;
  }

  .ad-card-header {
    padding: 16px;
  }

  .ad-card-title {
    font-size: 1.1rem;
  }

  .ad-iframe-wrapper {
    min-height: 200px;
  }

  .ad-feature-item {
    padding: 10px 16px;
    font-size: 0.85rem;
  }

  .ad-card-footer {
    padding: 16px;
  }

  .ad-cta-button {
    padding: 12px 20px;
    font-size: 0.95rem;
  }
}

@media (max-width: 480px) {
  .ad-card-header {
    padding: 12px;
  }

  .ad-card-title {
    font-size: 1rem;
  }

  .ad-card-subtitle {
    font-size: 0.8rem;
  }

  .ad-iframe-wrapper {
    min-height: 150px;
  }

  .ad-feature-item {
    padding: 8px 12px;
    font-size: 0.75rem;
  }

  .ad-feature-icon {
    width: 14px;
    height: 14px;
  }

  .ad-card-footer {
    padding: 12px;
  }

  .ad-cta-button {
    padding: 10px 16px;
    font-size: 0.9rem;
  }
}

/* ── ACCESSIBILITY ── */

.ad-card-container:focus-within {
  outline: 2px solid var(--ad-primary);
  outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .ad-card-container,
  .ad-sidebar-container,
  .ad-sidebar-item,
  .ad-cta-button,
  .ad-loader-spinner {
    transition: none;
    animation: none;
  }
}

/* Dark mode support (if site has dark mode) */
@media (prefers-color-scheme: dark) {
  :root {
    --ad-bg: #1e293b;
    --ad-border: #334155;
  }

  .ad-card-header,
  .ad-card-footer {
    background: linear-gradient(135deg, rgba(2, 132, 199, 0.15) 0%, rgba(99, 102, 241, 0.15) 100%);
  }

  .ad-iframe-wrapper {
    background: #0f172a;
  }
}

/* ── LAYOUT UTILITIES ── */

/* Full width card grid */
.ad-cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  margin: 48px 0;
}

@media (max-width: 768px) {
  .ad-cards-grid {
    gap: 20px;
    margin: 32px 0;
  }
}

/* Ad section wrapper */
.ad-section {
  position: relative;
  padding: 28px 0;
  border-top: 1px solid var(--ad-border);
  border-bottom: 1px solid var(--ad-border);
}

.ad-section:first-of-type {
  border-top: none;
}

/* ── PRINT SUPPORT ── */

@media print {
  .ad-card-container,
  .ad-sidebar-container {
    display: none !important;
  }
}
