/**
 * DAS TECH SOLUTIONS - ADVERTISEMENT STYLING & RESPONSIVE LAYOUTS
 * Covers Header, Below Navigation, Homepage Sections, Sidebar,
 * In-Article Placements, Mobile Sticky Bottom, and Admin Preview
 */

/* General Ad Slot Container */
.ad-slot-container {
  display: block;
  position: relative;
  text-align: center;
  margin: 20px auto;
  padding: 10px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  overflow: hidden;
  box-sizing: border-box;
  transition: all 0.25s ease;
}

.ad-slot-container:empty {
  display: none !important;
}

.ad-slot-container.ad-has-content {
  background: transparent;
  border: none;
  padding: 6px 0;
}

/* Micro Ad Label */
.ad-label {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 6px;
  text-align: center;
  user-select: none;
}

.ad-label.sponsor-label {
  color: #c8102e;
  font-weight: 700;
}

/* 1. Header Center Placement (Desktop Max 728x90) */
.header-center-ad {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70px;
  max-width: 728px;
  margin: 0 auto;
}

.header-center-ad:empty {
  display: none !important;
}

/* 2. Below Navigation Placement */
.ad-placement-below-nav {
  max-width: 1200px;
  margin: 15px auto;
  min-height: 90px;
}

/* 3. Homepage Top & Middle */
.ad-placement-homepage-top,
.ad-placement-homepage-middle {
  max-width: 100%;
  margin: 25px 0;
  min-height: 90px;
}

/* 4. Between Homepage Sections */
.ad-placement-between-sections {
  margin: 30px 0;
  min-height: 90px;
}

/* 5. Sidebar Advertisement (Square / Half Page 300x250, 300x600) */
.home-sidebar .ad-slot-container,
.ad-placement-sidebar {
  max-width: 336px;
  min-height: 250px;
  margin: 20px auto;
}

/* 6. In-Article Ad Slots (Top, Middle, Bottom) */
.article-ad-top,
.article-ad-middle,
.article-ad-bottom {
  margin: 24px 0;
  min-height: 100px;
  clear: both;
}

.article-ad-middle {
  margin: 30px 0;
  border-top: 1px dashed #e2e8f0;
  border-bottom: 1px dashed #e2e8f0;
  padding: 16px 0;
}

/* 7. Footer Banner Advertisement (Max 970x90 or 728x90) */
.ad-placement-footer {
  max-width: 970px;
  margin: 30px auto 10px;
  min-height: 90px;
}

/* 8. Mobile Sticky Bottom Advertisement */
.mobile-sticky-ad {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: #ffffff;
  box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.15);
  border-top: 1px solid #e2e8f0;
  padding: 6px 12px;
  text-align: center;
  align-items: center;
  justify-content: center;
  min-height: 50px;
}

.mobile-sticky-ad.ad-has-content {
  display: flex;
}

.mobile-sticky-close {
  position: absolute;
  top: -14px;
  right: 12px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #1e293b;
  color: #ffffff;
  border: 2px solid #ffffff;
  font-size: 14px;
  line-height: 22px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  z-index: 10000;
  padding: 0;
}

.mobile-sticky-close:hover {
  background: #c8102e;
}

/* Responsive Banner Creative Wrappers */
.ad-creative-link {
  display: inline-block;
  max-width: 100%;
  text-decoration: none;
}

.ad-creative-img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: 4px;
}

/* Direct Sponsor Creative */
.sponsor-banner-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #ffffff;
  border-radius: 6px;
  padding: 10px;
  border: 1px solid #e2e8f0;
  max-width: 100%;
}

.sponsor-badge-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  width: 100%;
  justify-content: center;
}

.sponsor-logo-img {
  height: 24px;
  width: auto;
  object-fit: contain;
}

.sponsor-name-text {
  font-size: 12px;
  font-weight: 700;
  color: #1e293b;
}

/* Sandboxed Safe Iframe */
.ad-sandboxed-frame {
  width: 100%;
  border: none;
  overflow: hidden;
  display: block;
  margin: 0 auto;
  background: transparent;
}

/* Fallback Inactive Placeholder */
.ad-fallback-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: #f1f5f9;
  border-radius: 6px;
  color: #64748b;
  font-size: 13px;
  gap: 8px;
}

/* Device Visibility Utilities */
@media (max-width: 768px) {
  .ad-hide-mobile {
    display: none !important;
  }
  .header-center-ad {
    margin: 8px auto 0;
  }
}

@media (min-width: 769px) {
  .ad-hide-desktop {
    display: none !important;
  }
  .mobile-sticky-ad {
    display: none !important;
  }
}

/* Admin Dashboard Specific Styles */
.ad-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.ad-stat-card {
  background: #ffffff;
  border-radius: 8px;
  padding: 14px 16px;
  border: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.ad-stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: #c8102e;
}

.ad-stat-card.stat-active::before { background: #059669; }
.ad-stat-card.stat-inactive::before { background: #94a3b8; }
.ad-stat-card.stat-adsense::before { background: #3b82f6; }
.ad-stat-card.stat-banner::before { background: #8b5cf6; }
.ad-stat-card.stat-html::before { background: #f59e0b; }
.ad-stat-card.stat-sponsor::before { background: #ec4899; }

.ad-stat-card .val {
  font-size: 24px;
  font-weight: 800;
  color: #111827;
  line-height: 1.2;
}

.ad-stat-card .lbl {
  font-size: 12.5px;
  color: #64748b;
  margin-top: 4px;
  font-weight: 500;
}

/* Preview Modal Viewport Simulator */
.preview-viewport-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  background: #f1f5f9;
  padding: 6px;
  border-radius: 6px;
  margin-bottom: 16px;
  justify-content: center;
}

.preview-viewport-btn {
  padding: 6px 14px;
  font-size: 12.5px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  color: #475569;
  font-weight: 600;
  transition: all 0.15s;
}

.preview-viewport-btn.active {
  background: #ffffff;
  color: #c8102e;
  border-color: #cbd5e1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.preview-stage-wrap {
  background: #e2e8f0;
  padding: 24px;
  border-radius: 8px;
  display: flex;
  justify-content: center;
  overflow-x: auto;
  min-height: 250px;
}

.preview-stage-frame {
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  padding: 16px;
  transition: width 0.3s ease;
  width: 100%;
  max-width: 100%;
}
