/* ============================================
   旅遊地圖 Travel Map 樣式
   ============================================ */

.tm-wrap {
    max-width: 1400px;
    margin: 0 auto;
    padding: 10px 12px 30px;
}

/* --- 工具列 / 篩選 --- */
.tm-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--border-color, #e8ded2);
    border-radius: 12px;
    padding: 10px 14px;
    margin-bottom: 14px;
}

.tm-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tm-filters select,
.tm-filters input,
.tm-quick-form select,
.tm-quick-form input {
    padding: 7px 10px;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 8px;
    background: #fff;
    font-size: 0.88em;
    color: #444;
    outline: none;
}

.tm-filters select:focus,
.tm-filters input:focus {
    border-color: #c98f6b;
}

#tm-search {
    min-width: 220px;
}

.tm-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* --- 地圖關鍵字定位 --- */
.tm-geo-form {
    display: flex;
    gap: 6px;
    align-items: center;
}

.tm-geo-form input {
    padding: 7px 10px;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 8px;
    background: #fff;
    font-size: 0.88em;
    color: #444;
    min-width: 200px;
}

.tm-geo-form input:focus {
    border-color: #c98f6b;
}

.tm-geo-form button:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* --- 按鈕 --- */
.tm-btn {
    padding: 8px 14px;
    border: 1px solid var(--border-color, #d9c9b8);
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.88em;
    color: #5b4a3c;
    transition: all 0.2s;
}

.tm-btn:hover {
    background: #f7efe6;
    transform: translateY(-1px);
}

.tm-btn-primary {
    background: #c98f6b;
    border-color: #c98f6b;
    color: #fff;
}

.tm-btn-primary:hover { background: #b77b57; }

.tm-btn-green {
    background: #4e9d7b;
    border-color: #4e9d7b;
    color: #fff;
}

.tm-btn-green:hover { background: #3f8667; }

.tm-btn-sm {
    padding: 4px 9px;
    font-size: 0.8em;
}

/* --- 主要版面 --- */
.tm-main {
    display: grid;
    grid-template-columns: 330px 1fr;
    gap: 14px;
    align-items: start;
}

.tm-sidebar {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.tm-panel {
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid var(--border-color, #e8ded2);
    border-radius: 12px;
    padding: 12px 14px;
}

.tm-panel h3 {
    margin: 0 0 10px;
    font-size: 1.02em;
    color: #6b4f3a;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tm-count {
    font-size: 0.75em;
    color: #9b8574;
    font-weight: normal;
}

/* --- 地圖 --- */
#tm-map {
    height: 480px;
    border-radius: 12px;
    border: 1px solid var(--border-color, #e8ded2);
    z-index: 1;
    background: #eef3f0;
}

.tm-map-err {
    padding: 40px;
    text-align: center;
    color: #a33;
}

.tm-marker-pin {
    width: 28px;
    height: 28px;
    border-radius: 50% 50% 50% 4px;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    border: 2px solid #fff;
}

.tm-marker-pin::after {
    content: '';
    transform: rotate(45deg);
}

.tm-marker-trip {
    background: #2c3e50;
    width: 30px;
    height: 30px;
}

/* --- 搜尋定位圖標（金色圓點＋脈動光環，與行程／項目圖標區隔） --- */
.tm-search-marker {
    background: transparent;
    border: none;
}

.tm-search-pin {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #f6c445;
    border: 3px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    animation: tm-search-pulse 1.6s ease-out infinite;
}

@keyframes tm-search-pulse {
    0% { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35), 0 0 0 0 rgba(246, 196, 69, 0.65); }
    100% { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35), 0 0 0 18px rgba(246, 196, 69, 0); }
}

.tm-popup {
    min-width: 190px;
    max-width: 250px;
    font-size: 0.86em;
    line-height: 1.5;
}

.tm-popup strong {
    display: block;
    margin: 4px 0 2px;
    font-size: 1.05em;
    color: #3b2c20;
}

.tm-popup-meta {
    color: #777;
    font-size: 0.92em;
}

.tm-popup-desc {
    margin: 4px 0;
    color: #555;
    font-size: 0.9em;
}

.tm-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 0.76em;
    color: #fff;
    background: #888;
    vertical-align: middle;
}

.tm-badge-trip { background: #2c3e50; }
.tm-badge-region { background: #7c9a7e; }

/* --- 行程卡片 --- */
.tm-trip-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 380px;
    overflow-y: auto;
}

.tm-trip-card {
    border: 1px solid #e7dbcc;
    border-radius: 10px;
    padding: 10px 12px;
    background: #fffdf9;
    cursor: pointer;
    transition: all 0.2s;
}

.tm-trip-card:hover { border-color: #c98f6b; }

.tm-trip-card.active {
    border-color: #c98f6b;
    background: #fbf1e7;
    box-shadow: 0 2px 8px rgba(201, 143, 107, 0.25);
}

.tm-trip-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.tm-trip-meta {
    font-size: 0.82em;
    color: #7c6a5b;
    margin: 2px 0;
}

.tm-progress {
    height: 6px;
    background: #eee4d8;
    border-radius: 4px;
    overflow: hidden;
    margin: 6px 0 3px;
}

.tm-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4e9d7b, #7fc4a3);
    border-radius: 4px;
    transition: width 0.4s;
}

.tm-trip-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

/* --- 建議面板 --- */
.tm-advice-box {
    font-size: 0.86em;
    line-height: 1.65;
    color: #5b4a3c;
    max-height: 460px;
    overflow-y: auto;
}

.tm-advice-box h4 {
    margin: 12px 0 5px;
    font-size: 0.95em;
    color: #8a5c3b;
}

.tm-advice-box ul {
    margin: 0;
    padding-left: 18px;
}

.tm-advice-box li { margin: 3px 0; }

.tm-advice-trip {
    background: #f7efe6;
    border-radius: 8px;
    padding: 7px 10px;
    margin-bottom: 6px;
}

.tm-advice-img {
    float: right;
    width: 110px;
    max-height: 90px;
    object-fit: cover;
    border-radius: 8px;
    margin: 0 0 6px 8px;
}

.tm-advice-web a {
    color: #a86b3f;
    word-break: break-all;
}

.tm-loading { color: #999; }

/* --- 項目清單 --- */
.tm-item-panel { margin-top: 14px; }

.tm-quick-form {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.tm-quick-form input[type="text"] {
    flex: 1;
    min-width: 180px;
}

.tm-item-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 520px;
    overflow-y: auto;
}

.tm-item-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border: 1px solid #eee1d2;
    border-radius: 10px;
    padding: 9px 12px;
    background: #fff;
    transition: all 0.2s;
}

.tm-item-card:hover { border-color: #d3b394; }

.tm-item-card.done {
    opacity: 0.62;
    background: #f6faf7;
}

.tm-item-card.done strong {
    text-decoration: line-through;
    color: #888;
}

.tm-done-check {
    width: 18px;
    height: 18px;
    margin-top: 3px;
    cursor: pointer;
    accent-color: #4e9d7b;
    flex-shrink: 0;
}

.tm-type-badge {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}

.tm-item-info {
    flex: 1;
    min-width: 0;
}

.tm-item-info strong {
    color: #4a3728;
    font-size: 0.95em;
}

.tm-item-meta {
    font-size: 0.8em;
    color: #8b7765;
    margin-top: 2px;
}

.tm-item-desc {
    font-size: 0.82em;
    color: #777;
    margin-top: 3px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.tm-item-actions {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex-shrink: 0;
}

.tm-empty {
    color: #a2917f;
    text-align: center;
    padding: 14px 8px;
    font-size: 0.88em;
}

/* --- Modal --- */
.tm-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(60, 42, 28, 0.45);
    z-index: 2000;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 14px;
    overflow-y: auto;
}

.tm-modal.open { display: flex; }

.tm-modal-box {
    background: #fffdf9;
    border-radius: 14px;
    width: 100%;
    max-width: 620px;
    padding: 18px 22px 22px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
    animation: tm-pop 0.25s ease;
}

@keyframes tm-pop {
    from { transform: translateY(14px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.tm-modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.tm-modal-head h3 {
    margin: 0;
    color: #6b4f3a;
}

.tm-close {
    background: none;
    border: none;
    font-size: 1.6em;
    cursor: pointer;
    color: #a08b78;
    line-height: 1;
}

/* --- 地圖選點模式：背景穿透，讓地圖可以直接點擊 --- */
.tm-modal.picking {
    background: transparent;
    pointer-events: none;
}

.tm-modal.picking .tm-modal-box {
    pointer-events: auto;
    border: 2px dashed #e6a34a;
}

.tm-btn-picking {
    background: #e6a34a;
    border-color: #e6a34a;
    color: #fff;
}

.tm-btn-picking:hover { background: #d69440; }

.tm-close:hover { color: #c0392b; }

/* --- 表單 --- */
.tm-form label {
    display: block;
    margin-bottom: 10px;
    font-size: 0.86em;
    color: #7c6a5b;
}

.tm-form input,
.tm-form select,
.tm-form textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    margin-top: 4px;
    border: 1px solid #e0d2c2;
    border-radius: 8px;
    font-size: 0.95em;
    background: #fff;
    outline: none;
}

.tm-form input:focus,
.tm-form select:focus,
.tm-form textarea:focus {
    border-color: #c98f6b;
}

.tm-form-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.tm-form-row label { flex: 1; min-width: 130px; }

.tm-form-row .tm-btn { margin-bottom: 10px; white-space: nowrap; }

.tm-form-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

/* --- 細節 --- */
.tm-detail-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.tm-detail-head h3 {
    margin: 0;
    flex: 1;
    color: #4a3728;
}

.tm-detail-done {
    font-size: 0.85em;
    color: #4e9d7b;
}

.tm-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px 14px;
    font-size: 0.88em;
    color: #55463a;
    margin-bottom: 12px;
}

.tm-detail-grid span {
    display: block;
    font-size: 0.82em;
    color: #a08b78;
}

.tm-detail-desc {
    background: #f9f3ea;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.88em;
    color: #66564a;
    margin-bottom: 10px;
    white-space: pre-wrap;
}

.tm-detail-link a {
    color: #a86b3f;
    word-break: break-all;
}

/* --- Toast --- */
.tm-toast {
    position: fixed;
    left: 50%;
    bottom: 40px;
    transform: translate(-50%, 20px);
    background: #4e9d7b;
    color: #fff;
    padding: 10px 22px;
    border-radius: 24px;
    font-size: 0.9em;
    opacity: 0;
    transition: all 0.3s;
    z-index: 3000;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.tm-toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.tm-toast-err { background: #c0392b; }

/* --- 響應式 --- */
@media (max-width: 1024px) {
    .tm-main {
        grid-template-columns: 1fr;
    }

    #tm-map {
        height: 380px;
    }

    .tm-trip-list {
        max-height: 260px;
    }
}

@media (max-width: 560px) {
    .tm-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    #tm-search { min-width: 0; }

    #tm-geo-input { min-width: 0; }

    .tm-geo-form { flex: 1; }

    .tm-geo-form input { flex: 1; }

    .tm-item-card {
        flex-wrap: wrap;
    }

    .tm-item-actions {
        flex-direction: row;
        width: 100%;
        justify-content: flex-end;
    }
}
