/**
 * Cruise Ship Tabs Styling
 * Following Drupal CSS coding standards
 */

/* Bootstrap Nav Base Styles (since full Bootstrap CSS is not loaded) */
.nav {
  display: flex;
  flex-wrap: wrap;
  padding-left: 0;
  margin-bottom: 0;
  list-style: none;
}

.nav-tabs {
  border-bottom: 1px solid #dee2e6;
}

.nav-tabs .nav-item {
  margin-bottom: -1px;
}

.nav-tabs .nav-link {
  display: block;
  padding: 0.5rem 1rem;
  margin-bottom: 0;
  background: none;
  border: 1px solid transparent;
  border-top-left-radius: 0.25rem;
  border-top-right-radius: 0.25rem;
}

.nav-tabs .nav-link:hover,
.nav-tabs .nav-link:focus {
  border-color: #e9ecef #e9ecef #dee2e6;
  isolation: isolate;
}

.nav-tabs .nav-link.active {
  color: #495057;
  background-color: #fff;
  border-color: #dee2e6 #dee2e6 #fff;
}

/* Tab visibility - more specific selectors */
.tab-content .tab-pane {
  display: none !important;
  opacity: 0;
  visibility: hidden;
  position: absolute;
  left: -9999px;
}

.tab-content .tab-pane.show {
  display: block !important;
  opacity: 1;
  visibility: visible;
  position: relative;
  left: 0;
}

.tab-content .tab-pane.active {
  display: block !important;
  opacity: 1;
  visibility: visible;
  position: relative;
  left: 0;
}

/* Bootstrap fade animation */
.fade {
  transition: opacity 0.15s linear;
}

.fade:not(.show) {
  opacity: 0;
}

/* Hide standalone gallery since it's now in tabs */
.node--type-cruise-ship .cruise-ship-gallery:not(.in-tab) {
  display: none !important;
}

/* Custom Cruise Ship Styles */
.cruise-ship-tabs-wrapper {
  margin: 2rem 0;
}

.cruise-ship-tabs-wrapper .nav-tabs {
  border-bottom: 2px solid #dee2e6;
  margin-bottom: 0;
}

.cruise-ship-tabs-wrapper .nav-tabs .nav-item {
  margin-bottom: -2px;
}

.cruise-ship-tabs-wrapper .nav-tabs .nav-link {
  color: #495057;
  background-color: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  padding: 0.75rem 1.25rem;
  font-weight: 500;
  transition: all 0.3s ease;
  cursor: pointer;
}

.cruise-ship-tabs-wrapper .nav-tabs .nav-link:hover,
.cruise-ship-tabs-wrapper .nav-tabs .nav-link:focus {
  border-color: #dee2e6 #dee2e6 transparent;
  background-color: #f8f9fa;
  outline: none;
}

.cruise-ship-tabs-wrapper .nav-tabs .nav-link.active {
  color: #0066cc;
  background-color: #fff;
  border-color: #dee2e6 #dee2e6 #fff;
  border-bottom: 2px solid #fff;
  font-weight: 600;
}

.cruise-ship-tabs-wrapper .tab-content {
  background-color: #fff;
  padding: 1.5rem;
  border: 1px solid #dee2e6;
  border-top: none;
  min-height: 300px;
}

.cruise-ship-tabs-wrapper .tab-pane {
  animation: fadeIn 0.3s ease-in;
}

.cruise-ship-tabs-wrapper .tab-panel-content {
  max-width: 100%;
  overflow-x: auto;
}

/* Ship Specifications Styling - Professional Card Layout */
.ship-specifications {
  margin: 2rem 0;
  padding: 2rem;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.ship-specifications h3 {
  margin: 0 0 1.5rem 0;
  color: #1e40af;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ship-specifications h3::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 1.5rem;
  background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%);
  border-radius: 2px;
}

.ship-specifications .specs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.ship-specifications .spec-item {
  background: #ffffff;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  border: 1px solid #e5e7eb;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.ship-specifications .spec-item:hover {
  border-color: #3b82f6;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
  transform: translateY(-1px);
}

.ship-specifications .spec-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
}

.ship-specifications .spec-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.2;
}

/* Responsive adjustments for specifications */
@media (max-width: 640px) {
  .ship-specifications {
    padding: 1.25rem;
    margin: 1rem 0;
  }

  .ship-specifications .specs-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .ship-specifications .spec-item {
    padding: 0.875rem 1rem;
  }

  .ship-specifications .spec-value {
    font-size: 1.1rem;
  }
}

