/* ===================================
   GoTrip — Trip Planning Modal CSS
   Redesigned · same color palette
   =================================== */

/* ===================================
   1. MODAL OVERLAY
   =================================== */
.planning-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(30, 41, 59, 0.55);
    z-index: 10000;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.planning-modal-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: overlayFadeIn 0.22s ease;
}

@keyframes overlayFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ===================================
   2. MODAL CONTAINER
   =================================== */
.planning-modal {
    background: #fff;
    width: 92%;
    max-width: 860px;
    max-height: 87vh;
    border-radius: 18px;
    box-shadow: 0 24px 64px rgba(45,90,135,0.28);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.28s cubic-bezier(.4,0,.2,1);
}

@keyframes modalSlideIn {
    from { opacity:0; transform: translateY(-28px) scale(0.96); }
    to   { opacity:1; transform: translateY(0)    scale(1);    }
}

/* ===================================
   3. MODAL HEADER
   =================================== */
.planning-modal-header {
    background: linear-gradient(135deg, #2D5A87 0%, #4a90e2 55%, #F1E5AC 100%);
    padding: 18px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.planning-modal-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.2);
    margin: 0;
}

.planning-modal-close {
    background: rgba(255,255,255,0.2);
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
}
.planning-modal-close:hover {
    background: rgba(255,255,255,0.35);
    transform: rotate(90deg);
}

/* ===================================
   4. MODAL BODY
   =================================== */
.planning-modal-body {
    padding: 20px 22px;
    overflow-y: auto;
    flex: 1;
    background: #f8fafc;
}

.planning-modal-body::-webkit-scrollbar { width: 4px; }
.planning-modal-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* ===================================
   5. TRIP DAYS
   =================================== */
.trip-days-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ===================================
   6. DAY CARD
   =================================== */
.day-card {
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 14px;
    overflow: visible;
    box-shadow: 0 2px 8px rgba(45,90,135,0.07);
    transition: box-shadow 0.22s, border-color 0.22s;
}

.day-card:hover {
    border-color: #4a90e2;
    box-shadow: 0 4px 16px rgba(74,144,226,0.14);
}

.day-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    background: linear-gradient(90deg, #f0f6ff 0%, #fdf9f0 100%);
    border-bottom: 1px solid #e2e8f0;
}

.day-number {
    font-size: 1rem;
    font-weight: 800;
    color: #2D5A87;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

/* day badge */
.day-number::before {
    content: attr(data-day);
    background: linear-gradient(135deg, #4a90e2, #2D5A87);
    color: #fff;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
    flex-shrink: 0;
}

.day-date-input {
    padding: 6px 10px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.85rem;
    font-family: inherit;
    color: #1e293b;
    outline: none;
    background: #fff;
    transition: all 0.2s;
    margin-left: auto;
}
.day-date-input:focus {
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74,144,226,0.12);
}

.day-remove-btn {
    background: #fff0f0;
    color: #ef4444;
    border: 1.5px solid #fecaca;
    padding: 5px 11px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.day-remove-btn:hover {
    background: #ef4444;
    color: #fff;
    border-color: #ef4444;
    transform: translateY(-1px);
}

/* body of each day card */
.day-card > .locations-list {
    padding: 12px 14px 8px;
}

.day-card > .add-location-section {
    padding: 16px 14px 20px;  /* เพิ่มล่างให้หายใจ */
}

/* ===================================
   7. LOCATION ITEMS
   =================================== */
.locations-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px 4px;
}

.location-item {
    background: #f8fafc;
    padding: 10px 12px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1.5px solid #e2e8f0;
    transition: all 0.2s;
}

.location-item:hover {
    background: #f0f6ff;
    border-color: #93c5fd;
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(74,144,226,0.1);
}

.location-order {
    background: linear-gradient(135deg, #4a90e2, #2D5A87);
    color: #fff;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 12px;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(74,144,226,0.3);
}

.location-info {
    flex: 1;
    min-width: 0;
}

.location-name {
    font-weight: 700;
    font-size: 0.88rem;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.location-category {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 1px;
}

/* ===================================
   8. TIME INPUT
   =================================== */
.location-time-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
}

.location-time-input {
    padding: 5px 8px;
    border: 1.5px solid #e2e8f0;
    border-radius: 7px;
    font-size: 0.82rem;
    font-family: inherit;
    color: #374151;
    background: #fff;
    transition: all 0.2s;
    cursor: pointer;
    min-width: 86px;
    outline: none;
}
.location-time-input:hover  { border-color: #4a90e2; background: #f0f6ff; }
.location-time-input:focus  {
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74,144,226,0.12);
    background: #fff;
}
.location-time-input::-webkit-calendar-picker-indicator {
    cursor: pointer; filter: invert(0.45);
}
.location-time-input:hover::-webkit-calendar-picker-indicator { filter: invert(0.25); }

.location-remove {
    background: #fff5f5;
    color: #ef4444;
    border: 1.5px solid #fecaca;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.2s;
    flex-shrink: 0;
}
.location-remove:hover {
    background: #ef4444;
    color: #fff;
    border-color: #ef4444;
    transform: scale(1.1);
}

/* ===================================
   9. ADD LOCATION SECTION
   =================================== */
.add-location-section {
    padding: 10px 14px 14px;
    border-top: 1px dashed #e2e8f0;
    margin-top: 12px;
}

.location-search-wrapper {
    position: relative;
}

.location-search-input {
    width: 100%;
    padding: 9px 36px 9px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 9px;
    font-size: 0.88rem;
    font-family: inherit;
    color: #1e293b;
    outline: none;
    background: #fff;
    transition: all 0.2s;
}
.location-search-input:focus {
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74,144,226,0.12);
}
.location-search-input::placeholder { color: #94a3b8; }

.location-search-icon {
    position: absolute;
    right: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 15px;
    pointer-events: none;
}

/* ===================================
   10. AUTOCOMPLETE DROPDOWN
   =================================== */
.autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(45,90,135,0.14);
    z-index: 50;
    display: none;
    animation: dropdownIn 0.15s ease;
}

@keyframes dropdownIn {
    from { opacity:0; transform: translateY(-6px); }
    to   { opacity:1; transform: translateY(0); }
}

.autocomplete-dropdown.active { display: block; }
.autocomplete-dropdown::-webkit-scrollbar { width: 3px; }
.autocomplete-dropdown::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 2px; }

