/* ==============================================
   SIDEBAR — SEIA THEME
   Ficheiro: assets/css/sidebar.css
   
   ============================================== */

/* ---- VARIÁVEIS ---- */
:root {
    --sb-primary:       #2c5aa0;
    --sb-primary-mid:   #3b7dcc;
    --sb-primary-light: #e8f0fb;
    --sb-primary-dark:  #1e3f73;
    --sb-border:        #d4dbe8;
    --sb-bg:            #ffffff;
    --sb-bg-section:    #f4f6fb;
    --sb-text:          #1a1a2e;
    --sb-text-muted:    #666;
    --sb-radius:        10px;
    --sb-collapsed:     100px;
    --sb-expanded:      280px;
    --sb-transition:    0.35s cubic-bezier(0.4, 0, 0.2, 1);
    --sb-z:             100;
}

/* =============================================
   SIDEBAR CONTAINER
   A sidebar fica em posição absoluta e flutua
   por cima do conteúdo ao expandir.
   O elemento pai deve ter position: relative.
   ============================================= */
.sidebar-primary {
    width: var(--sb-collapsed);
    background: var(--sb-bg);
    border: 1px solid var(--sb-border);
    border-radius: var(--sb-radius);
    box-shadow: 0 2px 10px rgba(44, 90, 160, 0.08);
    overflow: visible;
    transition: width var(--sb-transition), box-shadow var(--sb-transition);
    display: flex;
    flex-direction: column;
    position: absolute;
    /* Afastar da margem do ecrã */
    top: 20px;
    left: 20px;
    z-index: var(--sb-z);
}

.sidebar-primary:hover {
    width: var(--sb-expanded);
    box-shadow: 0 8px 32px rgba(44, 90, 160, 0.18);
}

/* =============================================
   HEADER DA SIDEBAR
   ============================================= */
.sidebar-header {
    background: linear-gradient(135deg, var(--sb-primary) 0%, var(--sb-primary-mid) 100%);
    border-bottom: solid var(--sb-primary-dark);
    border-radius: var(--sb-radius) var(--sb-radius) 0 0;
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

.sidebar-header .icon-only {
    font-size: 1.2rem;
    color: white;
    opacity: 1;
    position: absolute;
    transition: opacity var(--sb-transition);
}

.sidebar-header .title-full {
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
    letter-spacing: 1.8px;
    text-transform: uppercase;
    white-space: nowrap;
    opacity: 0;
    padding: 0 1.2rem;
    transition: opacity var(--sb-transition);
}

.sidebar-primary:hover .sidebar-header .icon-only  { opacity: 0; }
.sidebar-primary:hover .sidebar-header .title-full { opacity: 1; }

/* =============================================
   SECÇÕES
   ============================================= */
.sidebar-section {
    border-bottom: 1px solid var(--sb-border);
    position: relative;
}

.sidebar-section:last-child {
    border-bottom: none;
}

.section-header {
    display: flex;
    align-items: center;
    min-height: 46px;
    overflow: hidden;
    white-space: nowrap;
    cursor: default;
    transition: background 0.2s;
}

.sidebar-section:hover .section-header {
    background: var(--sb-primary-light);
}

.section-icon {
    width: var(--sb-collapsed);
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
    color: var(--sb-primary);
    transition: transform 0.2s;
}

.sidebar-section:hover .section-icon {
    transform: scale(1.15);
}

.section-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--sb-primary);
    letter-spacing: 1.1px;
    text-transform: uppercase;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity var(--sb-transition), transform var(--sb-transition);
}

.sidebar-primary:hover .section-label {
    opacity: 1;
    transform: translateX(0);
}

/* =============================================
   CORPO DA SECÇÃO
   ============================================= */


.sidebar-menu {
    margin-top: 20px;
}

/* Base: escondido */
.section-body {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    padding: 0 1rem;
    background: var(--sb-bg);
    transition: max-height var(--sb-transition),
                opacity var(--sb-transition),
                padding var(--sb-transition);
}

/*
 * SIDEBAR FECHADA + hover na secção
 * Flyout flutua à direita, por cima do conteúdo
 */
