/*
 * Sidebar dropdown groups (dashboard-redesign demo). Only applies when the
 * page declares @section('nav_tree'), which adds .app-sidebar--tree to the
 * sidebar. Colours come from the existing theme tokens; logical properties
 * keep the tree line and connectors correct in Arabic (RTL).
 */

.app-sidebar--tree .app-nav-group + .app-nav-group { margin-top: 0.35rem; }

.app-sidebar--tree .app-nav-group > .app-nav-link {
    padding: 0.6rem 0.8rem;
    border-inline-start: 0;
    border-radius: 10px;
    font-weight: 500;
}
.app-sidebar--tree .app-nav-group > .app-nav-link.active {
    background: var(--brand-accent);
    color: #fff;
    box-shadow: 0 6px 16px color-mix(in srgb, var(--brand-accent) 38%, transparent);
}

/* Group header = the dropdown toggle */
.app-nav-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: rgba(246, 248, 247, 0.92);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: start;
    cursor: pointer;
    transition: background-color 0.12s ease;
}
.app-nav-group-toggle:hover { background: rgba(246, 248, 247, 0.08); }
.app-nav-group-toggle:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 1px; }
.app-nav-caret { flex: 0 0 auto; transition: transform 0.18s ease; opacity: 0.8; }
.app-nav-group.is-collapsed .app-nav-caret { transform: rotate(-90deg); }
[dir="rtl"] .app-nav-group.is-collapsed .app-nav-caret { transform: rotate(90deg); }

/* The tree: a vertical line with a short connector into each child */
.app-sidebar--tree .app-nav-sub {
    margin-inline-start: 1.15rem;
    padding-inline-start: 0.35rem;
    border-inline-start: 1px solid rgba(246, 248, 247, 0.2);
}
.app-nav-group.is-collapsed .app-nav-sub { display: none; }

.app-sidebar--tree .app-nav-sub .app-nav-link {
    position: relative;
    margin-inline-start: 0.7rem;
    padding: 0.42rem 0.7rem;
    border-inline-start: 0;
    border-radius: 8px;
    font-size: 0.86rem;
    color: rgba(246, 248, 247, 0.78);
}
.app-sidebar--tree .app-nav-sub .app-nav-link::before {
    content: "";
    position: absolute;
    inset-inline-start: -0.7rem;
    top: 50%;
    width: 0.7rem;
    border-block-start: 1px solid rgba(246, 248, 247, 0.2);
}
.app-sidebar--tree .app-nav-sub .app-nav-link:hover { color: #fff; }
.app-sidebar--tree .app-nav-sub .app-nav-link.active {
    background: color-mix(in srgb, var(--brand-accent) 85%, transparent);
    color: #fff;
}

@media (prefers-reduced-motion: reduce) {
    .app-nav-caret { transition: none; }
}

/* ==========================================================================
   Top bar (same demo scope: pages declaring @section('nav_tree'))
   ========================================================================== */

.app-topbar--tree {
    gap: 0.6rem;
    padding: 0.7rem 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: 0 1px 0 rgba(16, 24, 40, 0.02);
}
/* The brand-coloured accent line under the bar is replaced by the cleaner border. */
.app-topbar--tree + .app-topbar-accent { display: none; }

.app-topbar--tree .app-topbar-title {
    font-size: 1.05rem;
    font-weight: 600;
}

/* Every outlined control becomes a soft round button */
.app-topbar--tree .btn {
    --bs-btn-border-radius: 999px;
    --bs-btn-padding-x: 0.9rem;
    --bs-btn-padding-y: 0.4rem;
    --bs-btn-font-size: 0.8125rem;
    --bs-btn-font-weight: 500;
    --bs-btn-color: var(--ink-primary);
    --bs-btn-border-color: var(--border-subtle);
    --bs-btn-bg: var(--surface-card);
    --bs-btn-hover-color: var(--ink-primary);
    --bs-btn-hover-bg: color-mix(in srgb, var(--brand-primary) 8%, var(--surface-card));
    --bs-btn-hover-border-color: color-mix(in srgb, var(--brand-primary) 40%, var(--border-subtle));
    --bs-btn-active-color: var(--ink-primary);
    --bs-btn-active-bg: color-mix(in srgb, var(--brand-primary) 12%, var(--surface-card));
    --bs-btn-active-border-color: var(--brand-primary);
    box-shadow: none;
}
.app-topbar--tree .btn:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; }

