/* ============================================
   TravelMap - Main Frontend Styles
   ============================================ */

:root {
    --primary: #38bdf8;
    --primary-dark: #0ea5e9;
    --accent: #818cf8;
    --bg-dark: #0f172a;
    --bg-sidebar: #1e293b;
    --bg-card: #1e293b;
    --bg-input: rgba(255,255,255,0.06);
    --border: rgba(255,255,255,0.1);
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --radius: 12px;
    --sidebar-width: 340px;
    --detail-width: 420px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* ---- Sidebar ---- */
.sidebar {
    position: fixed; top: 0; left: 0;
    width: var(--sidebar-width); height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    z-index: 1000;
    display: flex; flex-direction: column;
    overflow-y: auto;
    transition: transform var(--transition);
}

.sidebar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex; align-items: center; gap: 10px;
}

.sidebar-logo .material-symbols-outlined {
    font-size: 28px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text { font-size: 18px; font-weight: 700; }

.sidebar-actions { display: flex; gap: 4px; }

.icon-btn {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 12px; font-weight: 600;
    transition: all 0.15s;
}

.icon-btn:hover { background: rgba(255,255,255,0.1); color: var(--text); }
.icon-btn .material-symbols-outlined { font-size: 20px; }

.sidebar-section {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

/* ---- Search ---- */
.search-box {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0 14px;
    transition: border-color 0.2s;
}

.search-box:focus-within { border-color: var(--primary); }
.search-box .material-symbols-outlined { font-size: 20px; color: var(--text-muted); }

.search-box input {
    flex: 1; padding: 12px 0;
    background: none; border: none; color: var(--text);
    font-size: 14px; font-family: 'Inter', sans-serif;
    outline: none;
}

.search-box input::placeholder { color: var(--text-muted); }

/* ---- View Toggle ---- */
.view-toggle {
    display: flex; gap: 4px;
    background: var(--bg-input);
    border-radius: var(--radius);
    padding: 4px;
}

.view-btn {
    flex: 1; padding: 8px;
    background: none; border: none;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 13px; font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.15s;
}

.view-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
}

.view-btn:not(.active):hover { color: var(--text); }

/* ---- Section Header ---- */
.section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px;
}

.section-header h3 { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

.text-btn {
    background: none; border: none;
    color: var(--primary);
    font-size: 12px; font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: color 0.15s;
}

.text-btn:hover { color: var(--accent); }

/* ---- Filter List ---- */
.filter-list {
    display: flex; flex-direction: column; gap: 4px;
    max-height: 200px; overflow-y: auto;
}

.filter-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 13px;
}

.filter-item:hover { background: rgba(255,255,255,0.04); }

.filter-item input[type="checkbox"],
.filter-item input[type="radio"] {
    appearance: none; width: 18px; height: 18px;
    border: 2px solid var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: all 0.15s;
}

.filter-item input[type="radio"] {
    border-radius: 50%;
}

.filter-item input[type="checkbox"]:checked,
.filter-item input[type="radio"]:checked {
    background: var(--primary);
    border-color: var(--primary);
}

.filter-item input[type="checkbox"]:checked::after,
.filter-item input[type="radio"]:checked::after {
    content: '✓'; position: absolute;
    top: 50%; left: 50%; transform: translate(-50%, -50%);
    color: #fff; font-size: 12px; font-weight: 700;
}

.filter-item input[type="radio"]:checked::after {
    content: ''; width: 8px; height: 8px;
    background: #fff; border-radius: 50%;
}

.filter-icon {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.filter-icon .material-symbols-outlined { font-size: 16px; }

.filter-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.filter-label { color: var(--text); flex: 1; }
.filter-count { color: var(--text-muted); font-size: 11px; }

/* ---- Map ---- */
#map {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    bottom: 0;
    z-index: 1;
}

/* Custom Map Markers */
.custom-marker {
    position: relative;
    display: flex; align-items: center; justify-content: center;
}

.marker-icon {
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 3px 12px rgba(0,0,0,0.3);
    border: 3px solid #fff;
    transition: transform 0.15s;
}

.marker-icon:hover { transform: scale(1.15); }
.marker-icon .material-symbols-outlined { font-size: 20px; }

.visit-dot {
    position: absolute; top: -2px; right: -2px;
    width: 12px; height: 12px;
    border-radius: 50%;
    border: 2px solid #fff;
    z-index: 2;
}

.visit-dot.want { background: var(--warning); }
.visit-dot.visited { background: var(--success); }

/* Cluster styles */
.marker-cluster-small { background-color: rgba(56, 189, 248, 0.3); }
.marker-cluster-small div { background-color: rgba(56, 189, 248, 0.7); }
.marker-cluster-medium { background-color: rgba(129, 140, 248, 0.3); }
.marker-cluster-medium div { background-color: rgba(129, 140, 248, 0.7); }
.marker-cluster-large { background-color: rgba(168, 85, 247, 0.3); }
.marker-cluster-large div { background-color: rgba(168, 85, 247, 0.7); }

