/* Fix: Sortier-Icons explizit auf polyline ansprechen (mit hoher Spezifität) */
.mobile-sort-section .sort-btn svg polyline {
  stroke: #666 !important;
  stroke-width: 2 !important;
  fill: none !important;
}
.mobile-sort-section .sort-btn.active svg polyline {
  stroke: white !important;
  stroke-width: 2 !important;
  fill: none !important;
}
/* === BASE STYLES === */
:root {
  --primary: #E64C61;
  --secondary: #C75380;
  --text: #111111;
  --background: #FFFFFF;
  --border: #EFEFEF;
  --shadow: rgba(0, 0, 0, 0.05);
}

/* ===== Widget-Container ===== */
#deal-widget {
  font-family: system-ui, sans-serif;
  max-width: 900px;
  margin: auto;
  padding: 1em;
  background: var(--background);
  border-radius: 8px;
  box-shadow: 0 4px 10px var(--shadow);
}

/* ===== Desktop Tabelle ===== */
#deals-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--background);
}

#deals-table thead tr {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
}

#deals-table thead th {
  padding: 16px 24px;
  font-weight: 600;
  font-size: 16px;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 2;
  cursor: pointer;
}

#deals-table tbody tr:hover {
  background-color: #f9f9f9;
}

#deals-table td {
  padding: 16px 24px;
  font-size: 15px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

#deals-table td a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

#deals-table td a:hover {
  color: var(--secondary);
}

/* ===== DataTables Styling ===== */
.dataTables_wrapper {
  margin: 2em 0;
}

.dt-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1em;
}

.dt-header .dataTables_filter label {
  font-size: 0;
}

.dt-header .dataTables_filter input {
  font-size: 1rem;
  padding: 8px 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
  width: 100%;
  max-width: 300px;
  /* id: deals-table-search;  wird von DataTables ignoriert, aber für eigene Felder sinnvoll */
}

.dt-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1em;
  flex-wrap: wrap;
}

/* ===== Modal System ===== */
#iframe-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.iframe-modal-content {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  width: 90%;
  max-width: 800px;
  height: 80%;
  position: relative;
  display: flex;
  flex-direction: column;
}

.iframe-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: none;
  background: #fff;
  color: var(--primary);
  border-radius: 50%;
  font-size: 1.7rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: background 0.2s, color 0.2s;
  z-index: 10;
  padding: 0;
}

.iframe-close-btn:hover {
  background: var(--primary);
  color: #fff;
}

#deal-detail-iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.iframe-loader {
  border: 5px solid #f3f3f3;
  border-top: 5px solid #3498db;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  position: absolute;
  top: 50%;
  left: 50%;
  margin-top: -25px;
  margin-left: -25px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ===== Mobile Cards - Kompakt & Effizient ===== */
.deal-mobile-card {
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 12px;
  margin: 0;
  display: none;
  transition: background-color 0.15s ease;
}

.deal-mobile-card:hover {
  background-color: #f8f9fa;
}

/* Kompakter Titel + Status in einer Zeile */
.deal-mobile-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  gap: 8px;
}

.deal-mobile-title a {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  line-height: 1.2;
  flex: 1;
  min-width: 0; /* Für text-overflow */
}

.deal-mobile-title a:hover {
  color: var(--primary);
}

/* Kompakter Status-Badge */
.deal-status-badge {
  background-color: #f1f3f4;
  color: #5f6368;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Kompakte Daten in 2 Zeilen */
.deal-mobile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  font-size: 0.85rem;
}

.deal-mobile-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.deal-mobile-item strong {
  color: #666;
  font-weight: 500;
  font-size: 0.8rem;
}

.deal-mobile-item span {
  color: var(--text);
  font-weight: 600;
  text-align: right;
}

/* ===== Kompakte Mobile Controls - NUR TOP ===== */
#mobile-controls-top {
  background: var(--background);
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px var(--shadow);
  display: none;
  font-size: 14px;
}

