:root {
    --auth-card-max-width: 420px;
    --sidebar-width: 280px;
    --sidebar-width-collapsed: 72px;
    --sidebar-current-width: var(--sidebar-width);
    --topbar-height: 64px;
    --sidebar-bg: #0b3d91;
    --sidebar-bg-hover: rgba(255, 255, 255, 0.1);
    --sidebar-active: rgba(255, 255, 255, 0.16);
    --sidebar-text: rgba(255, 255, 255, 0.88);
    --sidebar-text-muted: rgba(255, 255, 255, 0.6);
}

/* ---- Auth ---- */
.auth-wrapper {
    padding: 1.5rem;
    background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 50%, #084298 100%);
}

.auth-card {
    width: 100%;
    max-width: var(--auth-card-max-width);
    border-radius: 1rem;
}

.auth-logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    font-size: 2rem;
    background: var(--bs-primary-bg-subtle);
    border-radius: 50%;
}

/* ---- App layout ---- */
.app-body {
    overflow-x: hidden;
}

.app-wrapper {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
}

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

.app-content {
    flex: 1;
}

.app-footer {
    flex-shrink: 0;
}

/* ---- Sidebar ---- */
.sidebar {
    --bs-offcanvas-width: min(88vw, var(--sidebar-width));
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, #084298 100%);
    color: var(--sidebar-text);
    border: none;
    z-index: 1045;
}

.sidebar.offcanvas-lg {
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar .nav-link {
    color: var(--sidebar-text) !important;
}

.sidebar .sidebar-link:hover,
.sidebar .sidebar-link:focus,
.sidebar .sidebar-link.active {
    color: #fff !important;
}

.sidebar .sidebar-link.disabled {
    color: var(--sidebar-text-muted) !important;
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 100%;
}

.sidebar-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.65rem;
}

.sidebar-collapse-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 0.65rem;
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.sidebar-collapse-btn:hover,
.sidebar-collapse-btn:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.22);
    color: #fff;
}

.sidebar-collapse-btn .collapse-icon {
    flex-shrink: 0;
}

.sidebar-brand {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #fff;
    min-width: 0;
}

.sidebar-brand:hover {
    color: #fff;
    opacity: 0.92;
}

.sidebar-brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 0.75rem;
    background: rgba(255, 255, 255, 0.14);
    font-size: 1.25rem;
    flex-shrink: 0;
}

