/* =============================================
   SekolahCMS — Global Search Modal
   Modal full-width tengah, realtime search
   ============================================= */

/* Search trigger button di navbar */
.sm-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  color: #666777;
  font-size: 1.15rem;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
}

.sm-trigger:hover {
  background: rgba(0, 85, 164, 0.08);
  color: #0055A4;
}

/* Backdrop */
.sm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9995;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.sm-backdrop.sm-open {
  opacity: 1;
  pointer-events: auto;
}

/* Modal container */
.sm-modal {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px) scale(0.97);
  z-index: 9996;
  width: 92%;
  max-width: 640px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.2s ease;
}

.sm-modal.sm-open {
  transform: translateX(-50%) translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* Search input area */
.sm-input-wrap {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #eef0f3;
  background: #fff;
  gap: 12px;
}

.sm-input-icon {
  color: #8895a7;
  font-size: 1.2rem;
}

.sm-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1rem;
  color: #1a2332;
  background: transparent;
  font-family: inherit;
}

.sm-input::placeholder {
  color: #8895a7;
}

.sm-close-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f3f5;
  border: none;
  border-radius: 6px;
  color: #555;
  font-size: 0.75rem;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 0 6px;
  transition: background 0.15s;
}

.sm-close-btn:hover {
  background: #e4e7ec;
}

/* Results area */
.sm-results {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  min-height: 100px;
}

.sm-empty,
.sm-loading {
  text-align: center;
  padding: 32px 20px;
  color: #8895a7;
  font-size: 0.88rem;
}

.sm-loading i {
  font-size: 1.3rem;
  animation: sm-spin 1s linear infinite;
  display: inline-block;
  margin-right: 6px;
}

@keyframes sm-spin {
  to { transform: rotate(360deg); }
}

.sm-empty i {
  font-size: 2rem;
  display: block;
  margin-bottom: 8px;
  color: #c4cad1;
}

/* Group section */
.sm-group {
  padding: 8px 0;
}

.sm-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 20px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8895a7;
}

.sm-group-header .sm-group-count {
  font-size: 0.68rem;
  font-weight: 600;
  color: #b0b7c0;
}

/* Result item */
.sm-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 20px;
  text-decoration: none;
  color: inherit;
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.sm-item:hover,
.sm-item.sm-active {
  background: #f0f6ff;
  border-left-color: #0055A4;
}

.sm-item-image {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 6px;
  background: #e9ecef;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sm-item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sm-item-image i {
  color: #8895a7;
  font-size: 1.4rem;
}

.sm-item-body {
  flex: 1;
  min-width: 0;
}

.sm-item-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: #1a2332;
  margin: 0 0 2px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sm-item-snippet {
  font-size: 0.78rem;
  color: #666;
  line-height: 1.4;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sm-item-snippet mark {
  background: rgba(255, 230, 0, 0.45);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 600;
}

/* Footer hint */
.sm-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  border-top: 1px solid #eef0f3;
  background: #f8f9fb;
  font-size: 0.7rem;
  color: #8895a7;
}

.sm-hint-keys {
  display: flex;
  gap: 8px;
  align-items: center;
}

.sm-hint-keys kbd {
  display: inline-block;
  padding: 2px 6px;
  background: #fff;
  border: 1px solid #d0d7de;
  border-bottom-width: 2px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: #555;
}

/* Highlight target via anchor */
.sm-target-highlight {
  animation: sm-highlight 2.5s ease;
}

@keyframes sm-highlight {
  0%   { box-shadow: 0 0 0 0 rgba(0, 85, 164, 0.6); }
  30%  { box-shadow: 0 0 0 6px rgba(0, 85, 164, 0.35); }
  100% { box-shadow: 0 0 0 0 rgba(0, 85, 164, 0); }
}

/* Mobile responsive */
@media (max-width: 640px) {
  .sm-modal {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: none;
    max-height: 100vh;
    border-radius: 0;
    transform: translateY(0) scale(1);
  }

  .sm-modal.sm-open {
    transform: translateY(0) scale(1);
  }

  .sm-input-wrap {
    padding: 14px 16px;
  }

  .sm-item {
    padding: 10px 16px;
  }

  .sm-group-header {
    padding: 6px 16px;
  }

  .sm-hint {
    padding: 8px 16px;
  }

  .sm-hint-keys {
    display: none;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .sm-backdrop,
  .sm-modal,
  .sm-item,
  .sm-trigger {
    transition: none;
  }
  .sm-loading i,
  .sm-target-highlight {
    animation: none;
  }
}