:root {
    /* Paleta E-Mobility (Carbono, Prata e Verde Elétrico) */
    --bg-color: #0b0f19;        
    --card-bg: #151e2e;         
    --primary-color: #00e676;   
    --primary-hover: #00c853;   
    --text-color: #f8fafc;      
    --text-muted: #94a3b8;      
    --border-color: #1e293b;    
    
    --border-radius: 6px;       
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.25);
    --glow: 0 0 15px rgba(0, 230, 118, 0.25); 
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', system-ui, sans-serif; }
body { background-color: var(--bg-color); color: var(--text-color); display: flex; min-height: 100vh; overflow-x: hidden; }

/* Layout Base */
.app-container { display: flex; width: 100%; min-height: 100vh; }
.sidebar { width: 260px; background: var(--card-bg); border-right: 1px solid var(--border-color); padding: 2rem 1.5rem; display: flex; flex-direction: column; flex-shrink: 0; }
.nav-link { color: var(--text-muted); text-decoration: none; padding: 0.85rem 1rem; margin-bottom: 0.5rem; border-radius: var(--border-radius); transition: all 0.3s ease; font-weight: 500; display: flex; align-items: center; gap: 10px; }
.nav-link:hover, .nav-link.active { background: rgba(0, 230, 118, 0.1); color: var(--primary-color); }
.main-content { flex: 1; padding: 2.5rem; overflow-y: auto; background: radial-gradient(circle at top right, #111827, var(--bg-color)); width: 100%; }

/* Botões */
.btn, .btn-auth { 
    background-color: var(--primary-color); 
    color: #0b0f19; 
    border: 1px solid rgba(0,0,0,0.2); 
    padding: 0.75rem 1.5rem; 
    border-radius: var(--border-radius); 
    cursor: pointer; 
    font-weight: 800; 
    text-transform: uppercase; 
    letter-spacing: 1px;
    font-size: 0.85rem;
    transition: all 0.2s ease; 
    text-align: center;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    display: inline-block;
}
.btn:hover, .btn-auth:hover { background-color: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--glow); }
.btn-block { display: block; width: 100%; }
.btn-secondary { background-color: transparent; border: 1px solid var(--border-color); color: var(--text-color); }
.btn-secondary:hover { background-color: var(--border-color); color: #fff; }

/* Inputs e Formulários */
.input-group { margin-bottom: 1.25rem; text-align: left; width: 100%; }
.input-group label { display: block; margin-bottom: 0.5rem; font-size: 0.75rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.input-group input, .input-group select { 
    width: 100%; padding: 0.85rem; background-color: rgba(0,0,0,0.3); 
    border: 1px solid var(--border-color); color: var(--text-color);
    border-radius: var(--border-radius); outline: none; transition: all 0.2s ease; font-size: 0.95rem;
}
.input-group input:focus, .input-group select:focus { border-color: var(--primary-color); box-shadow: inset 0 0 0 1px var(--primary-color); }

/* Área de Login */
.auth-wrapper { display: flex; width: 100vw; min-height: 100vh; align-items: center; justify-content: center; padding: 1.5rem; background: radial-gradient(circle at center, #151e2e, var(--bg-color)); }
.auth-box { 
    background: var(--card-bg); padding: 3rem 2.5rem; border-radius: 12px; 
    box-shadow: var(--shadow-lg); width: 100%; max-width: 420px; text-align: center;
    border: 1px solid rgba(0, 230, 118, 0.15); position: relative; overflow: hidden;
}
.auth-box::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 4px; background: linear-gradient(90deg, var(--primary-color), transparent); }
.auth-logo { max-width: 140px; margin-bottom: 1.5rem; display: block; margin-left: auto; margin-right: auto; }
.auth-title { font-size: 1.6rem; font-weight: 700; color: var(--text-color); margin-bottom: 0.5rem; letter-spacing: -0.5px; }
.auth-subtitle { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 2rem; }

/* Grid e Cards - min(100%, 260px) garante que não vaze a tela no celular */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 1.5rem; margin-top: 1.5rem; width: 100%; }
.card { 
    background: var(--card-bg); border-radius: var(--border-radius); overflow: hidden; 
    box-shadow: var(--shadow-md); transition: transform 0.3s ease, border-color 0.3s ease; 
    display: flex; flex-direction: column; border: 1px solid var(--border-color); position: relative;
    width: 100%;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--glow); border-color: rgba(0, 230, 118, 0.4); }
.card-img { width: 100%; height: 160px; object-fit: cover; border-bottom: 1px solid var(--border-color); opacity: 0.9; transition: opacity 0.3s; }
.card:hover .card-img { opacity: 1; }
.card-body { padding: 1.5rem; flex: 1; display: flex; flex-direction: column; justify-content: space-between; gap: 1rem; }
.card-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text-color); }
.card-desc { font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; }

