/* Importa a fonte do Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

/* 1. VARIÁVEIS GLOBAIS E ESTILOS DE BASE */
:root {
    --sidebar-width: 355px;
    --sidebar-width-collapsed: 100px;

    /* VARIÁVEIS ORIGINAIS */
    --cor-primaria: #0052CC;
    --cor-fundo: #FFFFFF;
    --cor-texto: #333333;
    --cor-texto-claro: #6c757d;
    --cor-verde: #17A665;
    --cor-vermelho: #E63946;
    --cor-borda-suave: #dee2e6;
    --sombra-suave: 0px 8px 24px rgba(0, 82, 204, 0.1);
    --transition-speed: 0.5s;

    /* PALETA DE CORES DA NAVEGAÇÃO */
    --nav-cor-fundo: #4d7cff;
    --nav-cor-texto: #FFFFFF;
    --nav-hover-fundo: rgba(255, 255, 255, 0.15);
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--cor-fundo);
    color: var(--cor-texto);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 {
    font-weight: 600;
    color: var(--cor-primaria);
}

main.container-fluid h2 {
    font-weight: 900;
    cursor: pointer;
    transition: all 0.3s ease-in-out;
}

main.container-fluid h2:hover {
    transform: scale(1.02);
    letter-spacing: 1px;
    text-shadow: 0 0 12px rgba(0, 82, 204, 0.4);
}

/* 2. ESTRUTURA E CORREÇÃO DA SIDEBAR PARA DESKTOP */
@media (min-width: 992px) {
    .sidebar.offcanvas-lg {
        background-color: var(--nav-cor-fundo) !important;
        z-index: 1045;
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        transform: none !important;
        visibility: visible !important;
        border-right: none;
        transition: width var(--transition-speed) ease-in-out;
    }

    .sidebar.offcanvas-lg .offcanvas-header {
        display: none;
    }

    .main-content {
        margin-left: var(--sidebar-width-collapsed);
        width: calc(100% - var(--sidebar-width-collapsed));
        transition: none;
    }

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

    body.sidebar-collapsed .sidebar .sidebar-header-desktop {
        justify-content: center;
        padding-bottom: 1rem;
    }

    body.sidebar-collapsed .sidebar .sidebar-title {
        opacity: 0;
        visibility: hidden;
        width: 0;
    }

    /* Ajuste de alinhamento quando fechado */
    body.sidebar-collapsed .sidebar .nav-link {
        padding: 10px 14px;
        font-size: 0.9rem;
        display: flex;
        align-items: center; /* Centraliza verticalmente */
        justify-content: flex-start;
    }

    body.sidebar-collapsed .sidebar .nav-link .nav-icon {
        font-size: 2rem;
        margin-right: 4px;
        display: flex;
        align-items: center; /* Centraliza o ícone em si */
        justify-content: center;
        height: 100%; /* Garante altura total */
        line-height: 1; /* Remove espaçamento extra de fonte */
    }

    body.sidebar-collapsed .sidebar .link-text,
    body.sidebar-collapsed .sidebar .sidebar-buttons {
        opacity: 0;
        visibility: hidden;
        width: 0;
        transition: opacity 0.1s ease, visibility 0.1s ease, width 0.1s ease;
    }

    body:not(.sidebar-collapsed) .sidebar.offcanvas-lg {
        width: var(--sidebar-width);
        box-shadow: 0 0 25px rgba(0, 0, 0, 0.1);
    }

    body:not(.sidebar-collapsed) .sidebar .sidebar-title {
        opacity: 1;
        visibility: visible;
        width: auto;
        transition: opacity 0.2s ease;
        transition-delay: 0.15s;
    }

    /* Ajuste de alinhamento quando aberto */
    body:not(.sidebar-collapsed) .sidebar .nav-link {
        justify-content: flex-start;
        padding: 12px 40px;
        display: flex;
        align-items: center; /* Centraliza verticalmente */
    }

    body:not(.sidebar-collapsed) .sidebar .nav-link .nav-icon {
        font-size: 2rem;
        margin-right: 8px;
        line-height: 1; /* Garante alinhamento com texto */
        display: flex;
        align-items: center;
    }

    body:not(.sidebar-collapsed) .sidebar .link-text,
    body:not(.sidebar-collapsed) .sidebar .sidebar-buttons {
        opacity: 1;
        visibility: visible;
        width: auto;
        transition: opacity 0.2s ease, visibility 0.2s ease;
        transition-delay: 0.15s;
    }
}

