/* ---------------- Coluna da Esquerda / Sidebar (Desktop Padrão) ---------------- */
.sidebar {
    position: fixed;
    left: 20px;
    top: 20px;
    width: 240px;
    background: #fff;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    z-index: 10;
    transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    
    /* Permite rolagem no desktop se a sidebar for maior que a tela */
    max-height: 90vh;
    overflow-y: auto; 
}

.button-row {
    display: flex;
    gap: 10px;      
    margin-top: 10px; 
}

.sidebar .list-title { 
    font-weight: bold;
    font-size: 0.95em;
    color: #34495e;
    margin-bottom: 6px;
}

.sidebar input, .sidebar select, .sidebar button {
    margin-bottom: 10px;
    padding: 7px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 0.95em;
    width: 100%;
    box-sizing: border-box;
}

.sidebar button {
    cursor: pointer;
    background: #3498db;
    color: #fff;
    border: none;
    transition: 0.2s;
}

.sidebar button:hover {
    background: #2980b9;
}

.sidebar .export-btn {
    margin-top: 6px;
    background: #27ae60;
}
.sidebar .export-btn:hover { background: #1e8449; }

.sidebar .info-text {
    font-size: 0.75em;
    color: #555;
    margin-top: 12px;
    line-height: 1.3;
}

/* ---------------- POPUP E BOTÕES DE AÇÃO ---------------- */

.popup-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(2px);
}

.popup-box {
    background: #fff;
    padding: 25px;
    border-radius: 12px;
    width: 320px;
    font-family: Arial, sans-serif;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    animation: popupFadeIn 0.2s ease-out;
}

@keyframes popupFadeIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.popup-box h3 {
    margin-top: 0;
    color: #2c3e50;
    text-align: center;
}

.popup-box input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
}

.popup-box button {
    cursor: pointer;
    border: none;
    border-radius: 5px;
    padding: 10px;
    font-weight: bold;
    color: white;
    transition: 0.2s;
}

.popup-box .confirm { background-color: #3498db; }
.popup-box .confirm:hover { background-color: #2980b9; }

.popup-box .cancel { background-color: #95a5a6; color: white; }
.popup-box .cancel:hover { background-color: #7f8c8d; }


#menuToggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 200; 
    background: #3498db;
    border: none;
    color: white;
    font-size: 1.5em;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* ======================================================== */
/* Regras Mobile & Landscape (max-width: 950px) - CORREÇÃO FINAL */
/* ======================================================== */

@media screen and (max-width: 950px) {

    .sidebar {
        position: fixed; 
        
        /* Centralização Absoluta */
        left: 50%;
        top: 20px; 
        
        /* -- CORREÇÃO DE LARGURA: Igual ao .container (450px ou 90% da tela) -- */
        width: 450px; 
        max-width: 90%; 
        
        /* Garante rolagem no modo paisagem */
        max-height: 85vh; 
        overflow-y: auto; 
        
        /* Estado Inicial (Escondido acima) */
        transform: translate(-50%, -150%);
        
        margin: 0; 
        padding: 50px 25px 25px 25px; 
        border-radius: 15px; 
        box-shadow: 0 10px 30px rgba(0,0,0,0.3);
        z-index: 100;
    }

    .sidebar.show {
        /* Estado Visível (Centralizado) */
        transform: translate(-50%, 0); 
    }
    
    #menuToggle {
        display: block; 
    }
    
    .container {
        margin-top: 80px !important;
        
        /* Força o .container a ter a largura máxima de 450px ou 90% da tela */
        width: 450px !important; 
        max-width: 90% !important;
        
        margin-left: auto !important;
        margin-right: auto !important;
    }
}