.sidebar-primary:not(:hover) .sidebar-section:hover .section-body {
    position: absolute;
    left: calc(var(--sb-collapsed) + 8px);
    top: 0;
    width: 240px;
    background: var(--sb-bg);
    border: 1px solid var(--sb-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(44, 90, 160, 0.18);
    z-index: calc(var(--sb-z) + 100);
    max-height: 600px;
    opacity: 1;
    overflow-y: auto;
    padding: 0.8rem 1rem;
}

/* Título automático no topo do flyout via data-label */
.sidebar-primary:not(:hover) .sidebar-section:hover .section-body::before {
    content: attr(data-label);
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 1.3px;
    text-transform: uppercase;
    color: var(--sb-primary);
    padding-bottom: 0.4rem;
    margin-bottom: 0.4rem;
    border-bottom: 2px solid var(--sb-primary-light);
}

/*
 * SIDEBAR ABERTA + hover na secção
 * Lista expande inline, por baixo do header
 */
.sidebar-primary:hover .sidebar-section:hover .section-body {
    position: static;
    max-height: 600px;
    opacity: 1;
    padding: 0.2rem 1rem 0.8rem;
    box-shadow: none;
    border: none;
    border-radius: 0;
    width: auto;
}

/* =============================================
   LINKS
   ============================================= */
.section-body ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.section-body li {
    border-bottom: 1px solid #edf0f5;
}

.section-body li:last-child {
    border-bottom: none;
}

.section-body a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.52rem 0.4rem;
    color: var(--sb-text);
    text-decoration: none;
    font-size: 0.83rem;
    font-weight: 400;
    border-left: 2px solid transparent;
    margin: 0 -0.4rem;
    padding-left: 0.4rem;
    border-radius: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.18s;
}

.section-body a:hover {
    background: var(--sb-primary-light);
    color: var(--sb-primary);
    border-left-color: var(--sb-primary-mid);
    font-weight: 600;
}

/* Badge contador */
.section-body .count {
    background: #e3eaf5;
    color: var(--sb-primary);
    padding: 0.12rem 0.5rem;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-left: 0.5rem;
    transition: all 0.18s;
}

.section-body a:hover .count {
    background: var(--sb-primary-mid);
    color: white;
}

/* =============================================
   FORMULÁRIO DE PESQUISA
   (compatível com get_search_form() do WordPress)
   ============================================= */
.section-body .search-form,
.section-body .search-form form {
    display: flex;
    gap: 0.35rem;
    padding: 0.3rem 0;
}

.section-body .search-form input[type="search"],
.section-body .search-form input[type="text"] {
    flex: 1;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--sb-border);
    border-radius: 4px;
    font-size: 0.82rem;
    min-width: 0;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.section-body .search-form input:focus {
    outline: none;
    border-color: var(--sb-primary-mid);
    box-shadow: 0 0 0 3px rgba(59, 125, 204, 0.1);
}

.section-body .search-form button,
.section-body .search-form input[type="submit"] {
    padding: 0.5rem 0.85rem;
    background: var(--sb-primary-mid);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
    transition: background 0.2s;
}

.section-body .search-form button:hover,
.section-body .search-form input[type="submit"]:hover {
    background: var(--sb-primary);
}

/* =============================================
   RESPONSIVO — MOBILE
   Sidebar escondida; expande com botão toggle
   ============================================= */
@media (max-width: 768px) {

    /* Botão toggle — adicionar ao PHP antes da <aside> */
    .sidebar-toggle {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        background: var(--sb-primary);
        color: white;
        border: none;
        border-radius: 6px;
        padding: 0.55rem 1rem;
        font-size: 0.82rem;
        font-weight: 700;
        cursor: pointer;
        margin-bottom: 0.75rem;
        transition: background 0.2s;
    }

    .sidebar-toggle:hover {
        background: var(--sb-primary-dark);
    }

    /* Sidebar escondida por defeito */
    .sidebar-primary {
        position: static;
        width: 100%;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        border: none;
        box-shadow: none;
        border-radius: 0;
        transition: max-height var(--sb-transition), opacity var(--sb-transition);
    }

    /* Classe adicionada via JS ao clicar no botão toggle */
    .sidebar-primary.is-open {
        max-height: 2000px;
        opacity: 1;
        border: 1px solid var(--sb-border);
        border-radius: var(--sb-radius);
        box-shadow: 0 4px 16px rgba(44, 90, 160, 0.12);
        overflow: visible;
    }

    /* No mobile, itens expandem inline (sem flyout) */
    .sidebar-primary.is-open .sidebar-section:hover .section-body {
        position: static;
        max-height: 600px;
        opacity: 1;
        padding: 0.2rem 1rem 0.8rem;
        box-shadow: none;
        border: none;
        width: auto;
    }

    /* Labels visíveis quando aberta */
    .sidebar-primary.is-open .section-label {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Esconder o botão toggle no desktop */
@media (min-width: 769px) {
    .sidebar-toggle {
        display: none;
    }
}

