/* =========================================================
   Trang chi tiết tiện ích (/chi-tiet-tien-ich)
   Toàn bộ style scope dưới .ti-detail để không ảnh hưởng trang khác
   ========================================================= */
.ti-detail {
    --ti-navy: #0c4a6e;
    --ti-blue: #0ea5e9;
    --ti-blue-soft: #f0f9ff;
    --ti-blue-line: #bae6fd;
    --ti-accent: #f07620;
    --ti-text: #0f172a;
    --ti-muted: #64748b;
    --ti-line: #e2e8f0;
    --ti-radius: 14px;
    --ti-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(12, 74, 110, .08);
    color: var(--ti-text);
    padding-bottom: 48px;
}

/* Thuộc tính hidden luôn thắng các rule display bên dưới */
.ti-detail [hidden] { display: none !important; }

/* ---------- Tiêu đề ---------- */
.ti-detail .ti-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 8px 0 18px; }
.ti-detail .ti-eyebrow { margin: 0 0 4px; font-size: 12px; font-weight: 600; letter-spacing: 3px; text-transform: uppercase; color: var(--ti-blue); }
.ti-detail .ti-title { margin: 0; font-size: 28px; font-weight: 700; line-height: 1.2; color: var(--ti-navy); }
.ti-detail .ti-count { flex-shrink: 0; padding: 6px 14px; border-radius: 999px; background: var(--ti-blue-soft); border: 1px solid var(--ti-blue-line); color: var(--ti-navy); font-size: 14px; white-space: nowrap; }
    .ti-detail .ti-count b { font-size: 16px; color: var(--ti-accent); }

/* ---------- Chip nhóm ---------- */
.ti-detail .ti-chips { position: relative; margin-bottom: 18px; padding: 0 44px; }
    .ti-detail .ti-chips .owl-stage-outer { padding: 4px 0; }