.sidebar-brand-text {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.sidebar-body {
    display: flex;
    flex-direction: column;
    padding: 1rem 0.875rem;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav {
    flex: 1;
}

.sidebar-link {
    color: var(--sidebar-text);
    border-radius: 0.65rem;
    padding: 0.72rem 0.875rem;
    font-weight: 500;
    font-size: 0.95rem;
    gap: 0.75rem;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
    border: 1px solid transparent;
}

.sidebar-link:hover,
.sidebar-link:focus {
    color: #fff;
    background: var(--sidebar-bg-hover);
}

.sidebar-link.active {
    color: #fff;
    background: var(--sidebar-active);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.sidebar-link.disabled {
    color: var(--sidebar-text-muted);
    cursor: not-allowed;
    opacity: 0.75;
}

.sidebar-link-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    flex-shrink: 0;
    opacity: 0.92;
}

.sidebar-link-text {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
}

.sidebar-badge {
    font-size: 0.65rem;
    padding: 0.2rem 0.45rem;
    flex-shrink: 0;
}

.sidebar-heading {
    color: var(--sidebar-text-muted);
    letter-spacing: 0.04em;
}

.sidebar-divider {
    height: 1px;
    margin: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.12);
    list-style: none;
}

.sidebar-submenu {
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
    padding-left: 0.5rem;
}

.sidebar-link-nested {
    padding-left: 2.25rem !important;
    font-size: 0.9rem;
}

.sidebar-footer {
    padding-top: 1rem;
    margin-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-user-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 0.75rem;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.78rem;
    color: var(--sidebar-text-muted);
    text-transform: capitalize;
}

.sidebar-menu-list {
    width: 100%;
}

/* ---- Collapsed sidebar (desktop) ---- */
@media (min-width: 992px) {
    body.sidebar-collapsed {
        --sidebar-current-width: var(--sidebar-width-collapsed);
    }

    body.sidebar-collapsed .sidebar.offcanvas-lg {
        width: var(--sidebar-current-width);
        max-width: var(--sidebar-current-width);
    }

    body.sidebar-collapsed .sidebar-header {
        justify-content: center;
        padding: 0.75rem 0;
    }

    body.sidebar-collapsed .sidebar-collapse-btn {
        margin: 0 auto;
    }

    body.sidebar-collapsed .sidebar-brand {
        display: none !important;
    }

    body.sidebar-collapsed .sidebar-body {
        padding: 0.5rem 0;
        align-items: center;
    }

    body.sidebar-collapsed .sidebar-nav {
        width: 100%;
        display: flex;
        justify-content: center;
    }

    body.sidebar-collapsed .sidebar-menu-list {
        width: 100%;
        align-items: center;
        padding: 0;
        margin: 0;
    }

    body.sidebar-collapsed .sidebar-brand-text,
    body.sidebar-collapsed .sidebar-link-text,
    body.sidebar-collapsed .sidebar-badge,
    body.sidebar-collapsed .sidebar-user-info,
    body.sidebar-collapsed .sidebar-heading {
        display: none !important;
    }

    body.sidebar-collapsed .nav-item {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 100%;
        padding: 0;
        margin: 0;
    }

    body.sidebar-collapsed .sidebar .nav-link.sidebar-link,
    body.sidebar-collapsed .sidebar .nav-link.sidebar-link.disabled {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        max-width: 44px !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 0 !important;
        padding: 0 !important;
        margin: 0 auto !important;
        flex: 0 0 44px !important;
    }

    body.sidebar-collapsed .sidebar-link-icon {
        width: 20px;
        height: 20px;
        margin: 0 !important;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    body.sidebar-collapsed .sidebar-link-nested {
        padding-left: 0 !important;
    }

    body.sidebar-collapsed .sidebar-submenu {
        display: none !important;
    }

    body.sidebar-collapsed .nav-item.has-children {
        flex-direction: column;
    }

    body.sidebar-collapsed .sidebar-footer {
        width: 100%;
        display: flex;
        justify-content: center;
        padding-top: 0.75rem;
    }

    body.sidebar-collapsed .sidebar-user-card {
        justify-content: center;
        align-items: center;
        width: 44px;
        height: 44px;
        min-width: 44px;
        padding: 0 !important;
        gap: 0;
        margin: 0 auto;
    }

    body.sidebar-collapsed .sidebar-user-avatar {
        width: 36px;
        height: 36px;
        margin: 0 auto;
    }
}

/* ---- Topbar ---- */
.app-topbar {
    background: #fff;
    border-bottom: 1px solid var(--bs-border-color);
    z-index: 1030;
    flex-shrink: 0;
}

.topbar-inner {
    padding: 0.75rem 1rem;
    min-height: var(--topbar-height);
}

.topbar-title h1 {
    line-height: 1.3;
}

.btn-icon {
    width: 42px;
    height: 42px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.65rem;
    flex-shrink: 0;
}

.btn-sm.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 0.5rem;
}

.topbar-user-btn {
    border-radius: 999px;
    padding: 0.35rem 0.65rem 0.35rem 0.35rem;
    max-width: 220px;
}

.topbar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--bs-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.topbar-user-name {
    max-width: 120px;
}

/* ---- Dashboard cards ---- */
.stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 0.75rem;
    flex-shrink: 0;
}

.card {
    border-radius: 0.75rem;
}

