/* Barra de navegaci?n: horizontal en escritorio, barra inferior en m?vil. */

.navbar {
    background: #1a73e8;
    padding: 0 16px;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    min-height: 56px;
}

.navbar-start {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    flex: 1 1 auto;
}

.navbar-end {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.navbar-brand {
    color: #fff;
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: 0.5px;
    text-decoration: none;
    padding: 8px 12px 8px 0;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.navbar-brand-icon {
    border-radius: 7px;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.navbar-links {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.navbar-links::-webkit-scrollbar {
    display: none;
}

.navbar a {
    color: #fff;
    text-decoration: none;
    font-size: 0.88rem;
    padding: 10px 12px;
    border-radius: 8px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.2s;
    border: 2px solid transparent;
    box-sizing: border-box;
}

.navbar a:hover {
    background: rgba(255, 255, 255, 0.18);
}

.navbar a.active {
    background: rgba(255, 255, 255, 0.22);
    font-weight: 600;
}

.conn-indicator {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    flex-shrink: 0;
    white-space: nowrap;
    cursor: pointer;
    border: none;
}

.conn-indicator.online {
    background: #d4edda;
    color: #155724;
}

.conn-indicator.offline {
    background: #f8d7da;
    color: #721c24;
}

/* Usuario autenticado + logout en la barra superior */
.navbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    color: #fff;
}

.navbar-user-info {
    font-size: 0.82rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.14);
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
}

.navbar-user-org {
    opacity: 0.85;
    font-weight: 500;
}

.navbar-user-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.navbar-manage-link,
.navbar-pw-link,
.navbar-login-link {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.14);
    font-weight: 600;
    padding: 7px 12px !important;
    border-radius: 20px;
    font-size: 0.8rem;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    height: auto;
}

.navbar-manage-link:hover,
.navbar-pw-link:hover,
.navbar-login-link:hover {
    background: rgba(255, 255, 255, 0.26) !important;
}

.navbar-manage-link.active {
    background: rgba(255, 255, 255, 0.3) !important;
}

.navbar-logout-form {
    display: inline-flex;
    margin: 0;
}

.navbar-logout-btn {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 7px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    font-family: inherit;
}

.navbar-logout-btn:hover {
    background: rgba(255, 235, 235, 0.22);
    border-color: rgba(255, 255, 255, 0.55);
}

.navbar-logout-btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Chip de GPS */
.operator-chip.operator-gps {
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #fff;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
}

.operator-chip.operator-gps:hover {
    background: rgba(255, 255, 255, 0.24);
}

.operator-chip.operator-gps.on {
    background: #e6f4ea;
    color: #1e7e34;
    border-color: #1e7e34;
}

.operator-chip.operator-gps.unset {
    opacity: 0.88;
}

/* Barra de navegaci?n inferior (oculta en escritorio) */
.bottom-nav {
    display: none;
}

.bn-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 1500;
}

.bn-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 56px;
    background: #fff;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
    padding: 8px 0 12px;
    z-index: 1501;
}

.bn-sheet::before {
    content: "";
    display: block;
    width: 40px;
    height: 4px;
    background: #dadce0;
    border-radius: 2px;
    margin: 6px auto 10px;
}

.bn-sheet a {
    display: block;
    padding: 14px 20px;
    color: #1a1a1a;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
}

.bn-sheet a:hover {
    background: #f0f2f5;
}