.ti-detail .ti-chip { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 16px 0 6px; border: 1px solid var(--ti-line); border-radius: 999px; background: #fff; color: var(--ti-navy); font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer; transition: background .2s, border-color .2s, color .2s, box-shadow .2s; }
    .ti-detail .ti-chip:hover { border-color: var(--ti-blue); box-shadow: 0 4px 12px rgba(14, 165, 233, .15); }
    .ti-detail .ti-chip:focus-visible { outline: 3px solid rgba(14, 165, 233, .45); outline-offset: 2px; }
    .ti-detail .ti-chip .ti-chip-icon { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: var(--ti-blue-soft); overflow: hidden; flex-shrink: 0; }
        .ti-detail .ti-chip .ti-chip-icon img { width: 22px !important; height: 22px; object-fit: contain; }
        .ti-detail .ti-chip .ti-chip-icon i { font-size: 14px; color: var(--ti-blue); }
    .ti-detail .ti-chip.active { background: var(--ti-navy); border-color: var(--ti-navy); color: #fff; }
        .ti-detail .ti-chip.active .ti-chip-icon { background: #fff; }
.ti-detail .ti-chips .owl-nav { margin: 0 !important; }
    .ti-detail .ti-chips .owl-nav button.owl-prev,
    .ti-detail .ti-chips .owl-nav button.owl-next { position: absolute; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; margin: 0 !important; border-radius: 50% !important; background: #fff !important; border: 1px solid var(--ti-line) !important; color: var(--ti-navy) !important; font-size: 14px !important; line-height: 1 !important; }
    .ti-detail .ti-chips .owl-nav button.owl-prev { left: 0; }
    .ti-detail .ti-chips .owl-nav button.owl-next { right: 0; }
    .ti-detail .ti-chips .owl-nav button:hover { border-color: var(--ti-blue) !important; color: var(--ti-blue) !important; }
    .ti-detail .ti-chips .owl-nav button.disabled { opacity: .35; cursor: default; }

/* ---------- Tab mobile ---------- */
.ti-detail .ti-tabs { display: none; }

/* ---------- Bố cục chính ---------- */
.ti-detail .ti-body { display: grid; grid-template-columns: minmax(340px, 410px) 1fr; gap: 16px; height: calc(100vh - 200px); min-height: 540px; max-height: 780px; }

.ti-detail .ti-panel { display: flex; flex-direction: column; min-height: 0; background: #fff; border: 1px solid var(--ti-line); border-radius: var(--ti-radius); box-shadow: var(--ti-shadow); overflow: hidden; }
.ti-detail .ti-panel-top { padding: 14px 14px 10px; border-bottom: 1px solid var(--ti-line); }

/* Ô tìm kiếm */
.ti-detail .ti-search { position: relative; }
    .ti-detail .ti-search > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ti-muted); pointer-events: none; }
    .ti-detail .ti-search input { width: 100%; height: 44px; padding: 0 40px 0 40px; border: 1px solid var(--ti-line); border-radius: 10px; background: #f8fafc; font-size: 15px; transition: border-color .2s, box-shadow .2s, background .2s; }
        .ti-detail .ti-search input:focus { outline: none; background: #fff; border-color: var(--ti-blue); box-shadow: 0 0 0 4px rgba(14, 165, 233, .15); }
    .ti-detail .ti-search .ti-search-clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; color: var(--ti-muted); }
        .ti-detail .ti-search .ti-search-clear:hover { background: var(--ti-line); color: var(--ti-text); }

/* Banner bật định vị */
.ti-detail .ti-geo { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 8px 10px; border-radius: 10px; background: #fff7ed; border: 1px solid #fed7aa; font-size: 13px; color: #9a3412; }
    .ti-detail .ti-geo i { color: var(--ti-accent); }
    .ti-detail .ti-geo span { flex: 1; line-height: 1.35; }
    .ti-detail .ti-geo button { flex-shrink: 0; padding: 5px 10px; border: 0; border-radius: 8px; background: var(--ti-accent); color: #fff; font-size: 12px; font-weight: 600; }
        .ti-detail .ti-geo button:hover { background: #d9620f; }

/* Danh sách */
.ti-detail .ti-list { position: relative; flex: 1; min-height: 0; overflow: hidden; padding: 10px; }
.ti-detail .ti-card { position: relative; display: flex; gap: 12px; padding: 12px; margin-bottom: 10px; border: 1px solid var(--ti-line); border-left: 4px solid transparent; border-radius: 12px; background: #fff; cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s, background .15s; }
    .ti-detail .ti-card:last-child { margin-bottom: 0; }
    .ti-detail .ti-card:hover { transform: translateY(-1px); border-color: var(--ti-blue-line); box-shadow: 0 6px 16px rgba(12, 74, 110, .08); }
    .ti-detail .ti-card:focus-visible { outline: 3px solid rgba(14, 165, 233, .45); outline-offset: 1px; }
    .ti-detail .ti-card.active { background: var(--ti-blue-soft); border-color: var(--ti-blue-line); border-left-color: var(--ti-blue); }
.ti-detail .ti-card-thumb { width: 72px; height: 72px; flex-shrink: 0; border-radius: 10px; background: #f1f5f9; overflow: hidden; }
    .ti-detail .ti-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ti-detail .ti-card-body { flex: 1; min-width: 0; }
.ti-detail .ti-card-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 0 0 4px; font-size: 15px; font-weight: 700; line-height: 1.35; color: var(--ti-navy); }
.ti-detail .ti-card-line { display: flex; gap: 6px; margin: 0 0 2px; font-size: 13px; line-height: 1.4; color: var(--ti-muted); }
    .ti-detail .ti-card-line i { width: 14px; margin-top: 3px; flex-shrink: 0; text-align: center; font-size: 12px; color: var(--ti-blue); }
.ti-detail a.ti-card-line { text-decoration: none; }
    .ti-detail a.ti-card-line:hover span { color: var(--ti-blue); text-decoration: underline; }
.ti-detail .ti-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.ti-detail .ti-distance { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: #ecfdf5; color: #047857; font-size: 12px; font-weight: 600; }
    .ti-detail .ti-distance.is-route { background: #fff7ed; color: #c2410c; }
.ti-detail .ti-card-actions { display: flex; gap: 6px; margin-left: auto; }
.ti-detail .ti-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 10px; border: 1px solid var(--ti-blue); border-radius: 8px; background: var(--ti-blue); color: #fff; font-size: 12px; font-weight: 600; text-decoration: none; white-space: nowrap; transition: background .15s, color .15s; }
    .ti-detail .ti-btn:hover { background: #0284c7; border-color: #0284c7; color: #fff; }
    .ti-detail .ti-btn.ti-btn-ghost { width: 30px; padding: 0; background: #fff; color: var(--ti-blue); }
        .ti-detail .ti-btn.ti-btn-ghost:hover { background: var(--ti-blue-soft); color: #0284c7; }

/* Skeleton */
.ti-detail .ti-skeleton { pointer-events: none; }
    .ti-detail .ti-skeleton .ti-card-thumb,
    .ti-detail .ti-skeleton .ti-sk-line { background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%); background-size: 200% 100%; animation: ti-shimmer 1.2s infinite linear; }
    .ti-detail .ti-skeleton .ti-sk-line { height: 12px; margin-bottom: 8px; border-radius: 6px; }

@keyframes ti-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Trạng thái rỗng */
.ti-detail .ti-empty { padding: 48px 24px; text-align: center; color: var(--ti-muted); }
    .ti-detail .ti-empty i { display: block; margin-bottom: 12px; font-size: 40px; color: var(--ti-blue-line); }
    .ti-detail .ti-empty p { margin: 0; font-size: 14px; }

/* ---------- Bản đồ ---------- */
.ti-detail .ti-map-wrap { position: relative; min-height: 0; border: 1px solid var(--ti-line); border-radius: var(--ti-radius); box-shadow: var(--ti-shadow); overflow: hidden; }
.ti-detail #ti-map { width: 100%; height: 100%; }
.ti-detail .ti-locate { position: absolute; top: 12px; right: 60px; z-index: 3; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border: 0; border-radius: 999px; background: #fff; color: var(--ti-navy); font-size: 13px; font-weight: 600; box-shadow: 0 2px 8px rgba(15, 23, 42, .2); }
    .ti-detail .ti-locate:hover { color: var(--ti-blue); }
    .ti-detail .ti-locate i { color: var(--ti-blue); }

/* Infowindow */
.ti-iw { display: flex; gap: 10px; max-width: 260px; font-family: inherit; }
    .ti-iw img { width: 52px; height: 52px; flex-shrink: 0; border-radius: 8px; object-fit: cover; background: #f1f5f9; }
    .ti-iw h4 { margin: 0 0 4px; font-size: 14px; font-weight: 700; color: #0c4a6e; }
    .ti-iw p { margin: 0 0 8px; font-size: 12px; color: #64748b; }
    .ti-iw button { padding: 4px 10px; border: 0; border-radius: 6px; background: #0ea5e9; color: #fff; font-size: 12px; font-weight: 600; }

/* Chấm vị trí người dùng */
.ti-user-dot { position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border: 3px solid #fff; border-radius: 50%; background: #2563eb; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); }
    .ti-user-dot:after { content: ""; position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; background: rgba(37, 99, 235, .25); animation: ti-pulse 1.8s ease-out infinite; }

@keyframes ti-pulse {
    0% { transform: scale(.3); opacity: 1; }
    100% { transform: scale(1.3); opacity: 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .ti-detail .ti-body { grid-template-columns: 340px 1fr; }
    .ti-detail .ti-title { font-size: 24px; }
}

@media (max-width: 767.98px) {
    .ti-detail .ti-head { align-items: flex-start; flex-direction: column; gap: 8px; }
    .ti-detail .ti-title { font-size: 22px; }
    .ti-detail .ti-chips { padding: 0; }
        .ti-detail .ti-chips .owl-nav { display: none; }

    .ti-detail .ti-tabs { position: sticky; top: 0; z-index: 5; display: flex; gap: 4px; margin-bottom: 12px; padding: 4px; border-radius: 12px; background: #e2e8f0; }
        .ti-detail .ti-tabs button { flex: 1; height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--ti-muted); font-size: 14px; font-weight: 600; }
            .ti-detail .ti-tabs button.active { background: #fff; color: var(--ti-navy); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }

    .ti-detail .ti-body { display: block; height: auto; min-height: 0; max-height: none; }
    .ti-detail .ti-panel { height: 70vh; min-height: 420px; }
    .ti-detail .ti-map-wrap { height: 65vh; min-height: 380px; }
    .ti-detail .ti-body[data-view="list"] .ti-map-wrap,
    .ti-detail .ti-body[data-view="map"] .ti-panel { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .ti-detail *, .ti-user-dot:after { animation: none !important; transition: none !important; }
}
