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

:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --danger: #d93025;
    --text: #202124;
    --text-secondary: #5f6368;
    --bg: #ffffff;
    --bg-hover: #f1f3f4;
    --border: #dadce0;
    --shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
    --sidebar-width: 340px;
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    overflow: hidden;
    height: 100vh;
}

#app {
    display: flex;
    height: 100vh;
}

/* Map */
#map {
    flex: 1;
    z-index: 1;
}

/* Sidebar */
#sidebar {
    width: var(--sidebar-width);
    background: var(--bg);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
}

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

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

.offline-badge {
    background: #ea4335;
    color: #fff;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 12px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Tabs */
.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-btn:hover {
    background: var(--bg-hover);
}

/* Tab Content */
.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 12px 20px;
}

.tab-content.active {
    display: block;
}

/* Spot List */
.spot-count {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.spot-list {
    list-style: none;
}

.spot-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    cursor: default;
}

.spot-item:last-child {
    border-bottom: none;
}

.spot-check {
    margin-top: 3px;
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

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

.spot-name {
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.spot-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.spot-stars {
    color: #fbbc04;
    font-size: 13px;
}

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

.spot-actions button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 16px;
    padding: 2px 4px;
    border-radius: 4px;
}

.spot-actions button:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.empty-hint {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Route */
.route-hint {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.route-waypoints {
    list-style: none;
    counter-reset: waypoint;
}

.route-waypoint {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #e8f0fe;
    border-radius: var(--radius);
    margin-bottom: 6px;
    font-size: 13px;
}

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

.route-waypoint-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#route-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.route-info {
    background: #e8f5e9;
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-top: 16px;
}

.route-info h4 {
    margin-bottom: 6px;
    font-size: 14px;
}

.route-info p {
    font-size: 13px;
    margin-top: 4px;
}

/* Buttons */
.btn-primary {
    flex: 1;
    padding: 10px 20px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-primary:disabled {
    background: #a8c7fa;
    cursor: not-allowed;
}

.btn-secondary {
    padding: 10px 20px;
    background: var(--bg-hover);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
}

.btn-sm {
    padding: 4px 10px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    color: var(--text-secondary);
}

.btn-sm:hover {
    background: var(--bg-hover);
}

.btn-danger {
    color: var(--danger);
    border-color: var(--danger);
}

.btn-danger:hover {
    background: #fce8e6;
}

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

/* Modal */
.modal.hidden {
    display: none;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
}

.modal-content {
    position: relative;
    background: var(--bg);
    border-radius: 12px;
    padding: 24px;
    width: 380px;
    max-width: 90vw;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal-content h3 {
    margin-bottom: 16px;
    font-size: 18px;
}

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

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

.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input[type="text"]:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.15);
}

.coords-text {
    font-size: 13px;
    color: var(--text-secondary);
    font-family: "SF Mono", "Roboto Mono", monospace;
}

/* Star Rating */
.star-rating {
    display: flex;
    gap: 4px;
}

.star {
    font-size: 24px;
    color: #dadce0;
    cursor: pointer;
    transition: color 0.15s;
    user-select: none;
}

.star.active,
.star.hover {
    color: #fbbc04;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    align-items: center;
}

/* Leaflet Overrides */
.leaflet-popup-content-wrapper {
    border-radius: 8px !important;
}

.leaflet-popup-content {
    margin: 12px 16px !important;
    min-width: 180px;
}

.popup-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}

.popup-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.popup-stars {
    color: #fbbc04;
    font-size: 14px;
    margin-bottom: 6px;
}

.popup-coords {
    font-size: 11px;
    color: #9aa0a6;
    font-family: monospace;
}

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

.popup-actions button {
    padding: 3px 10px;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    cursor: pointer;
}

.popup-actions button:hover {
    background: var(--bg-hover);
}

/* Custom Marker */
.custom-marker {
    background: none;
    border: none;
}

.marker-pin {
    width: 30px;
    height: 40px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.marker-pin svg {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* Utility */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        transform: translateX(100%);
        box-shadow: -4px 0 16px rgba(0,0,0,0.1);
    }

    #sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: flex;
    }

    #sidebar.open ~ .sidebar-toggle {
        right: calc(var(--sidebar-width) + 12px);
    }
}

/* Loading spinner for route calculation */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 6px;
    vertical-align: middle;
}

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