/* Kompakte Suche */
.mobile-search-section {
  margin-bottom: 8px;
}

.mobile-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  height: 32px;
}

.search-icon {
  fill: #666;
  margin-right: 8px;
  flex-shrink: 0;
}

#mobile-search {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  outline: none;
  padding: 0;
  margin: 0;
  height: auto;
  color: var(--text);
}

.clear-search {
  background: none;
  border: none;
  padding: 2px;
  cursor: pointer;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.clear-search:hover {
  background: #f5f5f5;
}

.clear-search svg {
  fill: #999;
}


/* Kompakte Sortierung */
.mobile-sort-section {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.sort-wrapper {
  display: flex;
  align-items: center;
  flex: 1;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  height: 32px;
}

.sort-icon {
  fill: #666;
  margin-right: 8px;
  flex-shrink: 0;
}

#sort-col {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  outline: none;
  padding: 0;
  margin: 0;
  color: var(--text);
  cursor: pointer;
}

.sort-buttons {
  display: flex;
  gap: 4px;
}

.sort-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  background: var(--background);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0;
}

.sort-btn svg {
  display: block;
  margin: auto;
}

.sort-btn:hover {
  background: #f5f5f5;
}

.sort-btn svg {
  fill: none;
  stroke: #666;
  stroke-width: 2;
}

.sort-btn.active {
  background: var(--primary);
  border-color: var(--primary);
}

.sort-btn.active svg {
  fill: none !important;
  stroke: white !important;
  stroke-width: 2 !important;
}

/* Kompakte Pagination */
.mobile-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0;
}

.mobile-page-info {
  display: flex;
  align-items: center;
  font-size: 12px;
  color: #666;
}

.info-icon {
  fill: var(--primary);
  margin-right: 6px;
}

.mobile-nav-buttons {
  display: flex;
  gap: 4px;
}

.mobile-nav-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  background: var(--background);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.mobile-nav-btn:hover:not(:disabled) {
  background: #f5f5f5;
  border-color: var(--primary);
}

.mobile-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.mobile-nav-btn svg {
  fill: #666;
}

/* ===== Responsive Design - KRITISCH! ===== */
@media (max-width: 768px) {
  /* Container für Mobile optimieren */
  #deal-widget {
    margin: 0;
    padding: 12px;
    box-shadow: none;
    border-radius: 0;
    max-width: none;
  }

  /* Desktop verstecken */
  #deals-table thead,
  .dt-header,
  .dt-footer {
    display: none !important;
  }

  /* Mobile Controls zeigen */
  #mobile-controls-top {
    display: block !important;
  }

  /* Desktop-Zeilen verstecken */
  #deals-table tbody tr:not(.deal-mobile-card-row) {
    display: none !important;
  }

  /* Karten-Zeilen */
  .deal-mobile-card-row,
  .deal-mobile-card-row td {
    display: block !important;
    width: 100% !important;
    padding: 0 !important;
    border: none !important;
    margin: 0 !important;
  }

  .deal-mobile-card {
    display: block !important;
    margin: 0 0 8px 0;
  }
}

@media (min-width: 769px) {
  /* Mobile-Elemente auf Desktop verstecken */
  #mobile-controls-top,
  .deal-mobile-card {
    display: none !important;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  #mobile-controls-bottom {
    background: var(--background);
    border-color: var(--border);
    color: var(--text);
  }
  
  #mobile-controls-top {
    background: var(--background);
    border-color: var(--border);
    color: var(--text);
  }
  
  .mobile-search-wrapper,
  .sort-wrapper,
  .sort-btn:not(.active),
  .mobile-nav-btn:not(:disabled) {
    background: var(--background);
    border-color: var(--border);
    color: var(--text);
  }
  
  #mobile-search,
  #sort-col {
    color: var(--text);
  }
}

/* ===== Cleanup ===== */
.deal-card, .deal-title, .deal-meta, .deal-meta-row, .deal-status, .deal-user-msg {
  display: none !important;
}