/**
 * Drone Comparison Styles
 */

/* Compare Header */
.compare-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #ed485b;
}

.compare-title {
  font-size: 2rem;
  font-weight: bold;
  margin: 0;
  color: #1b1c21;
}

.compare-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.compare-actions .btn {
  white-space: nowrap;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  transition: all 0.2s ease;
}

/* Toggle Differences — filled theme colour */
.compare-actions #toggle-differences {
  background-color: #ed485b;
  border-color: #ed485b;
  color: #fff;
}

.compare-actions #toggle-differences:hover,
.compare-actions #toggle-differences:focus {
  background-color: #d43d4f;
  border-color: #d43d4f;
  color: #fff;
  box-shadow: 0 2px 8px rgba(237, 72, 91, 0.35);
}

.compare-actions #toggle-differences.active {
  background-color: #1b1c21;
  border-color: #1b1c21;
  color: #fff;
}

.compare-actions #toggle-differences.active:hover {
  background-color: #ed485b;
  border-color: #ed485b;
}

/* Print & Share — outlined theme colour */
.compare-actions #print-compare,
.compare-actions #share-compare {
  background-color: transparent;
  border-color: #ed485b;
  color: #ed485b;
}

.compare-actions #print-compare:hover,
.compare-actions #print-compare:focus,
.compare-actions #share-compare:hover,
.compare-actions #share-compare:focus {
  background-color: #ed485b;
  border-color: #ed485b;
  color: #fff;
  box-shadow: 0 2px 8px rgba(237, 72, 91, 0.35);
}

/* Basic Info Cards */
.compare-basic-info {
  margin-bottom: 3rem;
}

.compare-basic-info .drone-card {
  margin-bottom: 1rem;
}

.compare-basic-info .card {
  height: 100%;
  border: 1px solid #dee2e6;
  transition: box-shadow 0.3s ease;
  border-radius: 8px;
  overflow: hidden;
}

.compare-basic-info .card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.drone-image {
  height: 250px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f9fa;
}

.drone-image.no-image {
  font-size: 5rem;
  color: #ccc;
}

.drone-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.drone-title {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.drone-title a {
  color: #1b1c21;
  text-decoration: none;
  transition: color 0.2s ease;
}

.drone-title a:hover {
  color: #ed485b;
}

.drone-brand,
.drone-price {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.drone-price {
  color: #ed485b;
  font-size: 1.25rem;
  font-weight: bold;
}

.drone-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.drone-actions .btn {
  flex: 1;
}

/* Specifications Table */
.compare-specifications {
  margin-top: 3rem;
}

.section-title {
  font-size: 1.75rem;
  font-weight: bold;
  margin-bottom: 2rem;
  color: #1b1c21;
}

/* Spec Category Sections */
.spec-category-section {
  margin-bottom: 2.5rem;
}

.category-header {
  font-size: 1.1rem;
  font-weight: 700;
  color: #ed485b;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid #f0f0f0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Spec Table Wrapper for Horizontal Scroll */
.spec-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 0;
}

.compare-table {
  margin: 0;
  font-size: 0.9rem;
  border-collapse: collapse;
  min-width: 100%;
}

.compare-table th {
  background: #f8f9fa;
  color: #1b1c21;
  font-weight: 600;
  padding: 1rem;
  border-bottom: 2px solid #dee2e6;
  position: relative;
}

.compare-table th.spec-label {
  width: 30%;
  min-width: 200px;
  background: #fff;
  position: sticky;
  left: 0;
  z-index: 10;
  border-right: 2px solid #f0f0f0;
}

.compare-table th.drone-col {
  width: 35%;
  min-width: 200px;
  background: #ed485b;
  color: white;
  text-align: center;
}

.compare-table tbody tr {
  border-bottom: 1px solid #f0f0f0;
  transition: background-color 0.2s ease;
}

.compare-table tbody tr:hover {
  background-color: #f9f9f9;
}

.compare-table tbody tr.has-difference {
  background: #fff9e6;
}

.compare-table tbody tr.has-difference td.spec-value {
  border-left: 3px solid #ffc107;
  font-weight: 500;
}

.compare-table td {
  padding: 1rem;
  vertical-align: middle;
  border: none;
}

.compare-table td.spec-label {
  font-weight: 500;
  background: #fff;
  position: sticky;
  left: 0;
  z-index: 9;
  border-right: 2px solid #f0f0f0;
}

.compare-table td.spec-value {
  text-align: center;
  background: #fff;
}

.compare-table td .text-muted {
  color: #999;
  font-style: italic;
}

/* Compare Footer */
.compare-footer {
  padding: 2rem 0;
  margin-top: 3rem;
  border-top: 1px solid #dee2e6;
}

.compare-footer .btn {
  margin: 0 0.5rem;
}

/* Floating Compare Bar (for listing pages) */
.compare-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  padding: 0.75rem 0;
  z-index: 1000;
  border-top: 3px solid #ed485b;
}

.compare-bar-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

/* Drone slots */
.compare-slots {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.compare-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 150px;
  max-width: 220px;
  padding: 0.35rem 2rem 0.35rem 0.75rem;
  border: 2px dashed #ccc;
  border-radius: 6px;
  background: #f8f9fa;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.compare-slot.filled {
  border-style: solid;
  border-color: #ed485b;
  background: #fff5f6;
}

.slot-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #999;
  letter-spacing: 0.05em;
  line-height: 1;
  margin-bottom: 0.15rem;
}