/* Legacy support for old dl/dt/dd structure */
.ship-specifications .specs-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.ship-specifications .specs-list li {
  background: #ffffff;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  border: 1px solid #e5e7eb;
}

.ship-specifications dt {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 0.375rem;
}

.ship-specifications dd {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
}

/* Hide empty dd elements */
.ship-specifications dd:empty {
  display: none;
}

.ship-specifications dd:empty + dt,
.ship-specifications li:has(dd:empty) {
  display: none;
}

/* Card Grid Layout for Tab Content */
.tab-panel-content .field__items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1.5rem;
  padding: 1rem 0;
}

/* Card styling for each paragraph item */
.mt-collapse-item,
.mt-highlight-item {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  max-height: 600px;
}

.mt-collapse-item:hover,
.mt-highlight-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Expanded state for read more */
.mt-collapse-item.expanded,
.mt-highlight-item.expanded {
  max-height: none;
}

/* Image at top of card - larger with better aspect ratio */
.mt-collapse-image,
.mt-highlight-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #f5f5f5;
  position: relative;
}

.mt-collapse-image img,
.mt-highlight-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

/* Special handling for Deck Plans and Staterooms - use contain to show full image */
[id="deck-plans"] .mt-collapse-image img,
[id="staterooms"] .mt-collapse-image img {
  object-fit: contain;
  background: white;
}

/* Image credit overlay on hover */
.mt-collapse-image .media,
.mt-highlight-image .media {
  position: relative;
  height: 100%;
}

.mt-collapse-image .media::after,
.mt-highlight-image .media::after {
  content: attr(data-credit);
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  line-height: 1.3;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  max-height: 80px;
  overflow: hidden;
}

.mt-collapse-image:hover .media::after,
.mt-highlight-image:hover .media::after {
  opacity: 1;
}

/* Card content */
.mt-collapse-item .card-content,
.mt-highlight-item .card-content {
  padding: 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Title styling */
.mt-collapse-title,
.mt-highlight-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #0066cc;
  margin: 0 0 0.75rem 0;
}

/* Body text with truncation */
.mt-collapse-body,
.mt-highlight-body,
.listing-description {
  color: #495057;
  line-height: 1.6;
  flex: 1;
  max-height: 120px;
  overflow: hidden;
  position: relative;
  transition: max-height 0.3s ease;
}

.mt-collapse-item.expanded .mt-collapse-body,
.mt-highlight-item.expanded .mt-highlight-body,
.room-listing-item.expanded .listing-description {
  max-height: none;
}

/* Fade effect for truncated text */
.mt-collapse-body::after,
.mt-highlight-body::after,
.listing-description::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(transparent, white);
  pointer-events: none;
}

.mt-collapse-item.expanded .mt-collapse-body::after,
.mt-highlight-item.expanded .mt-highlight-body::after,
.room-listing-item.expanded .listing-description::after {
  display: none;
}

/* Read more button */
.read-more-btn {
  background: none;
  border: none;
  color: #0066cc;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.5rem 0 0 0;
  cursor: pointer;
  text-align: left;
  transition: color 0.2s;
}

.read-more-btn:hover {
  color: #0052a3;
  text-decoration: underline;
}

/* Remove old paragraph styling */
.cruise-ship-tabs-wrapper .paragraph {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

/* Deck Plans - Optimized for Ultra-Wide Images */
#deck-plans .field__items {
  display: flex !important;
  flex-direction: column !important;
  gap: 1.5rem;
}

.deck-plan-item {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: box-shadow 0.3s ease;
}

