/**
 * Frontend styles for OSI Google Maps (LG-GMAPS)
 */

:root {
  --gmaps-height: 550px;
  --osi-cream-bg: #f7f3ed;
  --osi-cream-hover: #efe7db;
  --osi-cream-active: #eadecf;
  --osi-border-cream: #eadecf;
  --osi-shadow-soft:
    0 10px 30px -5px rgba(74, 55, 40, 0.08),
    0 4px 12px -2px rgba(74, 55, 40, 0.05);
}

/* Main Wrapper */
.osi-google-maps {
  position: relative;
  height: var(--gmaps-height, 550px);
  min-height: 550px;
  width: 100%;
  overflow: hidden;
  background-color: #f8fafc;
  box-shadow: var(--osi-shadow-soft);
  box-sizing: border-box;
}

.osi-google-maps * {
  box-sizing: border-box;
}

/* Map Widget & Canvas */
.osi-google-maps-widget {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

.osi-gmaps-map-canvas {
  width: 100%;
  height: 100%;
  background-color: #e5e7eb;
}

/* Navigation Overlay Bar (Floating on top-left of Map) */
.osi-google-maps-nav {
  position: absolute;
  top: 20px;
  left: 20px;
  bottom: 20px;
  z-index: 999;
  display: flex;
  flex-direction: row;
  gap: 1rem;
  pointer-events: none;
}

/* Floating Expand / Open Menu Pill Button (Shown when menu is minimized) */
.osi-gmaps-menu-expand-btn {
  background-color: var(--osi-cream-bg);
  border: 1px solid rgba(234, 222, 207, 0.8);
  border-radius: 9999px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--osi-shadow-soft);
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  align-self: flex-start;
  z-index: 10;
  outline: none;
  font-family: inherit;
}

.osi-gmaps-menu-expand-btn:hover,
.osi-gmaps-menu-expand-btn:focus {
  background-color: var(--osi-cream-hover);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px -4px rgba(74, 55, 40, 0.14);
}

.osi-gmaps-menu-expand-btn .osi-icon-pin {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke: currentColor;
}

.osi-gmaps-menu-expand-btn .osi-gmaps-menu-expand-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.osi-gmaps-menu-expand-btn .osi-icon-chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  stroke: currentColor;
  transition: transform 0.2s ease;
}

.osi-gmaps-menu-expand-btn:hover .osi-icon-chevron {
  transform: translateX(2px);
}

/* Left Navigation Menu Card */
.osi-google-maps-nav-menu {
  background-color: var(--osi-cream-bg);
  border-radius: 1.25rem;
  padding: 16px;
  width: 290px;
  display: flex;
  flex-direction: column;
  align-self: start;
  height: auto;
  max-height: 100%;
  overflow: hidden;
  transition:
    max-height 0.3s ease,
    width 0.3s ease,
    opacity 0.3s ease,
    transform 0.3s ease,
    box-shadow 0.3s ease;
  box-shadow: var(--osi-shadow-soft);
  pointer-events: auto;
  border: 1px solid rgba(234, 222, 207, 0.6);
}

.osi-google-maps-nav-menu.active {
  width: 290px;
}

.osi-google-maps-nav.is-menu-collapsed .osi-google-maps-nav-menu {
  display: none !important;
}

.osi-google-maps-nav.is-menu-collapsed #osi-gmaps-menu-expand-btn {
  display: inline-flex !important;
}

/* Active Clinic State: Hide location list menu and locations expand button on ALL viewports */
.osi-google-maps-nav.has-active-clinic .osi-google-maps-nav-menu,
.osi-google-maps-nav.has-active-clinic #osi-gmaps-menu-expand-btn {
  display: none !important;
}

/* Marker Bounce Animation */
@keyframes osiMarkerBounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-12px);
  }
}

.osi-marker-bounce {
  animation: osiMarkerBounce 0.35s ease 2;
}

/* Navigation Header */
.osi-google-maps-nav-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 2px 10px 2px;
  border-bottom: 1px solid var(--osi-border-cream);
  margin-bottom: 4px;
}

.osi-google-maps-nav-menu-header-title {
  flex: 1 1 0;
  font-size: 15px;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.osi-google-maps-nav-menu-header-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  background-color: transparent;
  cursor: pointer;
  border: none;
  outline: none;
  border-radius: 50%;
  transition:
    background-color 0.2s ease,
    transform 0.2s ease;
}