.marker-cluster div {
    width: 36px; height: 36px;
    margin: 5px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 13px;
    font-family: 'Inter', sans-serif;
}

/* ---- Map tile gap fix ---- */
.leaflet-tile {
    outline: 1px solid transparent;
    backface-visibility: hidden;
}

.leaflet-tile-container {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* ---- Popup ---- */
.leaflet-popup-content-wrapper {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: 16px !important;
    box-shadow: 0 15px 40px rgba(0,0,0,0.4) !important;
    padding: 0 !important;
    overflow: hidden;
}

.leaflet-popup-content { margin: 0 !important; width: 280px !important; }
.leaflet-popup-tip { background: var(--bg-card) !important; border: 1px solid var(--border) !important; }

.popup-card { overflow: hidden; }

.popup-gallery {
    position: relative; width: 100%; height: 180px;
    background: #0f172a;
    overflow: hidden;
}

.popup-gallery img {
    width: 100%; height: 100%; object-fit: cover;
}

.popup-gallery-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 30px; height: 30px;
    background: rgba(0,0,0,0.5); border: none;
    border-radius: 50%; color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 2;
    transition: background 0.15s;
}

.popup-gallery-nav:hover { background: rgba(0,0,0,0.8); }
.popup-gallery-nav.prev { left: 8px; }
.popup-gallery-nav.next { right: 8px; }
.popup-gallery-nav .material-symbols-outlined { font-size: 18px; }

.popup-gallery-counter {
    position: absolute; bottom: 8px; right: 8px;
    background: rgba(0,0,0,0.6);
    color: #fff; font-size: 11px;
    padding: 3px 8px; border-radius: 10px;
}

.popup-no-image {
    width: 100%; height: 180px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #1e293b, #334155);
}

.popup-no-image .material-symbols-outlined { font-size: 48px; color: var(--text-muted); }

.popup-body { padding: 16px; }
.popup-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.popup-text { font-size: 13px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 12px;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.popup-category {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 500;
    margin-bottom: 12px;
}

.popup-category .material-symbols-outlined { font-size: 14px; }

.popup-visit-status {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; margin-bottom: 10px;
}

.popup-route-stats {
    display: flex; gap: 12px;
    font-size: 11px; color: var(--text-muted);
    margin-bottom: 8px;
}

.popup-route-stats span {
    display: flex; align-items: center; gap: 2px;
}

.popup-footer {
    display: flex; gap: 8px;
}

.popup-btn {
    flex: 1; padding: 8px;
    border: none; border-radius: 8px;
    font-size: 12px; font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.15s;
}

.popup-btn.detail {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
}

.popup-btn.detail:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(56, 189, 248, 0.3); }

.popup-btn.visit {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.popup-btn.visit:hover { border-color: var(--primary); color: var(--text); }

/* ---- Detail Panel ---- */
.detail-panel {
    position: fixed; top: 0; right: 0;
    width: var(--detail-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-left: 1px solid var(--border);
    z-index: 1001;
    transform: translateX(100%);
    transition: transform var(--transition);
    display: flex; flex-direction: column;
    overflow-y: auto;
}

.detail-panel.open { transform: translateX(0); }

.detail-header {
    display: flex; align-items: center; justify-content: flex-end;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.detail-content { flex: 1; overflow-y: auto; }

.detail-gallery {
    position: relative; width: 100%; height: 260px;
    background: #0f172a;
    overflow: hidden;
}

.detail-gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }

.detail-gallery-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 36px; height: 36px;
    background: rgba(0,0,0,0.6); border: none;
    border-radius: 50%; color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 2;
}

.detail-gallery-nav.prev { left: 12px; }
.detail-gallery-nav.next { right: 12px; }

.detail-gallery-counter {
    position: absolute; bottom: 12px; right: 12px;
    background: rgba(0,0,0,0.6);
    padding: 4px 10px; border-radius: 12px;
    font-size: 12px; color: #fff;
}

.detail-body { padding: 24px 20px; }

.detail-title { font-size: 22px; font-weight: 700; margin-bottom: 12px; line-height: 1.3; }

.detail-meta {
    display: flex; flex-wrap: wrap; gap: 8px;
    margin-bottom: 16px;
}

.detail-category {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 12px; border-radius: 20px;
    font-size: 12px; font-weight: 500;
}

.detail-category .material-symbols-outlined { font-size: 16px; }

.hashtag-badge {
    display: inline-flex; align-items: center;
    padding: 4px 10px; border-radius: 12px;
    font-size: 11px; font-weight: 500;
    color: #fff;
}

.detail-shorttext {
    font-size: 14px; color: var(--text-secondary);
    line-height: 1.6; margin-bottom: 16px;
    font-style: italic;
}

.detail-description {
    font-size: 14px; color: var(--text);
    line-height: 1.7; margin-bottom: 20px;
}

.detail-description img { max-width: 100%; border-radius: 8px; }
.detail-description h1, .detail-description h2, .detail-description h3 { margin: 16px 0 8px; }
.detail-description p { margin-bottom: 10px; }
.detail-description ul, .detail-description ol { padding-left: 20px; margin-bottom: 10px; }

.detail-info-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 0;
    border-top: 1px solid var(--border);
    font-size: 13px;
}

