/* Painel administrativo */
:root {
    --sidebar-width: 260px;
    --cor-dark: #2c3e50;
}

body {
    background-color: #f4f7f6;
    font-family: 'Segoe UI', sans-serif;
    overflow-x: hidden;
}

/*
 * Sidebar fixa: altura máxima da .sidebar-scroll é definida em admin-sidebar-layout.js (px).
 * O CSS mantém overflow e estética; o JS evita falhas de Grid/Flex/UA no <nav>.
 */
.sidebar {
    width: var(--sidebar-width);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    box-sizing: border-box;
    background-color: var(--cor-dark);
    color: white;
    z-index: 1000;
    transition: transform 0.28s ease, box-shadow 0.28s ease;
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom, 0);
    display: flex;
    flex-direction: column;
}

.sidebar > hr {
    margin-top: 0;
    flex-shrink: 0;
}

.sidebar > .sidebar-brand,
.sidebar > .sidebar-footer {
    flex-shrink: 0;
}

.sidebar-scroll {
    flex: 1 1 0;
    min-width: 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.35) rgba(0, 0, 0, 0.2);
}

.sidebar-scroll::-webkit-scrollbar {
    width: 8px;
}

.sidebar-scroll::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.sidebar-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
    background-clip: padding-box;
}

.sidebar .nav-link {
    color: rgba(255, 255, 255, 0.7);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    border-left: 4px solid transparent;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    color: white;
    background-color: rgba(255, 255, 255, 0.1);
    border-left-color: var(--cor-verde-agua);
}

.main-content {
    margin-left: var(--sidebar-width);
    padding: 25px;
    min-height: 100vh;
}

.top-bar {
    background: white;
    padding: 15px 30px;
    margin-bottom: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
    border-bottom: 4px solid var(--cor-verde-agua);
    height: 100%;
}

.section-pane {
    display: none;
    animation: fadeIn 0.4s ease;
}

.section-pane.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pet-thumb {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 8px;
}

.msg-list-item {
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: 0.2s;
}

.msg-list-item:hover {
    background-color: #f8f9fa;
}

.msg-list-item.unread {
    background-color: #eaf4f6;
    border-left-color: var(--cor-verde-agua);
}

.btn-verde {
    background-color: var(--cor-verde-agua);
    color: white;
    border: none;
}

.btn-verde:hover {
    background-color: #247a8f;
    color: white;
}

/* —— Sidebar: móvel / tablet estreito — drawer + overlay —— */
/* Botão: escondido em desktop; visível quando JS define body.admin-layout-narrow ou media query */
.sidebar-toggle {
    display: none !important;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    min-width: 2.75rem;
    min-height: 2.75rem;
    color: #212529 !important;
    background-color: #fff !important;
    border-color: #adb5bd !important;
}

.sidebar-toggle:hover {
    background-color: #f8f9fa !important;
    border-color: #6c757d !important;
    color: #000 !important;
}

@media (max-width: 1199.98px) {
    .sidebar-toggle {
        display: inline-flex !important;
    }
}

body.admin-layout-narrow .sidebar-toggle {
    display: inline-flex !important;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1030;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

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

body.admin-sidebar-open {
    overflow: hidden;
    touch-action: none;
}

/*
 * Drawer: abaixo de xl (1200px). 991px deixava janelas ~1024px sem colapsar.
 */
@media (max-width: 1199.98px) {
    .sidebar {
        transform: translateX(-100%) !important;
        transition: transform 0.28s ease;
        z-index: 1040;
        box-shadow: 6px 0 28px rgba(0, 0, 0, 0.18);
    }

    .sidebar.show {
        transform: translateX(0) !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding-left: 16px;
        padding-right: 16px;
    }

    .top-bar {
        padding-left: 16px;
        padding-right: 16px;
    }
}

/*
 * Reforço com classe no body (definida em admin-sidebar-mobile.js).
 * Garante drawer se o media query falhar (iframe, zoom, ordem de CSS).
 */
body.admin-layout-narrow .sidebar:not(.show) {
    transform: translateX(-100%) !important;
    z-index: 1040;
    box-shadow: 6px 0 28px rgba(0, 0, 0, 0.18);
}

body.admin-layout-narrow .sidebar.show {
    transform: translateX(0) !important;
}

body.admin-layout-narrow .main-content {
    margin-left: 0 !important;
    padding-left: 16px;
    padding-right: 16px;
}

body.admin-layout-narrow .top-bar {
    padding-left: 16px;
    padding-right: 16px;
}

/*
 * Modal «Editar membro»: o <form> envolve header/body/footer, o que quebra o flex
 * padrão do Bootstrap só no .modal-content. Reforçamos a coluna flex + rolagem no corpo.
 */
#modalEquipeEditar .modal-dialog {
    max-height: calc(100vh - 1rem);
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

#modalEquipeEditar .modal-content {
    max-height: calc(100vh - 1rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#modalEquipeEditar .modal-content > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

#modalEquipeEditar .modal-header,
#modalEquipeEditar .modal-footer {
    flex-shrink: 0;
}

#modalEquipeEditar .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
}