.form-control:focus {
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

/* ---- Desktop sidebar (lg+) ---- */
@media (min-width: 992px) {
    .sidebar.offcanvas-lg {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: var(--sidebar-current-width);
        max-width: var(--sidebar-current-width);
        height: 100vh;
        height: 100dvh;
        transform: none !important;
        visibility: visible !important;
        display: block !important;
        opacity: 1 !important;
        background: linear-gradient(180deg, var(--sidebar-bg) 0%, #084298 100%) !important;
        transition: width 0.25s ease, max-width 0.25s ease;
    }

    .sidebar.offcanvas-lg .sidebar-header {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
    }

    .sidebar.offcanvas-lg .sidebar-body {
        display: flex !important;
        flex: 1 1 auto !important;
        height: calc(100% - 72px);
    }

    .app-wrapper {
        min-height: 100vh;
        min-height: 100dvh;
    }

    .app-main {
        margin-left: var(--sidebar-current-width);
        width: calc(100% - var(--sidebar-current-width));
        min-height: 100vh;
        min-height: 100dvh;
        transition: margin-left 0.25s ease, width 0.25s ease;
    }

    .topbar-inner {
        padding: 0.875rem 1.5rem;
    }

    .app-content {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

/* ---- Mobile tweaks ---- */
@media (max-width: 991.98px) {
    body.sidebar-open {
        overflow: hidden;
    }

    .sidebar.offcanvas {
        width: min(88vw, var(--sidebar-width));
    }

    .sidebar .offcanvas-header {
        padding: 1rem 1.25rem;
    }

    .sidebar-badge {
        display: none;
    }

    .app-content {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

@media (max-width: 575.98px) {
    :root {
        --sidebar-width: 100vw;
    }

    .auth-card .card-body {
        padding: 2rem 1.5rem;
    }

    .topbar-inner {
        padding: 0.65rem 0.75rem;
    }

    .topbar-user-btn {
        padding: 0.25rem;
        max-width: none;
    }

    .topbar-user-btn .topbar-user-name,
    .topbar-user-btn svg:last-child {
        display: none;
    }
}

/* ---- DataTables ---- */
div.dataTables_wrapper {
    padding: 1rem 1.25rem;
}

div.dataTables_wrapper .dataTables_length,
div.dataTables_wrapper .dataTables_filter,
div.dataTables_wrapper .dataTables_info,
div.dataTables_wrapper .dataTables_paginate {
    margin-bottom: 0.75rem;
}

div.dataTables_wrapper .dataTables_filter input {
    margin-left: 0.5rem;
}

div.dataTables_wrapper table.dataTable {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

div.dataTables_wrapper .row {
    align-items: center;
}

@media (max-width: 767.98px) {
    div.dataTables_wrapper .dataTables_length,
    div.dataTables_wrapper .dataTables_filter,
    div.dataTables_wrapper .dataTables_info,
    div.dataTables_wrapper .dataTables_paginate {
        text-align: left !important;
        float: none !important;
    }
}

@supports (padding: env(safe-area-inset-left)) {
    @media (max-width: 991.98px) {
        .sidebar-body {
            padding-bottom: calc(1rem + env(safe-area-inset-bottom));
        }

        .app-topbar .topbar-inner {
            padding-left: max(0.75rem, env(safe-area-inset-left));
            padding-right: max(0.75rem, env(safe-area-inset-right));
        }
    }
}

.badge-evento-pago {
    background-color: #198754;
    color: #fff;
}

.badge-evento-estornado {
    background-color: #6f42c1;
    color: #fff;
}

.badge-evento-cancelado {
    background-color: #dc3545;
    color: #fff;
}

.admin-pwa-bar {
    position: fixed;
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    z-index: 1080;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: 0.9rem;
    background: #0b3d91;
    color: #fff;
    box-shadow: 0 10px 30px rgba(8, 20, 28, 0.28);
}

.admin-pwa-copy {
    flex: 1 1 12rem;
    font-size: 0.85rem;
    line-height: 1.35;
}

.admin-pwa-actions {
    display: flex;
    gap: 0.4rem;
}

.admin-pwa-bar[hidden] {
    display: none !important;
}

/* ---- Assinaturas no participante ---- */
.assinaturas-check-list {
    display: grid;
    gap: 0.35rem;
    padding: 0.75rem 1rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 0.5rem;
    background: #fff;
}

.assinaturas-check-list .form-check {
    margin: 0;
}

/* ---- Shuttle vínculo participantes ---- */
.vinculo-shuttle {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 0.75rem;
    align-items: stretch;
}

.vinculo-shuttle-panel {
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.75rem;
    background: #fff;
    display: flex;
    flex-direction: column;
    min-height: 16rem;
    overflow: hidden;
}

.vinculo-shuttle-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
    background: #f8fafc;
    font-size: 0.82rem;
    font-weight: 600;
    color: #334155;
}

.vinculo-shuttle-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    background: #e2e8f0;
    font-size: 0.75rem;
    font-weight: 700;
}

.vinculo-shuttle-filter {
    margin: 0.65rem 0.65rem 0;
    border-radius: 0.55rem;
}

.vinculo-shuttle-list {
    list-style: none;
    margin: 0;
    padding: 0.5rem;
    overflow: auto;
    flex: 1;
    max-height: 14rem;
}

.vinculo-shuttle-item {
    display: grid;
    gap: 0.1rem;
    padding: 0.55rem 0.7rem;
    border-radius: 0.55rem;
    border: 1px solid transparent;
    cursor: pointer;
    user-select: none;
}

.vinculo-shuttle-item + .vinculo-shuttle-item {
    margin-top: 0.25rem;
}

.vinculo-shuttle-item strong {
    font-size: 0.88rem;
    font-weight: 600;
    color: #0f172a;
}

.vinculo-shuttle-item span {
    font-size: 0.75rem;
    color: #64748b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vinculo-shuttle-item:hover {
    background: #f1f5f9;
}

.vinculo-shuttle-item.is-selected {
    background: rgba(13, 110, 253, 0.1);
    border-color: rgba(13, 110, 253, 0.35);
}

.vinculo-shuttle-item.is-filtered-out {
    display: none;
}

.vinculo-shuttle-actions {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.4rem;
    padding-top: 1.75rem;
}

.vinculo-shuttle-actions .btn {
    min-width: 2.4rem;
    font-weight: 700;
    line-height: 1;
}

.vinculo-shuttle-hidden {
    display: none;
}

.vinculo-shuttle-empty {
    color: #94a3b8;
    font-size: 0.82rem;
    text-align: center;
    padding: 1.5rem 0.75rem;
}

@media (max-width: 767.98px) {
    .vinculo-shuttle {
        grid-template-columns: 1fr;
    }

    .vinculo-shuttle-actions {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        padding-top: 0;
    }

    .vinculo-shuttle-list {
        max-height: 11rem;
    }
}