.detail-info-row .material-symbols-outlined { font-size: 18px; color: var(--text-muted); }
.detail-info-row a { color: var(--primary); text-decoration: none; }
.detail-info-row a:hover { text-decoration: underline; }

.detail-visit-actions {
    display: flex; gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.visit-action-btn {
    flex: 1; padding: 10px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: none;
    color: var(--text-secondary);
    font-size: 12px; font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    transition: all 0.15s;
}

.visit-action-btn:hover { border-color: var(--primary); color: var(--text); }
.visit-action-btn.active-want { border-color: var(--warning); color: var(--warning); background: rgba(245, 158, 11, 0.1); }
.visit-action-btn.active-visited { border-color: var(--success); color: var(--success); background: rgba(16, 185, 129, 0.1); }
.visit-action-btn .material-symbols-outlined { font-size: 16px; }

/* GPX Download */
.detail-gpx-download {
    margin-top: 16px; padding-top: 16px;
    border-top: 1px solid var(--border);
}

.gpx-download-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: 8px;
    border: 1px solid var(--primary); color: var(--primary);
    background: transparent; cursor: pointer; font-size: 13px;
    font-weight: 500; transition: all 0.2s;
}

.gpx-download-btn:hover {
    background: var(--primary); color: #fff;
}

.gpx-download-btn .material-symbols-outlined { font-size: 18px; }

/* Route detail specifics */
.detail-route-points {
    margin-top: 16px; padding-top: 16px;
    border-top: 1px solid var(--border);
}

.detail-route-points h4 {
    font-size: 13px; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.route-point-item {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 0;
    font-size: 13px;
}

.route-point-num {
    width: 24px; height: 24px;
    background: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 600; color: #fff;
    flex-shrink: 0;
}

.route-stat {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 14px;
    background: var(--bg-input);
    border-radius: 10px;
    font-size: 13px;
}

.route-stat .material-symbols-outlined { font-size: 18px; color: var(--primary); }

.route-stats { display: flex; gap: 8px; margin-bottom: 16px; }

/* ---- Modal ---- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
    align-items: center; justify-content: center;
}

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

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    width: 100%; max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 60px rgba(0,0,0,0.4);
}

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 { font-size: 18px; font-weight: 600; }

.modal-body { padding: 24px; }

.account-info {
    display: flex; align-items: center; gap: 16px;
    margin-bottom: 20px;
}

.account-avatar {
    width: 52px; height: 52px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}

.account-avatar .material-symbols-outlined { font-size: 28px; color: #fff; }

.badge {
    display: inline-block;
    padding: 3px 10px; border-radius: 12px;
    font-size: 11px; font-weight: 600;
    background: rgba(56, 189, 248, 0.15);
    color: var(--primary);
    margin-top: 4px;
}

.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block; font-size: 13px; font-weight: 500;
    color: var(--text-secondary); margin-bottom: 6px;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px; color: var(--text);
    font-size: 14px; font-family: 'Inter', sans-serif;
    transition: border-color 0.15s;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--primary);
}

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 20px; border: none; border-radius: 10px;
    font-size: 13px; font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer; transition: all 0.15s;
    gap: 6px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
}

.btn-primary:hover { box-shadow: 0 4px 15px rgba(56, 189, 248, 0.3); }

.btn-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }

.btn-outline { background: none; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--text-muted); color: var(--text); }

/* ---- Sidebar Toggle ---- */
.sidebar-toggle {
    display: none;
    position: fixed; top: 12px; left: 12px;
    z-index: 1002;
    width: 40px; height: 40px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    align-items: center; justify-content: center;
    cursor: pointer;
}

/* ---- Loading spinner ---- */
.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 40px auto;
}

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

/* ---- Toast notifications ---- */
.toast-container {
    position: fixed; bottom: 20px; right: 20px;
    z-index: 3000;
    display: flex; flex-direction: column; gap: 8px;
}

.toast {
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-size: 13px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease-out;
    display: flex; align-items: center; gap: 10px;
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast .material-symbols-outlined { font-size: 18px; }
.toast.success .material-symbols-outlined { color: var(--success); }
.toast.error .material-symbols-outlined { color: var(--danger); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .detail-panel { width: 100%; left: 0; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: flex; }
    #map { left: 0; }
    .detail-panel { width: 100%; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
