:root {
    --primary-color: #fbc02d;
    --secondary-color: #333;
    --bg-light: #ffffff;
    --text-dark: #212121;
    --shadow: 0 2px 10px rgba(0,0,0,0.2);
    --sidebar-width: 300px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden;
}

#map_canvas {
    height: 100%;
    width: 100%;
}

/* Layout Principal */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar (Desktop) */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-light);
    box-shadow: var(--shadow);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

/* Header na Sidebar */
.sidebar-header {
    padding: 15px;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header img {
    height: 40px;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

/* Chips de Categoria */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.category-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    border-radius: 8px;
    border: 2px solid #eee;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    font-size: 11px;
    background: #f9f9f9;
}

.category-chip img {
    width: 24px;
    height: auto;
    margin-bottom: 5px;
}

.category-chip.active {
    border-color: var(--primary-color);
    background: #fffde7;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.category-chip input {
    display: none;
}

/* Botão Flutuante (FAB) */
.fab {
    position: absolute;
    bottom: 30px;
    left: 20px;
    width: 54px;
    height: 54px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: var(--shadow);
    cursor: pointer;
    z-index: 90;
    color: var(--secondary-color);
    transition: transform 0.2s, background 0.2s;
    user-select: none;
    font-size: 24px;
    padding: 0;
    margin: 0;
    text-align: center;
}

.fab i {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1 !important;
}

.fab:hover {
    transform: scale(1.1);
    background: #fdd835;
}

/* Botão de GPS */
.fab-gps {
    position: absolute;
    bottom: 95px;
    left: 24px;
    width: 45px;
    height: 45px;
    background: white;
    border-radius: 50%;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: var(--shadow);
    cursor: pointer;
    z-index: 90;
    color: #333;
    transition: transform 0.2s;
    font-size: 20px;
}
.fab-gps:hover { transform: scale(1.1); }

/* Overlay de Loading */
#loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.9);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
}

/* Toast Notifications (Substituto do Alert) */
#toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2147483647;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    width: max-content;
}

.toast-msg {
    min-width: 280px;
    max-width: 90vw;
    background: #222 !important;
    color: #fff !important;
    border-radius: 8px;
    padding: 15px 20px;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 5px 20px rgba(0,0,0,0.4);
    transition: all 0.3s ease;
    pointer-events: auto;
    animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 5px solid #fff;
}

.toast-msg.error { border-left-color: #f44336 !important; }
.toast-msg.success { border-left-color: #4caf50 !important; }
.toast-msg.info { border-left-color: #fbc02d !important; color: #fbc02d !important; }

.toast-msg i { font-size: 20px; }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUpMobile {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Painéis de Filtro/Busca (Modais) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}

/* Navegação Mobile (Hidden by default) */
.bottom-nav {
    display: none;
}

/* Painel de Detalhes (Side/Bottom Panel) */
#details-panel {
    position: fixed;
    background: white;
    z-index: 300;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.2);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.details-content {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
    line-height: 1.6;
    color: #444;
}

.close-details {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #eee;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-weight: bold;
    z-index: 310;
}

/* Compartilhamento */
.share-section {
    margin: 25px 0;
    border-top: 1px solid #eee;
    padding-top: 15px;
}

.share-label {
    font-size: 12px;
    font-weight: bold;
    color: #999;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.share-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.share-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: transform 0.2s, background 0.2s;
    font-size: 18px;
}

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

.btn-fb { background: #1877f2; color: white; }
.btn-x { background: #000; color: white; }
.btn-wa { background: #25d366; color: white; }
.btn-li { background: #0a66c2; color: white; }

/* Botão de Rota Refinado */
.route-form {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 12px;
    margin-top: 20px;
}

.route-form input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-bottom: 8px;
}

/* Responsividade Mobile */
@media (max-width: 768px) {
    .sidebar-content {
        padding-bottom: 90px; /* Evita que o último botão fique atrás da barra de baixo */
    }

    .sidebar {
        position: fixed;
        left: 0;
        bottom: 0;
        width: 100%;
        height: 80%;
        transform: translateY(100%);
        border-radius: 20px 20px 0 0;
    }

    .sidebar.open {
        transform: translateY(0);
    }

    .fab {
        bottom: 90px;
        left: 20px;
    }

    .fab-gps {
        bottom: 155px; /* Fica acima do botão de + no celular */
    }

    .bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 70px;
        background: white;
        display: flex;
        justify-content: space-around;
        align-items: center;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        z-index: 150;
        padding-bottom: 10px;
    }
    
    .bottom-nav div {
        text-align: center;
        font-size: 10px;
        flex: 1;
    }

    #details-panel {
        left: 0;
        right: 0;
        bottom: 0;
        height: 70vh;
        transform: translateY(100%);
        border-radius: 20px 20px 0 0;
    }
    #details-panel.open {
        transform: translateY(0);
    }
    .panel-handle {
        width: 40px;
        height: 5px;
        background: #ddd;
        border-radius: 10px;
        margin: 10px auto;
    }

    #toast-container {
        top: auto;
        bottom: 110px;
    }
    
    .toast-msg {
        animation: slideUpMobile 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    }

    .desktop-only {
        display: none !important;
    }
}

/* Responsividade Desktop */
@media (min-width: 769px) {
    #details-panel {
        top: 0;
        right: 0;
        width: 400px;
        height: 100vh;
        transform: translateX(100%);
    }
    #details-panel.open {
        transform: translateX(0);
    }
    .panel-handle { display: none; }

    .bottom-nav, .mobile-only {
        display: none !important;
    }
    
    .desktop-only {
        display: block !important;
    }
}