.deck-plan-item:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.deck-plan-title {
  background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
  color: white;
  padding: 0.875rem 1.25rem;
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.deck-plan-title .field {
  display: inline;
}

.deck-plan-title .field__item {
  display: inline;
}

.deck-plan-content {
  padding: 1rem;
}

.deck-plan-image-wrapper {
  position: relative;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  overflow-x: auto;
  margin-bottom: 1rem;
  cursor: pointer;
  transition: all 0.3s;
  /* Allow horizontal scroll for ultra-wide images */
  max-height: 250px;
}

.deck-plan-image-wrapper:hover {
  border-color: #3b82f6;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.deck-plan-image {
  min-width: 100%;
  width: max-content;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
}

/* Deck plan images - show full width, allow scroll */
.deck-plan-image img {
  height: 230px !important;
  width: auto !important;
  max-width: none !important;
  display: block;
  object-fit: contain;
}

/* Alternative: constrained view that shows the whole image */
.deck-plan-image-wrapper.fit-view {
  overflow: hidden;
  max-height: none;
}

.deck-plan-image-wrapper.fit-view .deck-plan-image {
  width: 100%;
}

.deck-plan-image-wrapper.fit-view img {
  width: 100% !important;
  height: auto !important;
  max-height: 300px;
}

.deck-plan-zoom-hint {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(30, 64, 175, 0.95);
  color: white;
  padding: 0.5rem 0.875rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  opacity: 0.9;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.deck-plan-zoom-hint svg {
  width: 16px;
  height: 16px;
}

.deck-plan-image-wrapper:hover .deck-plan-zoom-hint {
  opacity: 1;
  transform: scale(1.02);
}

/* Scroll hint for wide images */
.deck-plan-image-wrapper::before {
  content: '← Scroll to see full deck →';
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 5;
  white-space: nowrap;
}

.deck-plan-image-wrapper:hover::before {
  opacity: 0.8;
}

.deck-facilities-title {
  color: #475569;
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.deck-plan-description {
  color: #64748b;
  line-height: 1.6;
  font-size: 0.9rem;
}

.deck-plan-description ul {
  columns: 2;
  column-gap: 1.5rem;
  margin: 0;
  padding-left: 1.25rem;
}

.deck-plan-description li {
  margin-bottom: 0.35rem;
  break-inside: avoid;
}

/* Responsive adjustments for deck plans */
@media (max-width: 768px) {
  .deck-plan-image-wrapper {
    max-height: 180px;
  }

  .deck-plan-image img {
    height: 160px !important;
  }

  .deck-plan-description ul {
    columns: 1;
  }

  .deck-plan-image-wrapper::before {
    font-size: 0.65rem;
    padding: 0.25rem 0.5rem;
  }
}

/* Staterooms - Horizontal Layout */
#staterooms .field__items {
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

#staterooms .mt-collapse-item {
  flex-direction: row;
  max-height: none;
}

#staterooms .mt-collapse-image {
  width: 40%;
  min-width: 300px;
  aspect-ratio: 4 / 3;
  flex-shrink: 0;
}

#staterooms .card-content {
  width: 60%;
  padding: 1.5rem;
}

#staterooms .mt-collapse-body {
  max-height: 200px;
}

/* Room Listing specific styles */
.room-listing-item {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.room-listing-item:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.room-listing-item .listing-container {
  display: flex;
  flex-direction: row;
  align-items: stretch;
}

.room-listing-item .listing-image {
  width: 40%;
  min-width: 280px;
  max-width: 400px;
  overflow: hidden;
  background: #f9f9f9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.room-listing-item .listing-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  max-height: 300px;
}

.room-listing-item .listing-details {
  flex: 1;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.room-listing-item .listing-title {
  font-size: 1.35rem;
  font-weight: 600;
  color: #0066cc;
  margin: 0 0 1rem 0;
  border-bottom: 2px solid #e9ecef;
  padding-bottom: 0.5rem;
}

.room-listing-item .listing-description {
  color: #495057;
  line-height: 1.7;
  max-height: 180px;
  overflow-y: auto;
}

.room-listing-item .listing-description ul {
  margin: 0;
  padding-left: 1.5rem;
}

.room-listing-item .listing-description li {
  margin-bottom: 0.5rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .tab-panel-content .field__items {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  #deck-plans .mt-collapse-item,
  #staterooms .mt-collapse-item {
    flex-direction: column;
  }

  #deck-plans .mt-collapse-image,
  #staterooms .mt-collapse-image {
    width: 100%;
    min-width: unset;
  }

  #deck-plans .card-content,
  #staterooms .card-content {
    width: 100%;
  }
}

/* Responsive design */
@media (max-width: 768px) {
  .cruise-ship-tabs-wrapper .nav-tabs {
    flex-wrap: wrap;
  }

  .cruise-ship-tabs-wrapper .nav-tabs .nav-link {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
  }

  .cruise-ship-tabs-wrapper .tab-content {
    padding: 1rem;
  }
}

/* Deck Plan Lightbox */
.deck-plan-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.deck-plan-lightbox .lightbox-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
}

.deck-plan-lightbox .lightbox-content {
  position: relative;
  max-width: 95vw;
  max-height: 95vh;
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.deck-plan-lightbox .lightbox-content img {
  max-width: 100%;
  max-height: 85vh;
  display: block;
  margin: 0 auto;
}

.deck-plan-lightbox .lightbox-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s;
  z-index: 1;
}

.deck-plan-lightbox .lightbox-close:hover {
  background: rgba(0, 0, 0, 0.9);
}

/* Animation */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}