.osi-google-maps-nav-menu-header-toggle:hover,
.osi-google-maps-nav-menu-header-toggle:focus {
  background-color: var(--osi-cream-hover);
  transform: scale(1.08);
}

.osi-google-maps-nav-menu-header-toggle .osi-icon-toggle {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  transition: transform 0.2s ease;
}

/* Search Box */
.osi-gmaps-search-box {
  position: relative;
  margin-top: 10px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
}

.osi-gmaps-search-icon {
  position: absolute;
  left: 12px;
  display: flex;
  align-items: center;
  pointer-events: none;
  opacity: 0.6;
}

.osi-gmaps-search-icon svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
}

.osi-gmaps-search-box input[type="text"] {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--osi-border-cream);
  border-radius: 9999px;
  background-color: #ffffff;
  font-size: 13px;
  transition: all 0.2s ease;
}

.osi-gmaps-search-box input[type="text"]:focus {
  outline: none;
  border-color: var(--osi-border-cream);
  background-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(74, 55, 40, 0.1);
}

/* Scrollable Clinic List Container */
.osi-google-maps-nav-menu-main {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  margin-top: 2px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.osi-google-maps-nav-menu-main::-webkit-scrollbar {
  display: none;
}

.osi-gmaps-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

/* Simple Clinic List Item */
.osi-gmaps-list-item {
  font-size: 15px;
  font-weight: 700;
  padding: 14px 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 1px solid var(--osi-border-cream);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.osi-gmaps-list-item:last-child {
  border-bottom: none;
}

.osi-gmaps-list-item:hover,
.osi-gmaps-list-item:focus {
  opacity: 0.85;
}

.osi-gmaps-list-item.active {
  font-weight: 800;
  opacity: 1;
}

.osi-gmaps-list-item-text {
  line-height: 1.4;
  word-break: break-word;
  flex: 1;
}

.osi-gmaps-chevron {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  flex-shrink: 0;
  margin-left: 8px;
}

/* Side Detail Card Panel (Sliding Drawer Overlay) */
.osi-google-maps-nav-detail {
  display: none;
  width: 310px;
  height: 100%;
  flex-direction: column;
  transform: translateX(-15px);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.3s ease,
    opacity 0.3s ease;
}

.osi-google-maps-nav-detail.active {
  display: flex;
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.osi-google-maps-nav.is-detail-minimized .osi-google-maps-nav-detail,
.osi-google-maps-nav.is-detail-minimized #osi-google-maps-nav-detail {
  display: none !important;
}

.osi-google-maps-nav.is-detail-minimized #osi-gmaps-detail-expand-btn {
  display: inline-flex !important;
}

.osi-gmaps-detail-expand-btn .osi-gmaps-detail-expand-label {
  font-size: 13px;
  font-weight: 700;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Detail Card Structure */
.osi-card {
  background-color: var(--osi-cream-bg);
  border-radius: 1.25rem;
  width: 100%;
  height: auto; /* tinggi card */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--osi-shadow-soft);
  border: 1px solid rgba(234, 222, 207, 0.6);
}

.osi-card-header {
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  position: relative;
  border-top-left-radius: 1.25rem;
  border-top-right-radius: 1.25rem;
  min-height: 140px;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 20px 16px;
  background-color: var(--osi-cream-hover);
}

.osi-card-header-actions {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 5;
  pointer-events: none;
}

.osi-card-header-btn,
.osi-card-header-close {
  background-color: rgba(0, 0, 0, 0.45);
  border: none;
  outline: none;
  cursor: pointer;
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  transition:
    background-color 0.2s ease,
    transform 0.2s ease;
  pointer-events: auto;
}

.osi-card-header-btn:hover,
.osi-card-header-close:hover {
  background-color: rgba(0, 0, 0, 0.7);
  transform: scale(1.08);
}

.osi-card-header-btn svg,
.osi-card-header-close svg {
  width: 18px;
  height: 18px;
  color: #ffffff;
}

/* Detail Card Content Body */
.osi-card-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  padding: 20px 18px;
  overflow-y: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.osi-card-wrapper::-webkit-scrollbar {
  display: none;
}

.osi-card-title-main {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.35;
  margin: 0 0 16px 0;
}

.osi-card-main-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 16px;
}

