@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;1,400&family=Inter:wght@400;500;600;800&display=swap');

:root {
    --primary-color: #5548E1;
    --primary-light: #8E84F3;
    --accent-color: #00D2D3;
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --bg-login: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --text-color: #2D3436;
    --text-muted: #636e72;
    --sidebar-width: 380px;
    --radius-m: 16px;
    --radius-s: 12px;
}

/* Base Reset */
html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    width: 100%;
    font-family: 'Inter', sans-serif;
    color: var(--text-color);
}

/* =========================================
   LOGIN / SIGNUP LAYOUT
   Only applies to body.login-layout
   ========================================= */
body.login-layout {
    background: var(--bg-login);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* Decorative Circles */
body.login-layout::before {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    top: -50px;
    left: -50px;
}

body.login-layout::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: rgba(0, 210, 211, 0.2);
    bottom: -50px;
    right: -50px;
}

.login-container {
    background: rgba(255, 255, 255, 0.95);
    padding: 3rem;
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 420px;
    text-align: center;
    z-index: 10;
    backdrop-filter: blur(10px);
}

/* =========================================
   PLANNER APP LAYOUT
   Only applies to body.app-layout
   ========================================= */
body.app-layout {
    background-color: #f0f2f5;
    background-image: none;
    /* Explicitly remove gradient */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent body scroll */
}

.app-container {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: white;
    box-shadow: 5px 0 25px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    z-index: 20;
    padding: 0;
    /* 移除全局 padding，让子区域自己控制 */
    box-sizing: border-box;
    height: 100%;
    overflow: hidden;
    /* 裁剪溢出的拖拽元素 */
}

.sidebar-header h2 {
    margin: 0 0 20px 0;
    font-size: 1.6rem;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Map Area */
.map-container {
    flex: 1;
    position: relative;
    height: 100%;
    width: 100%;
    background-color: #f0f2f5;
    /* Prevent black flash */
}

#map {
    width: 100%;
    height: 100%;
    background-color: #f0f2f5;
    /* Prevent black flash while tiling */
}

.map-search-box {
    position: absolute;
    top: 15px;
    left: 15px;
    width: 280px;
    padding: 12px 20px;
    border-radius: 30px;
    border: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    z-index: 5;
    outline: none;
}

/* 适应视图按钮悬停效果 */
#btn-fit-bounds:hover {
    background: #f8f9fa;
    transform: scale(1.05);
}

#btn-fit-bounds:active {
    transform: scale(0.95);
}

/* =========================================
   COMMON COMPONENTS
   ========================================= */
/* Buttons */
.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: var(--radius-s);
    cursor: pointer;
    font-weight: 700;
    transition: transform 0.2s;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-secondary {
    background: #eee;
    color: #333;
}

/* Forms */
input,
select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: var(--radius-s);
    box-sizing: border-box;
    margin-bottom: 15px;
}

input:focus {
    border-color: var(--primary-color);
    outline: none;
}

/* Trip Cards and Lists */
.trip-card {
    position: relative;
    background: white;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 10px;
    border: 1px solid #eee;
    cursor: pointer;
    transition: all 0.2s;
}

.trip-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.trip-card h4 {
    margin: 0 0 5px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 30px;
    /* Prevent overlap with delete button */
}

/* Day Panels */
.day-container {
    background: white;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid #eee;
}

.day-header {
    font-weight: 800;
    color: var(--primary-color);
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
    margin-bottom: 10px;
}

.trip-places-list {
    list-style: none;
    padding: 0;
    min-height: 20px;
    /* Dropzone area */
}

.place-item {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: grab;
    user-select: none;
    /* 防止拖拽时选中文字 */
    -webkit-user-select: none;
}

/* Modals */
.modal {
    display: none;
    /* Hidden by default */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    color: #aaa;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
    z-index: 10;
}

.close:hover,
.close:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}


/* TRIP DETAIL VIEW - FIXED LAYOUT */
.trip-detail-view {
    display: flex;
    flex-direction: column;
    /* Force Stacked Layout (Rows) */
    height: 100%;
}

.detail-header {
    flex-shrink: 0;
    padding: 20px;
    border-bottom: 1px solid #eee;
    background: #fff;
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Dragging State Global */
body.dragging-active,
body.dragging-active * {
    user-select: none;
    -webkit-user-select: none;
    cursor: grabbing !important;
}

/* Hide original item but keep layout space (optional, Sortable usually handles this with ghostClass) */
.sortable-ghost {
    opacity: 0.4;
    background: #f3f4f6;
    border: 2px dashed #d1d5db;
    box-shadow: none;
}

/* Color Palette Buttons */
.color-btn {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #fff;
    cursor: pointer;
    box-shadow: 0 0 0 1px #E5E7EB;
    transition: transform 0.2s, box-shadow 0.2s;
    padding: 0;
}

.color-btn:hover {
    transform: scale(1.2);
    box-shadow: 0 0 0 1px #9CA3AF;
    z-index: 1;
}

#daysContent {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 20px;

    position: relative;
}

/* Forced Scroll Override */
#daysContent {
    overflow-y: auto !important;
    flex: 1 1 auto !important;
    height: auto !important;
    min-height: 0 !important;
}