/* =========================[ SIDEBAR STYLESHEET ]========================= */

#sidebar {
    width: 250px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background-color: var(--color-topbar);
    padding: 20px 10px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 20px;
    font-family: var(--font-primary);
    z-index: 999;
    color: inherit;

    box-shadow: 2px 0 6px rgba(0, 0, 0, 0.1);

    /* Smooth collapse */
    transition: width 0.3s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-logo {
    max-width: 160px;
    height: auto;
    transition: max-width 0.3s ease;
}

#sidebar-modules {
    display: flex;
    flex-direction: column;
}


/* =========================[ BUTTONS IN SIDEBAR ]========================= */

.sidebar-btn {
    all: unset; /* reset ALL styles */
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 30px 15px;
    font-size: small;
    cursor: pointer;
    color: var(--color-gray);
    border-left: 3px solid transparent;
    border-radius: 0;
    transition: all 0.2s ease;
    position: relative; /* needed for collapsed tooltip */
}

.sidebar-btn:hover {
    background-color: var(--color-gray-light);
    border-left: 3px solid var(--color-blue-light);
    color: var(--color-blue-dark);
    font-weight: 500;
    padding: 10px 20px 15px;
}

/* Active button */
.sidebar-btn.active {
    background-color: #eef6ff; /* soft blue */
    border-left: 3px solid var(--color-blue);
    color: var(--color-blue);
    font-weight: 600;
    box-shadow: inset 2px 0 6px rgba(0, 0, 0, 0.05);
}

/* =========================[ LOGOUT BUTTON ]========================= */
.logout-btn {
    all: unset;
    margin-top: auto;
    width: 100%;
    padding: 10px 40px;
    font-size: small;
    cursor: pointer;
    color: #f87171;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logout-btn:hover {
    background-color: #fee2e2;
    color: #b91c1c;
    border-left: 3px solid #f87171;
}

/* =========================[ COLLAPSED STATE - LOGOUT ]========================= */
#sidebar.collapsed .logout-btn {
    width: 60px;
    justify-content: center;
    padding: 12px 0;
    position: relative;
}

/* Esconde o texto no collapsed */
#sidebar.collapsed .logout-btn span {
    display: none;
}

/* Mostra igual tooltip quando hover */
#sidebar.collapsed .logout-btn:hover span {
    display: block;
    position: absolute;
    top: 50%;
    left: 100%;
    transform: translateY(-50%);
    white-space: nowrap;
    background-color: var(--color-dark);
    color: var(--color-text-light);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    margin-left: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}


/* =========================[ SIDEBAR TOP - HEADER BAR ]========================= */

#sidebar-top {
    width: 100%;
    height: 50px;
    top: 0;
    left: 0;
    background: linear-gradient(to right, #007cf0, #00dfd8);
    border-bottom: 1px solid #ccc;
    z-index: 998;
}

.sidebar-top-content {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    font-size: small;
    color: var(--color-text-light);
    transition: padding-left 0.3s ease;
}

/* Topbar padding depends on sidebar state */
body:not(.sidebar-collapsed) .sidebar-top-content {
    padding-left: 280px;
}

body.sidebar-collapsed .sidebar-top-content {
    padding-left: 100px;
}

/* Profile label */
.profile-role {
    font-weight: bold;
    color: #e2e8f0;
}

/* User info block (right side) */
.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-photo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.user-photo:hover {
    transform: scale(1.2);
    opacity: 0.9;
    border-radius: 40%;
}


/* =========================[ TOGGLE BUTTON ]========================= */

#sidebar-toggle {
    margin: 5px 10px;
    align-self: flex-start;
    color: var(--color-gray-dark);
    transition: color 0.2s ease, transform 0.2s ease;
}

#sidebar-toggle:hover {
    color: var(--color-blue);
    transform: scale(1.1);
}

#sidebar-toggle.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px;
    font-size: medium;
}


/* =========================[ COLLAPSED STATE ]========================= */

#sidebar.collapsed {
    width: 80px;
}

/* Ajuste da logo no modo collapsed */
#sidebar.collapsed .sidebar-logo {
    max-width: 40px;   /* reduz a logo */
    margin: 0 auto;    /* centraliza horizontalmente */
    display: block;    /* garante alinhamento */
}

/* =========================[ COLLAPSED BUTTONS ]========================= */

#sidebar.collapsed .sidebar-btn {
    width: 60px;
    justify-content: center;
    padding: 12px 0;
}

/* Esconde labels normalmente */
#sidebar.collapsed .sidebar-btn span {
    display: none;
}

.sidebar-btn span {
    transition: opacity 0.2s ease, width 0.2s ease, margin 0.2s ease;
    overflow: hidden;
    white-space: nowrap;
    display: inline-block;
}

#sidebar.collapsing .sidebar-btn span {
    opacity: 0;
    width: 0;
    margin: 0;
}

/* Sidebar já colapsado: não mostra o texto */
#sidebar.collapsed .sidebar-btn span {
    display: none;
}

/* Mostra label estilo tooltip quando hover */
#sidebar.collapsed .sidebar-btn:hover span {
    display: block;
    position: absolute;
    top: 50%;
    left: 100%;
    transform: translateY(-50%);
    white-space: nowrap;
    background-color: var(--color-dark);
    color: var(--color-text-light);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    margin-left: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}



/* =========================[ EXTRA ]========================= */

.top-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
