/* === Embed-specific styles === */

/* Custom alert colors */
.alert-info {
  background-color: #C9E5F8;
  border-color: #9BCAE8;
  color: #1a4d6e;
}
.alert-warning {
  background-color: #FFEFCA;
  border-color: #E5D4A8;
  color: #6e5a1a;
}
.alert-success {
  background-color: #F0E1D3;
  border-color: #D5C5B5;
  color: #5a4a3a;
}
:root {
  --brand-blue: #003F72;
  --brand-blue-dark: #002244;
  --brand-light-blue: #EDF1F9;
  --brand-text: #424242;
  --bs-border-radius: 0;
  --bs-border-radius-sm: 0;
  --bs-border-radius-lg: 0;
  --bs-border-radius-xl: 0;
  --bs-border-radius-xxl: 0;
  --bs-border-radius-pill: 0;
  --bs-btn-border-radius: 0;
  --bs-btn-border-radius-sm: 0;
  --bs-btn-border-radius-lg: 0;
  --bs-input-border-radius: 0;
  --bs-card-border-radius: 0;
}

*, .btn, .btn-group .btn, .form-control, .alert, .table, .table-responsive, .badge, .dropdown-menu {
  border-radius: 0 !important;
}

body {
  background: #ffffff;
  color: var(--brand-text);
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

body, button, input, select, textarea, .btn, .table, .table th, .table td, .alert, label {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

/* Prevent horizontal overflow at root level */
html, body { overflow-x: hidden; }
body { width: 100%; max-width: 100%; }

.embed-container { max-width: 1200px; margin: 0 auto; padding: 8px 12px; }
.filter-bar { background: var(--brand-light-blue); border: 1px solid #e6edf3; border-radius: 0; padding: 8px; }
.table-card { background: #fff; border: 1px solid #e6edf3; border-radius: 0; }

.table th { white-space: nowrap; font-weight: 700; color: var(--brand-blue); }
.table thead a { color: var(--brand-blue); font-weight: 700; text-decoration: none; }
.table thead a:hover, .table thead a:focus { color: var(--brand-blue-dark); text-decoration: none; }

.powered { text-align: center; color: #6c757d; font-size: 12px; margin-top: 10px; }
.powered a { color: var(--brand-blue); text-decoration: none; font-weight: 600; }

/* Blur placeholder for total count until loaded (match index) */
.count-blur {
  display: inline-block;
  filter: blur(4px);
  opacity: 0.6;
}

/* Modal styles for combined booking */
.embed-dialog-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 1050; display: flex; align-items: center; justify-content: center; padding: 12px; }
.embed-dialog { background: #fff; border: 2px solid var(--brand-blue); border-radius: 6px; max-width: 520px; width: 100%; box-shadow: 0 8px 24px rgba(0,0,0,0.25); font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; }
.embed-dialog-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--brand-light-blue); }
.embed-dialog-title { margin: 0; font-weight: 700; font-size: 18px; color: var(--brand-blue); }
.embed-dialog-close { background: #dc3545; color: #fff; border: none; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; font-size: 16px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.embed-dialog-body { padding: 12px 16px; }
.embed-dialog-note { padding: 8px 10px; background: #f8f9fa; border-left: 3px solid var(--brand-blue); font-style: italic; color: #555; margin-bottom: 12px; font-size: 13px; }
.embed-dialog-legs { font-size: 14px; color: #333; margin-bottom: 12px; }
.embed-dialog-legs .leg { margin-bottom: 6px; }
.embed-dialog-legs .times { color: #666; font-size: 12px; }
.embed-dialog-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.dialog-btn { flex: 1; padding: 10px; border: none; border-radius: 4px; color: #fff; cursor: pointer; transition: filter 0.2s ease; font-weight: 600; }
.dialog-btn:focus { outline: none; }
.dialog-btn:hover { filter: brightness(0.95); }
.dialog-btn-primary { background: var(--brand-blue); }
.dialog-btn-secondary { background: #28a745; }
.dialog-btn-skyscanner { background: #ff6b35; flex-basis: 100%; }

@media (max-width: 576px) {
  .embed-dialog { max-width: 92vw; }
  .embed-dialog-buttons { flex-direction: column; }
  .dialog-btn { width: 100%; }
  .dialog-btn-skyscanner { width: 100%; }
}

/* Filter card styles */
.filter-card {
  background: #fff;
  border: 1px solid #e6edf3;
  border-radius: 0;
  margin-bottom: 8px;
}

.filter-content {
  display: flex;
  gap: 16px;
  align-items: flex-end;
}

.filter-item {
  flex: 1;
  min-width: 150px;
}

.filter-label {
  display: block;
  font-weight: 600;
  color: var(--brand-blue);
  margin-bottom: 4px;
  font-size: 14px;
  text-align: center;
}

/* Responsive filter layout */
@media (max-width: 991px) {
  .filter-content {
    flex-direction: column;
    gap: 12px;
  }
  
  .filter-item {
    width: 100%;
  }
}

@media (min-width: 992px) {
  .filter-content {
    justify-content: center;
    align-items: center;
  }
  
  .filter-item {
    flex: 0.9;
    min-width: 80px;
  }
  
  #locationModalBtn {
    min-width: 320px;
    padding: 0.375rem 0.75rem;
  }
}

/* Stack filter controls and add vertical spacing between 576px and 784px */
@media (min-width: 576px) and (max-width: 784px) {
  .filter-bar #filterForm {
    display: flex !important;
    flex-wrap: wrap !important;
    row-gap: 10px !important;
  }
  .filter-bar #filterForm .col-sm-auto,
  .filter-bar #filterForm .col-12.col-sm-auto {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    width: 100% !important;
  }
  /* Add a bit of inner padding to the date input */
  .filter-bar #date.form-control {
    padding: 0.5rem 0.7rem !important;
  }
  /* Center only the Till/Från label on mid-mobile widths */
  .filter-bar #filterForm .justify-content-sm-start { 
    justify-content: center !important; 
  }
  .filter-bar #filterForm .justify-content-sm-start .form-label { 
    display: block; 
    width: 100%; 
    text-align: center !important; 
  }
}

/* Above 784px: vertically center only the Till/Från label column */
@media (min-width: 785px) {
  .filter-bar #filterForm .d-flex.justify-content-sm-start {
    align-self: center !important;
  }
}

/* Remove form-label styling on non-desktop */
@media (max-width: 784px) {
  label[for="country-se"].form-label {
    margin-bottom: 0;
  }
}

/* Increase gap between filter rows for tablet range */
@media (min-width: 785px) and (max-width: 892px) {
  #filterForm {
    row-gap: 0.5rem !important;
  }
}

.custom-scrollbar { height: 6px; background: #e9eff6; border-radius: 0; position: relative; overflow: hidden; }
.scrollbar-thumb { position: absolute; top: 0; height: 6px; background: var(--brand-blue); border-radius: 0; }
.nowrap { white-space: nowrap; }

/* Map link layout (to avoid linked space) */
.nowrap-map-icon { white-space: nowrap; display: inline-flex; align-items: center; gap: 0.1em; }
.map-link-icon { display: inline-flex; align-items: center; padding: 0; margin-right: 0.25em; color: var(--brand-blue) !important; text-decoration: none !important; }
.map-link-icon:hover { color: var(--brand-blue-dark) !important; text-decoration: none !important; }
.map-link-icon i { display: inline-flex; align-items: center; justify-content: center; line-height: 1; }

/* Icon sizes */
.icon-size {
  font-size: 1em;
  display: inline-block;
  text-align: center;
  width: 100%;
}

.icon-size-small {
  font-size: 1.2em;
}

/* Map pin icon size */
.map-icon-size {
  font-size: 1em;
}

/* Clock flag icons */
.clock-flag-icon {
  width: 20px;
  height: 14px;
  object-fit: cover;
  vertical-align: middle;
  margin-right: 4px;
  border-radius: 2px !important;
}

/* Transport SVG icons */
.transport-icon {
  width: 32px;
  height: 32px;
  vertical-align: middle;
}

.transport-icon-small {
  width: 32px;
  height: 32px;
  vertical-align: middle;
}

/* Slightly smaller helicopter emoji */
.helicopter-icon { 
  font-size: 0.9em; 
  display: inline-block; 
  line-height: 1; 
  text-align: center;
}

/* Mobile icon optimizations */
@media (max-width: 576px) {
  /* Prevent rubber-band overscroll on the scrollable table */
  .table-responsive {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: auto !important;
    overscroll-behavior-x: contain;
    overscroll-behavior-y: auto;
    touch-action: auto;
  }
  /* Make first column (transport icons) as narrow as possible but with right padding */
  .table td:first-child {
    width: 36px !important;
    min-width: 36px !important;
    max-width: 36px !important;
    padding: 0.3rem 0.5rem 0.3rem 0.2rem !important;
  }
  
  /* Stack double icons vertically on mobile */
  .icon-size {
    display: block !important;
    text-align: center !important;
    line-height: 0.8 !important;
    white-space: pre-line !important;
    word-break: break-all !important;
  }
  
  /* Fix map icon dot issue on mobile */
  .map-link-icon {
    gap: 0 !important;
    margin-right: 0.15em;
  }
  .map-link-icon i {
    display: inline-block !important;
    line-height: 0 !important;
  }
  .map-link-icon i::before {
    line-height: 1 !important;
    display: inline-block !important;
  }
  .nowrap-map-icon {
    gap: 0.2em;
  }
  .icon-size-small {
    font-size: 1em;
  }
}

/* Remove mobile Bootstrap row negative margins and column paddings to prevent horizontal gap */
@media (max-width: 576px) {
  .row {
    --bs-gutter-x: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  [class^="col-"], [class*=" col-"] {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
}

/* Ensure icons are perfectly centered in their cells */
.table td.text-center {
  text-align: center !important;
  vertical-align: middle !important;
}

/* Center transport icons specifically */
.table td:first-child {
  text-align: center !important;
  vertical-align: middle !important;
  width: 50px;
  min-width: 50px;
}

/* Carrier favicons */
.carrier-favicon {
  width: 26px;
  height: 26px;
  object-fit: contain;
  vertical-align: -2px;
  border-radius: 50%;
}

.carrier-favicon-small {
  width: 20px;
  height: 20px;
  object-fit: contain;
  vertical-align: -2px;
  border-radius: 50%;
}

/* Merged two favicons into one circular icon (left/right halves) */
.carrier-favicon-merged {
  position: relative;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  overflow: hidden;
  display: inline-block;
  vertical-align: -2px;
}

.carrier-favicon-col {
  white-space: nowrap;
  padding: 0 !important;
  padding-left: 4px !important;
  padding-right: 4px !important;
  width: 36px !important;
  max-width: 36px !important;
  text-align: center !important;
  vertical-align: middle !important;
}

/* Per-company icon size tweaks */
img.carrier-favicon[src*="birka_gotland.ico"] { width: 22px; height: 22px; }
img.carrier-favicon[src*="eckerolinjen.ico"] { width: 28px; height: 28px; }
.carrier-favicon-merged img[src*="birka_gotland.ico"] { transform: scale(0.9); }
.carrier-favicon-merged img[src*="eckerolinjen.ico"] { transform: scale(1.04); }
.carrier-favicon-merged img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.carrier-favicon-merged img:first-child {
  clip-path: polygon(0 0, 50% 0, 50% 100%, 0 100%);
}
.carrier-favicon-merged img:last-child {
  clip-path: polygon(50% 0, 100% 0, 100% 100%, 50% 100%);
}

/* Override global border-radius for carrier favicons to make them circular */
.carrier-favicon,
.carrier-favicon-small,
.carrier-favicon-merged,
.carrier-favicon img,
.carrier-favicon-merged img {
  border-radius: 50% !important;
}

/* Match index: tighten spacing before icon column */
.book-cell { padding-right: 4px !important; padding-left: 0 !important; white-space: nowrap; width: 1%; }
.book-cell .btn { margin-right: 0 !important; padding: 0.4rem 0.55rem !important; }

/* Wider carrier column on mobile */
@media (max-width: 576px) {
  .carrier-column { min-width: 150px; width: 150px; }
}

/* Subtle visible row source marker */
.row-src-indicator { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-left: 6px; vertical-align: middle; opacity: 0.5; }
.row-src-indicator.api { background: var(--brand-blue); }
.row-src-indicator.csv { background: #6c757d; }
.row-src-indicator:hover { opacity: 0.8; }

/* Ship column smaller and wrapping in embed */
.ship-column { min-width: 110px; max-width: 140px; white-space: normal !important; word-break: break-word !important; overflow-wrap: anywhere; }

/* Primary buttons styled to brand */
.btn-primary,
.btn-check:checked + .btn-primary,
.btn-primary:active,
.btn-primary:focus { background-color: var(--brand-blue); border-color: var(--brand-blue); color: #fff; }
.btn-primary:hover { background-color: var(--brand-blue-dark); border-color: var(--brand-blue-dark); color: #fff; }
.btn-outline-primary { color: var(--brand-blue); border-color: var(--brand-blue); background-color: transparent; }
.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-check:checked + .btn-outline-primary { background-color: var(--brand-blue); border-color: var(--brand-blue); color: #fff; }
.btn-group .btn { font-weight: 600; }
.book-btn { font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; font-weight: 600; letter-spacing: 0.2px; }
.trips-count { text-align: left; }

/* Footer alignment below the table */
.post-table-footer { display: flex; align-items: flex-start; justify-content: space-between; padding-top: 4px; }
.post-table-footer .footer-left { display: flex; flex-direction: column; align-items: flex-start; flex: 1 1 0; }
.post-table-footer .footer-center { display: flex; align-items: flex-start; justify-content: center; flex: 1 1 0; }
.post-table-footer .footer-right { display: flex; align-items: center; flex: 1 1 0; }
.post-table-footer .footer-left .text-muted.small:first-child { margin-top: 0 !important; }
.post-table-footer .powered { margin-top: 0; }

/* Date input */
.filter-bar #date.form-control { text-align: center; border-color: var(--brand-blue); color: var(--brand-blue); }
.filter-bar #date.form-control:focus { border-color: var(--brand-blue); box-shadow: none; }

/* Mobile */
@media (max-width: 576px) {
  .post-table-footer { flex-direction: column; align-items: stretch; }
  .post-table-footer .footer-left { order: 1; }
  .post-table-footer .footer-center { order: 2; justify-content: center; margin-top: 8px; }
  .post-table-footer .powered { text-align: center; }
}

/* Spinner overlay styling for embed */
.fullscreen-spinner { position: fixed; inset: 0; z-index: 2000; background: rgba(0, 0, 0, 0.5); display: none; align-items: flex-start; justify-content: center; padding-top: 12vh; }
.fullscreen-spinner .spinner-content { text-align: center; background: rgba(255, 255, 255, 0.6); border: 1px solid rgba(255, 255, 255, 0.35); width: 140px; height: 140px; display: flex; align-items: center; justify-content: center; flex-direction: column; box-shadow: 0 8px 20px rgba(0,0,0,0.25); border-radius: 0; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); position: relative; }
.fullscreen-spinner .spinner-content .text-white { color: var(--brand-blue) !important; font-size: 12px; margin-top: 6px !important; }

/* Boat spinner CSS moved into spinner.html to scope styles */

@media (max-width: 576px) {
  .btn-group-mobile-50 > label { width: 50%; }
  .fullscreen-spinner { padding-top: 20vh; }
  .embed-container { padding-left: 0 !important; padding-right: 0 !important; max-width: 100%; }
}


/* Cap table row height on mobile */
@media (max-width: 576px) {
  .table tbody td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 3rem;
  }
}

/* Match index table compact typography on mobile */
@media (max-width: 576px) {
  .table,
  .table th,
  .table td {
    font-size: 0.85rem;
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
    padding-left: 0.3rem;
    padding-right: 0.3rem;
  }
}