.autocomplete-item {
    padding: 9px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: #f0f6ff; }

.autocomplete-icon { font-size: 18px; flex-shrink: 0; }

.autocomplete-info { flex:1; min-width:0; }

.autocomplete-name {
    font-weight: 700;
    font-size: 0.88rem;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.autocomplete-category {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 1px;
}

.autocomplete-item-province {
    font-size: 0.72rem;
    color: #94a3b8;
}

.autocomplete-no-results {
    padding: 14px;
    text-align: center;
    color: #94a3b8;
    font-size: 0.85rem;
}

/* ===================================
   11. ADD DAY BUTTON
   =================================== */
.add-day-btn {
    width: 100%;
    padding: 11px 14px;
    background: linear-gradient(135deg, #4a90e2 0%, #2D5A87 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 0.92rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin-top: 16px;
    transition: all 0.22s;
    box-shadow: 0 3px 12px rgba(74,144,226,0.3);
}
.add-day-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74,144,226,0.42);
}
.add-day-btn:active { transform: translateY(0); }

/* ===================================
   12. MODAL FOOTER
   =================================== */
.planning-modal-footer {
    padding: 14px 22px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-shrink: 0;
}

.btn-planning {
    padding: 9px 18px;
    border: none;
    border-radius: 9px;
    font-size: 0.88rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.btn-planning-show {
    background: #10b981;
    color: #fff;
    box-shadow: 0 2px 8px rgba(16,185,129,0.25);
}
.btn-planning-show:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(16,185,129,0.35);
}

.btn-planning-export {
    background: linear-gradient(135deg, #4a90e2 0%, #2D5A87 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(74,144,226,0.25);
}
.btn-planning-export:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(74,144,226,0.4);
}

.btn-planning-clear {
    background: #fff5f5;
    color: #ef4444;
    border: 1.5px solid #fecaca;
}
.btn-planning-clear:hover {
    background: #ef4444;
    color: #fff;
    border-color: #ef4444;
}

/* ===================================
   13. EMPTY STATE
   =================================== */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: #94a3b8;
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state-text { font-size: 1rem; color: #64748b; margin-bottom: 6px; font-weight: 600; }
.empty-state-hint { font-size: 0.85rem; }

/* ===================================
   14. ROUTE MARKER
   =================================== */
.route-marker-icon { background: transparent; border: none; }
.route-marker-number {
    background: linear-gradient(135deg, #4a90e2, #2D5A87);
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 13px;
    box-shadow: 0 2px 8px rgba(45,90,135,0.4);
    border: 2px solid #fff;
}

.trip-route-line {
    stroke: #4a90e2;
    stroke-width: 3;
    fill: none;
    stroke-dasharray: 6 4;
    animation: dash 18s linear infinite;
}
@keyframes dash { to { stroke-dashoffset: -100; } }

/* ===================================
   15. LOADING EXPORT
   =================================== */
.loading-export {
    display: none;
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    padding: 28px 36px;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(45,90,135,0.22);
    z-index: 10001;
    text-align: center;
    gap: 14px;
    flex-direction: column;
    align-items: center;
}
.loading-export.active {
    display: flex;
}

.loading-spinner {
    width: 42px;
    height: 42px;
    border: 3px solid #e2e8f0;
    border-top-color: #4a90e2;
    border-right-color: #2D5A87;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================================
   16. RESPONSIVE
   =================================== */
@media (max-width: 1024px) and (min-width: 769px) {
    .location-time-input { font-size: 0.8rem; min-width: 78px; }
}

@media (max-width: 768px) {
    .planning-modal { width: 96%; max-height: 92vh; }
    .planning-modal-header { padding: 14px 16px; }
    .planning-modal-title { font-size: 1.05rem; }
    .planning-modal-body { padding: 14px 14px; }
    .day-card-header { flex-wrap: wrap; gap: 8px; }
    .planning-modal-footer { flex-direction: column; gap: 8px; }
    .btn-planning { width: 100%; justify-content: center; }
    .location-item { flex-wrap: wrap; }
    .location-time-wrapper { width: 100%; margin-left: 36px; }
    .location-time-input { flex: 1; min-width: auto; }
}