:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --bg-color: #f3f4f6;
    --text-color: #1f2937;
    --card-bg: #ffffff;
    --border-color: #e5e7eb;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Kanit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
    /* Prevent body scroll, map handles it */
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

.sidebar {
    width: 350px;
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    z-index: 1000;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
}

.sidebar-header {
    margin-bottom: 2rem;
}

.sidebar-header h2 {
    color: var(--primary-color);
}

.waypoints-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.waypoint-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.75rem;
    background: #f9fafb;
    padding: 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.waypoint-marker {
    width: 24px;
    height: 24px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    margin-right: 0.5rem;
    flex-shrink: 0;
}

.waypoint-input {
    flex: 1;
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9rem;
    width: 100%;
}

.waypoint-details {
    flex: 1;
    overflow: hidden;
}

.waypoint-title {
    font-size: 0.9rem;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.waypoint-subtitle {
    font-size: 0.8rem;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.waypoint-remove {
    color: #ef4444;
    cursor: pointer;
    margin-left: 0.5rem;
    padding: 0.25rem;
}

#map {
    flex: 1;
    height: 100%;
    z-index: 1;
}

/* Landing Page Re-styles */
.landing-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 2rem;
}

h1 {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    text-decoration: none;
    font-weight: 600;
    transition: background-color 0.2s;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: white;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.btn-secondary:hover {
    background-color: #f9fafb;
}

.btn-text {
    background: none;
    color: #6b7280;
}

.btn-text:hover {
    color: var(--text-color);
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    width: 90%;
    max-width: 400px;
}

.modal-content input {
    width: 100%;
    padding: 0.5rem;
    margin: 1rem 0;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Tracking Page Specifc */
.map-page-container {
    position: relative;
    height: 100vh;
}

.radar-marker {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* The red dot itself */
.radar-core {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    background-color: #ef4444;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    z-index: 2;
    animation: pulse-dot 2s infinite ease-in-out;
}

/* The radiating ring */
.radar-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    /* Slightly larger base size */
    height: 60px;
    background-color: rgba(239, 68, 68, 0.4);
    border-radius: 50%;
    z-index: 1;
    animation: pulse-ring 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

/* Fix animation origins since we are now centering via translate */
@keyframes pulse-ring {
    0% {
        width: 20px;
        height: 20px;
        opacity: 1;
    }

    80%,
    100% {
        width: 80px;
        height: 80px;
        opacity: 0;
    }
}

@keyframes pulse-dot {
    0% {
        width: 20px;
        height: 20px;
    }

    50% {
        width: 24px;
        height: 24px;
    }

    100% {
        width: 20px;
        height: 20px;
    }
}

.controls {
    position: absolute;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Mobile Adjustments */
@media (max-width: 640px) {
    .controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .actions {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .actions button {
        width: 100%;
        text-align: center;
    }

    #tripNoteDisplay {
        top: auto !important;
        bottom: 20px;
        left: 10px;
        right: 10px;
        max-width: none !important;
    }
}

/* Create Route Mobile Responsive */
/* Create Route Mobile Responsive */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    #mobileSidebarToggle {
        display: flex !important;
    }

    .sidebar {
        width: 100%;
        height: 75%;
        /* Increased height to ensure buttons fit */
        position: fixed;
        bottom: 0px;
        left: 0;
        right: 0;
        z-index: 1500;
        transition: transform 0.3s ease-in-out;
        transform: translateY(100%);
        /* Hidden by default (slid down) */

        order: 2;
        border-right: none;
        border-top: 1px solid var(--border-color);
        padding: 0.75rem;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
        box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        background: white;
    }

    .sidebar.active {
        transform: translateY(0);
    }

    .waypoints-list {
        flex: 1 1 auto;
        overflow-y: auto;
        min-height: 100px;
        border: 1px dashed #e5e7eb;
        border-radius: 4px;
        padding: 5px;
    }

    /* Single line waypoint details */
    .waypoint-details {
        display: flex;
        flex-direction: row;
        align-items: baseline;
        gap: 0.5rem;
    }

    .waypoint-title {
        min-width: fit-content;
    }

    #map {
        width: 100%;
        height: 100%;
        order: 1;
    }

    /* Hide non-essential elements to save space */
    .sidebar-header p,
    .search-controls p,
    .sidebar-header h2 {
        display: none !important;
    }

    /* Make headers very compact */
    .sidebar-header,
    .sidebar-header h3 {
        margin: 0 !important;
        font-size: 0.95rem !important;
        padding: 0 !important;
    }

    /* Compact Search Controls */
    .search-controls {
        margin-bottom: 0 !important;
        padding-bottom: 0.5rem !important;
        border-bottom: 1px solid #e5e7eb;
    }

    .search-controls label {
        display: none !important;
    }

    /* Compact Note Area */
    #tripNote {
        height: 2.5rem;
        padding: 0.25rem;
    }

    /* Footer Buttons Side-by-Side */
    .sidebar-footer {
        display: flex;
        gap: 0.5rem;
        margin-top: auto;
        flex-shrink: 0;
    }

    .sidebar-footer>* {
        flex: 1;
        width: auto !important;
        margin: 0 !important;
        padding: 0.5rem !important;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .btn {
        padding: 0.5rem 1rem;
    }

    /* Revert search toggle visibility, since whole sidebar toggles */
    #toggleSearchBtn {
        display: none !important;
    }

    #searchControlsArea {
        display: block !important;
    }
}