/* Badges e Favoritos */
.badge { font-size: 0.65rem; font-weight: 700; padding: 4px 8px; border-radius: 4px; margin-bottom: 10px; display: inline-block; text-transform: uppercase; letter-spacing: 1px; }
.badge-tech { background: rgba(0, 230, 118, 0.1); color: var(--primary-color); border: 1px solid rgba(0, 230, 118, 0.2); }

.fav-btn {
    background: rgba(11, 15, 25, 0.8); backdrop-filter: blur(4px); color: var(--text-muted); border: 1px solid var(--border-color);
    font-size: 1.2rem; cursor: pointer; position: absolute; top: 12px; right: 12px; z-index: 10;
    border-radius: 50%; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; transition: all 0.2s ease;
}
.fav-btn:hover { transform: scale(1.1); background: var(--card-bg); color: #fff; }
.fav-btn.active-fav { color: var(--primary-color); border-color: var(--primary-color); box-shadow: var(--glow); }

/* Componentes Visuais */
.loader-container { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4rem 1rem; width: 100%; text-align: center; }
.spinner { width: 45px; height: 45px; border: 3px solid rgba(0, 230, 118, 0.1); border-top-color: var(--primary-color); border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 1rem; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* =========================================================
   REGRAS DE RESPONSIVIDADE TOTAL (MOBILE & TABLETS)
========================================================= */

@media (max-width: 900px) {
    /* Barra de cabeçalho da Biblioteca vira coluna */
    .main-content > div:first-child { flex-direction: column; align-items: stretch !important; gap: 1rem; }
    .main-content > div:first-child > div { display: flex; flex-direction: column; gap: 0.5rem; width: 100%; }
    #searchInput { width: 100%; min-width: unset; }
    #searchBtn, #clearBtn, #btnResgatar { width: 100%; }
}

@media (max-width: 768px) {
    .app-container { flex-direction: column; }
    
    /* Menu Lateral vira Menu Superior Fixo/Scrollável */
    .sidebar { width: 100%; padding: 1rem; border-right: none; border-bottom: 1px solid var(--border-color); flex-direction: row; justify-content: center; align-items: center; flex-wrap: wrap; gap: 10px; }
    .sidebar h2 { width: 100%; text-align: center; margin-bottom: 0.5rem !important; font-size: 1.3rem; justify-content: center; }
    .nav-link { padding: 0.6rem 0.8rem; font-size: 0.85rem; margin-bottom: 0; flex: 1; justify-content: center; text-align: center; white-space: nowrap; }
    #btnLogout { width: 100%; margin-top: 0.5rem !important; }
    
    .main-content { padding: 1.5rem; }
    
    /* Modais menores */
    .custom-modal-box { padding: 1.5rem; width: 95%; margin: 10px; max-height: 85vh; }
    .custom-modal-box form > div:last-child { flex-direction: column; }
    .custom-modal-box form button { width: 100%; }
    
    /* Admin - Painel de Controle Desktop -> Mobile */
    .stats-row { grid-template-columns: 1fr; gap: 1rem; }
    .form-section { padding: 1.5rem; }
    
    /* Admin - Listas empilhadas no celular para evitar quebra de layout */
    .list-item { flex-direction: column; align-items: flex-start; gap: 12px; }
    .list-item > div:first-child { width: 100%; }
    .list-item > div:last-child { width: 100%; display: flex; gap: 8px; justify-content: flex-start; }
    .action-btn { flex: 1; padding: 8px; text-align: center; border: 1px solid var(--border-color); }
}

@media (max-width: 480px) {
    /* Telas muito pequenas (Smartphones menores) */
    .auth-box { padding: 2rem 1.25rem; border-radius: 8px; border-left: none; border-right: none; }
    .auth-title { font-size: 1.35rem; }
    .nav-link { flex-basis: 100%; } /* Botões do menu um em cima do outro */
    .main-content h1 { font-size: 1.4rem; text-align: center; }
    .card-img { height: 180px; } 
}