/* 3. HEADER DA SIDEBAR E BOTÃO HAMBÚRGUER */
.sidebar-header-desktop {
    display: flex;
    align-items: center;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
}

#desktopSidebarToggle {
    font-size: 1.8rem;
    color: var(--nav-cor-texto);
    border: none;
    background-color: transparent;
    border-radius: 10px;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

#desktopSidebarToggle:hover {
    background-color: var(--nav-hover-fundo);
    transform: scale(1.05);
}

body.sidebar-collapsed #desktopSidebarToggle {
    margin: 0 auto;
}

body:not(.sidebar-collapsed) #desktopSidebarToggle {
    margin-left: auto;
    margin-right: 1rem;
}

/* 4. ESTILOS GERAIS DA SIDEBAR (MOBILE-FIRST) */
.sidebar {
    background-color: var(--nav-cor-fundo);
}

.sidebar .offcanvas-body {
    padding: 0.4rem 2rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.sidebar-user-greeting,
.sidebar-title,
.sidebar .nav-link {
    color: var(--nav-cor-texto) !important;
}

.sidebar-user-greeting {
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8) !important;
    text-align: center;
    margin-top: -10px;
    margin-bottom: 2rem;
}

.sidebar-title {
    font-size: 2rem;
    font-weight: 900;
    text-decoration: none;
    transition: all 0.3s ease;
}

.sidebar-title:hover {
    transform: scale(1.02);
    letter-spacing: 1px;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

/* Classe geral dos links da navbar */
.sidebar .nav-link {
    font-weight: 1000;
    border-radius: 16px;
    transition: all 0.2s ease-in-out;
    padding: 16px;
    font-size: 0.90rem;
    /* Adições para centralização */
    display: flex;
    align-items: center;
}

.sidebar .nav-link:hover {
    background-color: var(--nav-hover-fundo);
    transform: translateX(5px) scale(1.02);
}

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

.btn-login, .btn-logout {
    font-weight: 600;
    border-radius: 10px;
    padding: 14px;
    border: none;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: white;
}

.btn-login {
    background-color: var(--cor-verde);
    box-shadow: 0 4px 15px rgba(23, 166, 101, 0.3);
}

.btn-login:hover {
    background-color: #19b970;
    transform: translateY(-4px);
    box-shadow: 0 6px 20px rgba(23, 166, 101, 0.4);
}

.btn-logout {
    background-color: var(--cor-vermelho);
    box-shadow: 0 4px 15px rgba(230, 57, 70, 0.3);
}

.btn-logout:hover {
    background-color: #f14e5a;
    transform: translateY(-4px);
    box-shadow: 0 6px 20px rgba(230, 57, 70, 0.4);
}

.mobile-header {
    background-color: var(--nav-cor-fundo) !important;
}

.mobile-header .btn-primary {
    background-color: transparent !important;
    border: none;
    color: white;
}

.mobile-header .btn-primary:hover {
    background-color: rgba(255, 255, 255, 0.15) !important;
}

/* OUTROS ESTILOS (Flip Cards, etc) MANTIDOS */
.flip-card {
    background-color: transparent;
    width: 100%;
    max-width: 350px;
    height: 350px;
    perspective: 1500px;
    margin: auto;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.8s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    transform-style: preserve-3d;
    border-radius: 16px;
}

.flip-card:hover .flip-card-inner {
    transform: rotateY(180deg);
    box-shadow: var(--sombra-suave);
}

.flip-card-front, .flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

.flip-card-front {
    color: white;
}

.flip-card-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.flip-card:hover .flip-card-front img {
    transform: scale(1.05);
}

.flip-card-front .card-title {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    padding: 2.5rem 1.5rem 1.5rem;
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.flip-card-back {
    background-size: cover;
    background-position: center;
    color: white;
    transform: rotateY(180deg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 25px;
}

.flip-card-back .card-content {
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px) saturate(120%);
    -webkit-backdrop-filter: blur(10px) saturate(120%);
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.flip-card-back .btn {
    background-color: rgba(255, 255, 255, 0.9);
    color: var(--cor-primaria);
    font-weight: 600;
    border: none;
    transition: all 0.3s ease;
}

.flip-card-back .btn:hover {
    background-color: #fff;
    transform: scale(1.05);
}

html, body {
    height: 100%;
}

.main-content {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

main.container-fluid {
    flex: 1 0 auto;
}