.slot-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: #aaa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
  line-height: 1.2;
}

.compare-slot.filled .slot-name {
  color: #1b1c21;
}

.slot-remove {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #aaa;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  display: none;
}

.slot-remove:hover {
  color: #ed485b;
}

.compare-vs {
  font-size: 0.75rem;
  font-weight: 700;
  color: #6c757d;
  text-transform: uppercase;
  flex-shrink: 0;
  letter-spacing: 0.05em;
}

/* Actions area */
.compare-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.compare-bar-alert {
  display: none;
  color: #dc3545;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
}

.compare-bar .btn-compare {
  background: #ed485b;
  border-color: #ed485b;
  color: white;
  padding: 0.5rem 1.5rem;
  white-space: nowrap;
}

.compare-bar .btn-compare:hover {
  background: #d43d54;
  border-color: #d43d54;
}

.compare-bar .btn-compare:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #ccc;
  border-color: #ccc;
}

.compare-bar .btn-clear {
  color: #6c757d;
  text-decoration: none;
  white-space: nowrap;
}

.compare-bar .btn-clear:hover {
  color: #ed485b;
  text-decoration: underline;
}

/* Compare Checkbox on Cards */
.compare-checkbox-wrapper {
  position: absolute;
  top: 10px;
  right: 10px;
  background: white;
  padding: 0.5rem;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  z-index: 10;
}

.compare-checkbox-wrapper label {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
}

.compare-checkbox-wrapper input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
}

.drone-selectable {
  position: relative;
}

/* Modal Styling */
#addDroneModal .modal-body {
  padding: 1.5rem;
}

#drone-autocomplete {
  border: 2px solid #dee2e6;
  border-radius: 4px;
  padding: 0.75rem;
  font-size: 1rem;
}

#drone-autocomplete:focus {
  border-color: #ed485b;
  outline: none;
  box-shadow: 0 0 0 0.2rem rgba(237, 72, 91, 0.25);
}

#autocomplete-results {
  max-height: 300px;
  overflow-y: auto;
}

#autocomplete-results .list-group-item {
  cursor: pointer;
  transition: background-color 0.2s ease;
}

#autocomplete-results .list-group-item:hover {
  background-color: #f8f9fa;
  color: #ed485b;
}

/* Responsive Design */
@media (max-width: 768px) {
  .compare-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .compare-title {
    font-size: 1.5rem;
  }

  .compare-actions {
    width: 100%;
    flex-direction: column;
  }

  .compare-actions button {
    width: 100%;
  }

  .compare-table {
    font-size: 0.85rem;
  }

  .compare-table th.spec-label,
  .compare-table th.drone-col {
    width: auto;
    font-size: 0.8rem;
    padding: 0.75rem;
  }

  .compare-table td {
    padding: 0.75rem;
  }

  /* Horizontal scroll for table on mobile */
  .spec-table-wrapper {
    overflow-x: auto;
  }

  .compare-table {
    min-width: 500px;
  }

  .drone-image {
    height: 200px;
  }

  .drone-title {
    font-size: 1.25rem;
  }

  .compare-bar-content {
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
  }

  .compare-slots {
    justify-content: center;
  }

  .compare-slot {
    min-width: 120px;
    max-width: 140px;
  }

  .compare-bar-actions {
    justify-content: center;
    flex-wrap: wrap;
  }

  .compare-bar .btn-compare,
  .compare-bar .btn-clear {
    flex: 1;
  }

  .compare-footer .btn {
    display: block;
    width: 100%;
    margin: 0.5rem 0;
  }

  .drone-actions {
    flex-direction: column;
  }

  .drone-actions .btn {
    width: 100%;
  }

  .category-header {
    font-size: 1rem;
  }
}

@media (max-width: 576px) {
  .compare-title {
    font-size: 1.25rem;
  }

  .section-title {
    font-size: 1.25rem;
  }

  .compare-checkbox-wrapper {
    top: 5px;
    right: 5px;
    padding: 0.25rem 0.5rem;
  }

  .compare-checkbox-wrapper label {
    font-size: 0.8rem;
  }

  .compare-table th.spec-label,
  .compare-table td.spec-label {
    min-width: 140px;
  }

  .category-header {
    font-size: 0.95rem;
  }
}

/* Detail page "Add to Compare" button */
.compare-drone-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}

#detail-compare-btn {
  border-color: #ed485b;
  color: #ed485b;
  font-size: 0.95rem;
  padding: 0.5rem 1.25rem;
  transition: all 0.2s ease;
}

#detail-compare-btn:hover {
  background-color: #ed485b;
  color: #fff;
}

#detail-compare-btn.added {
  background-color: #28a745;
  border-color: #28a745;
  color: #fff;
  cursor: default;
}

.compare-detail-msg {
  display: none;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.2rem 0;
}

.compare-detail-msg.msg-success { color: #28a745; }
.compare-detail-msg.msg-warning { color: #e67e22; }
.compare-detail-msg.msg-info    { color: #3498db; }

/* Print Styles */
@media print {
  .compare-header .compare-actions,
  .compare-footer,
  .compare-bar,
  .compare-checkbox-wrapper,
  #add-another-drone {
    display: none !important;
  }

  .spec-category-section {
    page-break-inside: avoid;
  }

  .compare-table {
    page-break-inside: avoid;
  }

  .drone-card {
    page-break-inside: avoid;
  }

  body {
    background: white;
  }

  .compare-header {
    border-bottom: 2px solid #000;
  }
}
