:root {
    --bg-color: #0f172a;
    --surface-color: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --font-family: 'Inter', sans-serif;
}

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

body {
    background: var(--bg-color);
    background-image: radial-gradient(circle at top right, #1e3a8a 0%, transparent 40%),
                      radial-gradient(circle at bottom left, #064e3b 0%, transparent 40%);
    color: var(--text-main);
    font-family: var(--font-family);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.glassmorphism {
    background: var(--surface-color);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* LOGIN */
.login-container {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    animation: fadeIn 0.5s ease-out;
    margin: auto;
}

.login-header { text-align: center; margin-bottom: 2rem; }
.login-header h2 { font-size: 1.8rem; font-weight: 700; margin-bottom: 0.5rem; }
.login-header p { color: var(--text-muted); font-size: 0.95rem; }

/* FORMS */
.input-group { margin-bottom: 1.5rem; }
.input-group label { display: block; margin-bottom: 0.5rem; font-size: 0.9rem; font-weight: 500; color: var(--text-muted); }
.input-group input, .input-group select {
    width: 100%; padding: 0.75rem 1rem; background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color); border-radius: 8px; color: var(--text-main); font-family: var(--font-family); font-size: 1rem; transition: all 0.2s ease;
}
.input-group input:focus, .input-group select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* BUTTONS */
.btn {
    display: inline-flex; align-items: center; justify-content: center; padding: 0.75rem 1.5rem;
    border-radius: 8px; font-weight: 600; font-size: 0.95rem; border: none; cursor: pointer;
    transition: all 0.2s ease; font-family: var(--font-family); text-decoration: none;
}
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4); }
.btn-danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid var(--danger); box-shadow: none; }
.btn-danger:hover { background: var(--danger); color: #fff; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4); border-color: transparent;}
.btn-block { width: 100%; }

/* ALERTS */
.alert { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1.5rem; font-size: 0.9rem; }
.alert-danger { background: rgba(239, 68, 68, 0.2); border: 1px solid var(--danger); color: #fca5a5; }
.alert-success { background: rgba(16, 185, 129, 0.2); border: 1px solid var(--success); color: #6ee7b7; }

/* DASHBOARD LAYOUT */
.dashboard-page { flex-direction: row; }
.sidebar {
    width: 260px; height: 100vh; position: fixed; top: 0; left: 0; padding: 2rem 1.5rem;
    display: flex; flex-direction: column; border-right: 1px solid var(--border-color); border-radius: 0;
    box-shadow: 5px 0 15px rgba(0,0,0,0.2); z-index: 100;
}
.sidebar-header { display: flex; justify-content: center; align-items: center; width: 100%; margin-bottom: 3rem; }
.sidebar .brand { font-size: 1.5rem; font-weight: 700; color: #fff; text-align: center; }
.menu-toggle { display: none; background: transparent; border: none; color: var(--text-main); cursor: pointer; padding: 0.5rem; border-radius: 8px; transition: background 0.2s; }
.menu-toggle:hover { background: rgba(255,255,255,0.1); }
.sidebar .nav-links { list-style: none; display: flex; flex-direction: column; gap: 0.5rem;}
.sidebar .nav-links a {
    display: block; padding: 0.75rem 1rem; color: var(--text-muted); text-decoration: none;
    border-radius: 8px; transition: all 0.2s ease;
}
.sidebar .nav-links a:hover, .sidebar .nav-links a.active {
    background: rgba(255, 255, 255, 0.05); color: #fff;
    transform: translateX(4px);
}
.sidebar .nav-links a.text-danger { color: #fca5a5; margin-top: auto; }

.main-content { margin-left: 260px; padding: 2.5rem; width: calc(100% - 260px); }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }
.topbar h1 { font-size: 1.8rem; font-weight: 600; }

/* MAPS */
.map-container { padding: 1.5rem; margin-bottom: 2rem; }
.yard-map {
    width: 100%; height: 350px; background: rgba(15, 23, 42, 0.8); border-radius: 12px;
    border: 2px dashed rgba(255, 255, 255, 0.2); position: relative; overflow: hidden;
    background-image: radial-gradient(rgba(255,255,255,0.05) 1px, transparent 1px);
    background-size: 20px 20px;
}
.yard-map-picker {
    width: 100%; height: 250px; background: rgba(15, 23, 42, 0.8); border-radius: 12px;
    border: 2px dashed rgba(255, 255, 255, 0.4); position: relative; cursor: crosshair;
    background-image: radial-gradient(rgba(255,255,255,0.05) 1px, transparent 1px);
    background-size: 20px 20px; transition: border 0.3s;
}
.yard-map-picker:hover { border-color: rgba(255, 255, 255, 0.7); }

.pin {
    width: 20px; height: 20px; background: var(--success); border: 2px solid #fff;
    border-radius: 50%; position: absolute; transform: translate(-50%, -50%);
    box-shadow: 0 0 12px var(--success); z-index: 10; animation: bounceIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.pin::after {
    content: ''; position: absolute; top: 16px; left: 4px; width: 0; height: 0;
    border-left: 4px solid transparent; border-right: 4px solid transparent;
    border-top: 8px solid var(--success);
}
.pin-label {
    position: absolute; top: -35px; left: 50%; transform: translateX(-50%);
    background: rgba(0,0,0,0.85); color: #fff; padding: 4px 8px; border-radius: 6px;
    font-size: 0.75rem; white-space: nowrap; pointer-events: none; border: 1px solid rgba(255,255,255,0.1);
}

/* TABLE */
.table-container { padding: 1.5rem; overflow-x: auto; }
.table-container h3 { font-weight: 500; }
.data-table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
.data-table th, .data-table td { padding: 1rem; text-align: left; border-bottom: 1px solid var(--border-color); }
.data-table th { color: var(--text-muted); font-weight: 600; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }
.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }

/* MODAL */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px); display: none; align-items: center; justify-content: center; z-index: 1000;
}
.modal-content {
    width: 100%; max-width: 600px; padding: 2.5rem; position: relative;
    max-height: 90vh; overflow-y: auto; background: var(--bg-color);
}
.close-btn { position: absolute; top: 1rem; right: 1.5rem; font-size: 1.8rem; cursor: pointer; color: var(--text-muted); transition: 0.2s;}
.close-btn:hover { color: var(--danger); transform: scale(1.1); }

@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes bounceIn { 
    0% { transform: translate(-50%, -50%) scale(0); } 
    80% { transform: translate(-50%, -50%) scale(1.2); } 
    100% { transform: translate(-50%, -50%) scale(1); } 
}

/* =========================================================================
   MOBILE RESPONSIVENESS (MOBILE-FIRST ADAPTATIONS)
   ========================================================================= */
@media (max-width: 768px) {
    body { overflow-x: hidden; }
    
    /* SIDEBAR CONVERTIDA PRA TOP NAVBAR HEADER STICKY */
    .dashboard-page { flex-direction: column; }
    .sidebar {
        width: 100%; height: auto; position: sticky; top: 0; padding: 1rem; flex-direction: column;
        border-right: none; border-bottom: 1px solid var(--border-color); z-index: 1000;
        border-radius: 0 0 16px 16px; box-shadow: 0 10px 30px rgba(0,0,0,0.6);
        backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    }
    .sidebar-header { margin-bottom: 0; justify-content: space-between; }
    .sidebar .brand { font-size: 1.4rem; margin-bottom: 0; }
    .menu-toggle { display: block; }
    
    .sidebar .nav-links { display: none; flex-direction: column; width: 100%; margin-top: 1rem; gap: 0.5rem; }
    .sidebar .nav-links.show-nav { display: flex; animation: fadeIn 0.3s ease; }
    .sidebar .nav-links a { text-align: left; padding: 1rem; font-size: 1rem; border: none; border-bottom: 1px solid rgba(255,255,255,0.05); border-radius: 0; }
    .sidebar .nav-links a:last-child { border-bottom: none; }
    .sidebar .nav-links a.text-danger { margin-top: 0.5rem; }

    /* COMPONENTES CORE DA TELA */
    .main-content { margin-left: 0; width: 100%; padding: 1rem; }
    
    /* O BOTAO DE NOVA ENTRADA FICA GORDO E CLICAVEL COM FACILIDADE NO DEDO */
    .topbar { flex-direction: column; align-items: stretch; gap: 1.25rem; text-align: center; }
    .topbar h1 { font-size: 1.5rem; }
    .topbar .btn { width: 100%; padding: 1rem; font-size: 1.1rem; box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4); }
    
    /* MODAIS OCUPAm A TELA TODA MAIS CONFORTAVELMENTE */
    .form-grid { grid-template-columns: 1fr; }
    .modal-content { padding: 1.5rem 1rem; max-height: 95vh; border-radius: 12px 12px 0 0; align-self: flex-end; }
    .modal { align-items: flex-end; } /* Modal estilo "Bottom Sheet" do Android/iOS */
    .close-btn { top: 1rem; right: 1rem; background: var(--danger); color: #fff; border-radius: 50%; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }
    
    .map-container, .table-container { padding: 0; border: none; box-shadow: none; background: transparent; backdrop-filter: none; }
    .table-container h3 { padding: 0 0.5rem; margin-bottom: 1rem; }
    .yard-map { height: 300px; border-radius: 16px; margin-bottom: 1.5rem; }
    
    /* MAGIA DAS TABELAS (TRANSFORMAR TD EM CARDS ESTILOSOS) */
    .data-table thead { display: none; }
    .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
    .data-table tr { 
        margin-bottom: 1.5rem; background: var(--surface-color); border-radius: 16px; 
        border: 1px solid var(--border-color); padding: 1rem; box-shadow: 0 5px 15px rgba(0,0,0,0.3); 
    }
    .data-table td { 
        text-align: right; padding: 0.75rem 0; border-bottom: 1px solid rgba(255,255,255,0.05); 
        display: flex; justify-content: space-between; align-items: center; gap: 1rem; 
    }
    .data-table td:last-child { border-bottom: none; display: block; margin-top: 1rem; }
    .data-table td::before { 
        content: attr(data-label); font-size: 0.75rem; color: var(--text-muted); 
        font-weight: 600; text-transform: uppercase; text-align: left;
    }
    .data-table td > form { width: 100%; display: block; }
    .data-table td > form .btn { width: 100%; padding: 1rem; font-size: 1rem; font-weight: 700; border-radius: 10px; }
}
