/* ============================================================
   ESTILOS GENERALES Y DISEÑO DE MARCA - PLATAFORMA DE RASTREO GPS
   ============================================================ */

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #0f172a;
    --accent-color: #3b82f6;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-light: #f8fafc;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --status-moving: #10b981;
    --status-stopped: #f59e0b;
    --status-offline: #64748b;
    --status-engine-off: #ef4444;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-soft: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.08);
}

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f1f5f9;
    color: var(--text-main);
    overflow-x: hidden;
    margin: 0;
}

/* layout principal */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* sidebar */
.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-dark);
    color: #fff;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
    font-weight: 700;
    font-size: 1.2rem;
    color: #fff;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-brand img {
    height: 32px;
    width: auto;
}

.sidebar-nav {
    padding: 1.25rem 0.75rem;
    flex-grow: 1;
    overflow-y: auto;
}

.nav-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0.75rem 1rem 0.25rem 1rem;
    font-weight: 600;
}

.sidebar-nav .nav-link {
    color: #94a3b8;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    transition: all 0.2s ease;
    text-decoration: none;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.08);
}

.sidebar-nav .nav-link.active {
    background-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* main content */
.app-main {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left 0.3s ease;
}

/* topbar header */
.app-topbar {
    height: var(--topbar-height);
    background-color: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-main);
    cursor: pointer;
    display: none;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.user-profile-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-main);
}

.avatar-circle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.95rem;
}

/* page content */
.content-body {
    padding: 1.75rem;
    flex-grow: 1;
}

/* cards y paneles */
.card-custom {
    background-color: #fff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    margin-bottom: 1.5rem;
}

.card-custom .card-header {
    background-color: transparent;
    border-bottom: 1px solid #f1f5f9;
    padding: 1.25rem 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-custom .card-body {
    padding: 1.5rem;
}

/* stat counters cards */
.stat-card {
    background: #fff;
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    border: 1px solid #e2e8f0;
    box-shadow: var(--shadow-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.stat-icon.total { background: #eff6ff; color: #2563eb; }
.stat-icon.moving { background: #ecfdf5; color: #10b981; }
.stat-icon.stopped { background: #fffbeb; color: #f59e0b; }
.stat-icon.offline { background: #f1f5f9; color: #64748b; }

.stat-val {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* badges de estado */
.badge-status {
    padding: 0.35em 0.75em;
    border-radius: 50rem;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.badge-status::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: currentColor;
}

/* Fondo Oscuro Difuminado (Backdrop Overlay) para Menú Móvil Desplegable */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
}

/* responsive */
@media (max-width: 991.98px) {
    .app-sidebar {
        width: 280px;
        max-width: 85vw;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
        transform: translateX(-100%);
        z-index: 1060;
        border-radius: 0 18px 18px 0;
    }
    .app-sidebar.show {
        transform: translateX(0);
    }
    .app-main {
        margin-left: 0;
        padding-bottom: 0;
    }
    .sidebar-toggle-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: var(--radius-sm);
        background: #f1f5f9;
        color: var(--secondary-color);
        border: 1px solid #cbd5e1;
        cursor: pointer;
        padding: 0;
    }
    .app-topbar {
        padding: 0 1rem;
    }
}