/* Menu / theme toggles: round icon buttons */
.app-topbar--tree #sidebarCollapseToggle,
.app-topbar--tree #themeToggle,
.app-topbar--tree > .btn.d-lg-none {
    --bs-btn-padding-x: 0;
    width: 2.25rem;
    height: 2.25rem;
    justify-content: center;
    align-items: center;
    padding: 0;
}

/* EN | AR as one segmented pill */
.app-topbar--tree .btn-group {
    padding: 3px;
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    background: var(--surface-card);
}
.app-topbar--tree .btn-group .btn {
    --bs-btn-padding-x: 0.7rem;
    --bs-btn-padding-y: 0.2rem;
    --bs-btn-border-color: transparent;
    --bs-btn-bg: transparent;
    border-radius: 999px !important;
    margin: 0 !important;
}
.app-topbar--tree .btn-group .btn-primary {
    --bs-btn-bg: var(--brand-primary);
    --bs-btn-color: #fff;
    --bs-btn-hover-bg: var(--brand-primary-hover);
    --bs-btn-hover-color: #fff;
    --bs-btn-border-color: var(--brand-primary);
}

/* User menu: avatar + name + role */
.app-topbar--tree .dropdown > .btn { display: inline-flex; align-items: center; gap: 0.55rem; }
.app-topbar-avatar {
    display: grid;
    place-items: center;
    width: 1.7rem;
    height: 1.7rem;
    border-radius: 50%;
    background: var(--brand-primary);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 600;
}
.app-topbar-user { display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 1.15; text-align: start; }
.app-topbar-user-name { font-size: 0.8125rem; font-weight: 600; }
.app-topbar-user-role { font-size: 0.6875rem; color: var(--ink-secondary); font-weight: 400; }
@media (max-width: 575.98px) { .app-topbar-user { display: none; } }

.app-topbar--tree .dropdown-menu {
    margin-top: 0.4rem !important;
    padding: 0.4rem;
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(16, 24, 40, 0.14);
}
.app-topbar--tree .dropdown-item { border-radius: 8px; font-size: 0.875rem; }
.app-topbar--tree .badge { font-size: 0.65rem; }

/* Phones: keep the whole top bar inside the screen width. */
@media (max-width: 575.98px) {
    .app-topbar--tree { gap: 0.35rem; padding-inline: 0.5rem; }
    .app-topbar--tree .d-flex.ms-auto { gap: 0.3rem !important; min-width: 0; }
    .app-topbar--tree .btn,
    .app-topbar--tree .app-topbar-user-btn { padding-inline: 0.55rem; }
    .app-topbar--tree .dropdown-toggle::after { margin-inline-start: 0.25rem; }
    .app-topbar--tree .app-topbar-avatar { margin: 0; }
}
@media (max-width: 575.98px) {
    .app-topbar--tree #themeToggle,
    .app-topbar--tree #sidebarToggle,
    .app-topbar--tree > .btn { flex: 0 0 auto; min-width: 2.1rem; }
    /* The word "Notifications" becomes a bell so the bar fits a phone. */
    .app-topbar--tree .bell-label { font-size: 0; }
    .app-topbar--tree .bell-label::before {
        content: "";
        display: inline-block;
        width: 1.05rem;
        height: 1.05rem;
        vertical-align: -0.2em;
        background-color: currentColor;
        -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9'/%3E%3Cpath d='M10.3 21a1.94 1.94 0 0 0 3.4 0'/%3E%3C/svg%3E") center / contain no-repeat;
        mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9'/%3E%3Cpath d='M10.3 21a1.94 1.94 0 0 0 3.4 0'/%3E%3C/svg%3E") center / contain no-repeat;
    }
}

/* Icons beside the sidebar headers */
.app-sidebar--tree .app-nav-label { display: inline-flex; align-items: center; gap: 0.65rem; min-width: 0; }
.app-sidebar--tree .app-nav-icon { flex: 0 0 auto; opacity: 0.85; }
.app-sidebar--tree .app-nav-link.active .app-nav-icon,
.app-sidebar--tree .app-nav-group-toggle:hover .app-nav-icon { opacity: 1; }