.bn-sheet-user {
    padding: 14px 20px 10px;
    border-bottom: 1px solid #eee;
    margin-bottom: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.bn-sheet-user-name {
    font-weight: 700;
    color: #1a1a1a;
    font-size: 1rem;
}

.bn-sheet-user-org {
    font-size: 0.82rem;
    color: #666;
}

.bn-sheet-logout {
    margin: 0;
    padding: 0;
}

.bn-sheet-logout button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 14px 20px;
    color: #b3261e;
    background: none;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.bn-sheet-logout button:hover {
    background: #fdecea;
}

/* --- Escritorio ancho: navegaci?n agrupada + men?s desplegables --- */
@media (min-width: 901px) {
    .navbar {
        padding: 0 24px;
        min-height: 58px;
    }

    .navbar-start {
        gap: 8px;
    }

    .navbar-links {
        overflow-x: visible;
        align-items: center;
        gap: 4px;
        margin-left: 4px;
    }

    .navbar-primary {
        display: flex;
        align-items: center;
        gap: 2px;
    }

    .navbar-primary a {
        font-size: 0.92rem;
        font-weight: 500;
        padding: 10px 14px;
    }

    .nav-dropdown {
        position: relative;
        flex-shrink: 0;
    }

    .nav-dropdown-btn,
    .navbar-user-toggle {
        appearance: none;
        border: 2px solid transparent;
        background: transparent;
        color: #fff;
        font-family: inherit;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        gap: 6px;
        border-radius: 8px;
        transition: background 0.2s;
        box-sizing: border-box;
    }

    .nav-dropdown-btn {
        font-size: 0.92rem;
        font-weight: 500;
        padding: 10px 14px;
        white-space: nowrap;
    }

    .nav-dropdown-btn:hover,
    .navbar-user-toggle:hover {
        background: rgba(255, 255, 255, 0.18);
    }

    .nav-dropdown-btn.active,
    .navbar-user-toggle.active {
        background: rgba(255, 255, 255, 0.22);
        font-weight: 600;
    }

    .nav-dropdown-btn[aria-expanded="true"],
    .navbar-user-toggle[aria-expanded="true"] {
        background: rgba(255, 255, 255, 0.28);
    }

    .nav-chev {
        font-size: 0.72rem;
        opacity: 0.85;
        line-height: 1;
    }

    .nav-dropdown-panel {
        position: absolute;
        top: calc(100% + 8px);
        right: 0;
        min-width: 220px;
        background: #fff;
        border-radius: 12px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
        padding: 8px;
        z-index: 2000;
        border: 1px solid rgba(0, 0, 0, 0.06);
    }

    .nav-more-dropdown .nav-dropdown-panel {
        left: 0;
        right: auto;
    }

    .nav-dropdown-panel a {
        display: block;
        color: #1a1a1a !important;
        padding: 10px 14px !important;
        border-radius: 8px;
        font-size: 0.88rem;
        font-weight: 500;
        white-space: nowrap;
        border: none;
    }

    .nav-dropdown-panel a:hover {
        background: #f0f4f8 !important;
    }

    .nav-dropdown-panel a.active {
        background: #e8f0fe !important;
        color: #1a73e8 !important;
        font-weight: 600;
    }

    .navbar-user-toggle {
        padding: 6px 12px 6px 6px;
        max-width: 240px;
        text-align: left;
    }

    .navbar-user-avatar {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.25);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-weight: 700;
        font-size: 0.85rem;
        flex-shrink: 0;
    }

    .navbar-user-label {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        min-width: 0;
        line-height: 1.25;
    }

    .navbar-user-label strong {
        font-size: 0.82rem;
        font-weight: 700;
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .navbar-user-label small {
        font-size: 0.7rem;
        opacity: 0.85;
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .nav-user-panel {
        min-width: 240px;
    }

    .nav-user-panel-head {
        padding: 10px 14px 12px;
        border-bottom: 1px solid #eee;
        margin-bottom: 4px;
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .nav-user-panel-head strong {
        color: #1a1a1a;
        font-size: 0.92rem;
    }

    .nav-user-panel-head span {
        color: #666;
        font-size: 0.78rem;
    }

    .nav-dropdown-divider {
        height: 1px;
        background: #eee;
        margin: 6px 8px;
    }

    .nav-user-logout-form {
        margin: 0;
        padding: 0;
    }

    .nav-user-logout-btn {
        appearance: none;
        border: none;
        background: none;
        width: 100%;
        text-align: left;
        padding: 10px 14px;
        border-radius: 8px;
        color: #b3261e;
        font-size: 0.88rem;
        font-weight: 600;
        cursor: pointer;
        font-family: inherit;
        transition: background 0.2s;
    }

    .nav-user-logout-btn:hover {
        background: #fdecea;
    }

    .navbar-end {
        gap: 10px;
    }

    body:not(.page-login) .container {
        max-width: 920px;
    }
}

/* --- M?vil / tablet --- */
@media (max-width: 900px) {
    .navbar {
        padding: 0 10px;
        min-height: 48px;
        justify-content: space-between;
    }

    .navbar-start {
        flex: 0 1 auto;
    }

    .navbar-end {
        gap: 6px;
    }

    .navbar-links {
        display: none;
    }

    .navbar-user {
        display: none !important;
    }

    .operator-chip.operator-gps {
        padding: 5px 10px;
        font-size: 0.76rem;
    }

    .bottom-nav {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        background: #fff;
        border-top: 1px solid #e0e0e0;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
        z-index: 1000;
        height: 56px;
        align-items: stretch;
        justify-content: space-around;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .bottom-nav a,
    .bottom-nav .bn-more {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        color: #555;
        text-decoration: none;
        font-size: 0.68rem;
        font-weight: 600;
        background: none;
        border: none;
        cursor: pointer;
        padding: 4px 2px;
        min-height: 44px;
        font-family: inherit;
    }

    .bottom-nav .bn-icon {
        font-size: 1.15rem;
        line-height: 1;
    }

    .bottom-nav a.active,
    .bottom-nav .bn-more[aria-expanded="true"] {
        color: #1a73e8;
    }

    .bottom-nav a.active::before {
        content: "";
        position: absolute;
        top: 0;
        width: 28px;
        height: 3px;
        background: #1a73e8;
        border-radius: 0 0 3px 3px;
    }

    .bottom-nav a {
        position: relative;
    }

    body {
        padding-bottom: 60px;
    }
}

@media (max-width: 420px) {
    .navbar-brand { font-size: 1rem; padding: 8px 6px 8px 0; }
    .conn-indicator { font-size: 0.72rem; padding: 5px 10px; }
    .bottom-nav a, .bottom-nav .bn-more { font-size: 0.62rem; }
    .bottom-nav .bn-icon { font-size: 1.05rem; }
}

/* Contenedor de contenido: navbar full-width, cuerpo centrado y alineado */
.page-main {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 24px 16px 32px;
    min-width: 0;
}

.page-main--wide {
    max-width: 980px;
}

@media (max-width: 900px) {
    .page-main {
        padding: 16px 16px 24px;
    }
}