.osi-card-content-wrapper {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.osi-card-content-title {
  margin: 0;
  padding: 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  opacity: 0.8;
}

.osi-card-content-description {
  font-size: 13px;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 0;
  padding: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.osi-card-content-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  margin-top: 3px;
  stroke: currentColor;
}

.osi-card-email-link {
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.osi-card-email-link:hover,
.osi-card-email-link:focus {
  opacity: 0.75;
}

/* Detail Card Action Links */
.osi-card-secondary-content {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: auto;
  border-top: 1px solid var(--osi-border-cream);
}

.osi-card-content-link {
  background-color: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  border: none;
  border-bottom: 1px solid var(--osi-border-cream);
  outline: none;
  text-align: left;
  width: 100%;
  font-size: 14px;
  font-weight: 700;
  padding: 14px 0;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.osi-card-content-link:last-child {
  border-bottom: none;
}

.osi-card-content-link:hover,
.osi-card-content-link:focus {
  opacity: 0.75;
}

.osi-card-content-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
}

/* Error and No Results Styles */
.osi-gmaps-error {
  padding: 16px 20px;
  border: 1px solid #fecaca;
  background-color: #fef2f2;
  color: #b91c1c;
  border-radius: 1rem;
  font-size: 14px;
  font-weight: 500;
}

.osi-gmaps-no-results {
  padding: 24px;
  text-align: center;
  opacity: 0.7;
  font-size: 14px;
}

/* Mobile Breakpoints & 50% Max Width Constraint Requirement */
@media (max-width: 768px) {
  .osi-google-maps-nav {
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: calc(100% - 20px);
  }

  /* Initial Mobile State: Show only list menu (50% max width) */
  .osi-google-maps-nav-menu,
  .osi-google-maps-nav-menu.active {
    max-width: 50% !important;
    width: 50% !important;
    display: flex !important;
  }

  .osi-google-maps-nav-detail {
    display: none;
  }

  /* Active Mobile State: Hide list menu, show ONLY clinic detail card (50% max width) */
  .osi-google-maps-nav.has-active-clinic .osi-google-maps-nav-menu {
    display: none !important;
  }

  .osi-google-maps-nav.has-active-clinic .osi-google-maps-nav-detail {
    display: flex !important;
    max-width: 50% !important;
    width: 50% !important;
    transform: translateX(0) !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  .osi-card {
    max-width: 100% !important;
    width: 100% !important;
  }

  .osi-card-wrapper {
    padding: 12px 10px;
  }

  .osi-card-title-main {
    font-size: 14px;
    margin-bottom: 10px;
  }

  .osi-card-content-title {
    font-size: 11px;
  }

  .osi-card-content-description {
    font-size: 11px;
    line-height: 1.4;
  }

  .osi-card-content-link {
    padding: 8px 0;
    font-size: 12px;
  }

  /* Collapsed Mobile State: Hide menu, show expand button */
  .osi-google-maps-nav.is-menu-collapsed .osi-google-maps-nav-menu {
    display: none !important;
  }

  .osi-google-maps-nav.is-menu-collapsed #osi-gmaps-menu-expand-btn {
    display: inline-flex !important;
    padding: 8px 14px;
  }

  .osi-google-maps-nav.has-active-clinic #osi-gmaps-menu-expand-btn {
    display: none !important;
  }

  /* Minimized Detail Mobile State: Hide detail card, show detail expand pill */
  .osi-google-maps-nav.has-active-clinic.is-detail-minimized
    .osi-google-maps-nav-detail {
    display: none !important;
  }

  .osi-google-maps-nav.has-active-clinic.is-detail-minimized
    #osi-gmaps-detail-expand-btn {
    display: inline-flex !important;
    padding: 8px 14px;
    max-width: 80%;
  }

  .osi-google-maps-nav.has-active-clinic.is-detail-minimized
    #osi-gmaps-detail-expand-btn
    .osi-gmaps-detail-expand-label {
    max-width: 140px;
    font-size: 12px;
  }

  .osi-card-header-btn,
  .osi-card-header-close {
    width: 28px;
    height: 28px;
  }

  .osi-card-header-btn svg,
  .osi-card-header-close svg {
    width: 15px;
    height: 15px;
  }

  .osi-google-maps-nav-menu-header-title {
    font-size: 13px;
  }

  .osi-google-maps-nav-menu-header-toggle {
    width: 24px;
    height: 24px;
  }

  .osi-gmaps-list-item {
    font-size: 12px;
    padding: 10px 4px;
  }
}
