/* 03-layout.css — Page layout, sidebar, topbar, content area
   =========================================================== */

/* -----------------------------------------------------------
   4. Base Typography & Layout
   ----------------------------------------------------------- */
html, body {
    height: 100%;
}

code, pre, kbd, samp, .font-monospace {
    font-family: var(--c-font-mono) !important;
}

/* Force sidebar + content to sit side by side (row layout).
   Tabler 1.4.0 uses flex-direction:column for .page, which stacks
   the navbar-vertical on top of the page-wrapper. Override it. */
.page {
    display: flex !important;
    flex-direction: row !important;
    min-height: 100vh;
    align-items: stretch;
}

/* Reset any Tabler margin-left (used when sidebar is position:fixed) */
.page-wrapper {
    flex: 1 !important;
    min-width: 0;
    width: auto !important;
    margin-left: 0 !important;
    display: flex;
    flex-direction: column;
}

/* -----------------------------------------------------------
   5. Sidebar (#sidebar / .navbar-vertical)
   ----------------------------------------------------------- */
#sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: #070810 !important;
    border-right: 1px solid rgba(255, 255, 255, 0.07);
    transition: width 0.25s ease, min-width 0.25s ease;
    overflow: visible;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    z-index: 1040;
}

/* Inner container fills sidebar height */
#sidebar > .container-fluid {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0;
    overflow: hidden;
}

/* Collapse section grows to fill available space */
#sidebar .navbar-collapse {
    display: flex !important;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0;
}

#sidebar .navbar-nav {
    flex: 1;
    overflow: visible;
}

/* -----------------------------------------------------------
   5a. fp-logo — Sidebar brand block
   ----------------------------------------------------------- */
.fp-logo {
    padding: 0.875rem 0.875rem 0.75rem;
    border-bottom: 1px solid var(--c-border-subtle);
    flex-shrink: 0;
}

.fp-logo-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    text-decoration: none;
    color: inherit;
}

.fp-logo-link:hover {
    color: inherit;
    text-decoration: none;
}

.fp-logo-icon {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    background: var(--c-accent-dim);
    border: 1px solid var(--c-accent-bdr);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--c-accent);
    font-size: 0.9375rem;
    transition: background 0.15s ease;
}

.fp-logo-link:hover .fp-logo-icon {
    background: rgba(var(--c-accent-rgb), 0.18);
}

.fp-logo-text {
    overflow: hidden;
    transition: opacity 0.15s ease;
    min-width: 0;
}

.fp-logo-name {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}

.fp-logo-sub {
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    white-space: nowrap;
    margin-top: 1px;
}

/* -----------------------------------------------------------
   5b. Sidebar Nav Items
   ----------------------------------------------------------- */
#sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3125rem 0.75rem;
    border-radius: 6px;
    margin: 1px 0.5rem;
    font-size: 0.8125rem;
    font-weight: 450;
    color: var(--c-text-muted);
    border-left: 2px solid transparent;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
    white-space: nowrap;
}

#sidebar .nav-link:hover {
    color: var(--c-text);
    background: rgba(255, 255, 255, 0.04);
}

#sidebar .nav-link.active {
    color: var(--c-accent-light);
    background: var(--c-accent-glow);
    border-left-color: var(--c-accent);
    border-radius: 0;
    margin-left: 0;
    margin-right: 0;
    padding-left: calc(0.75rem + 2px);
}

#sidebar .nav-link-icon {
    width: 1rem;
    text-align: center;
    flex-shrink: 0;
    font-size: 0.9375rem;
    line-height: 1;
}

#sidebar .nav-link-title {
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.15s ease;
}

/* Nav section dividers */
.fp-nav-divider {
    border: none;
    border-top: 1px solid var(--c-border-subtle);
    margin: 0.375rem 0.875rem;
}

/* Sidebar dropdown menus — always dark */
#sidebar .dropdown-menu {
    background: #0e1118;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.25rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

#sidebar .dropdown-item {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    padding: 0.3125rem 0.75rem;
}

#sidebar .dropdown-item:hover,
#sidebar .dropdown-item:focus {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.85);
}

#sidebar .dropdown-item.active {
    background: var(--c-accent-dim);
    color: var(--c-accent-light);
}

/* -----------------------------------------------------------
   5c. fp-sidebar-footer — Theme toggle & version
   ----------------------------------------------------------- */
.fp-sidebar-footer {
    padding: 0.625rem 0.875rem;
    border-top: 1px solid var(--c-border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-shrink: 0;
}

.fp-theme-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    background: transparent;
    border: 1px solid var(--c-border);
    border-radius: 6px;
    padding: 0.3125rem 0.5rem;
    color: var(--c-text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
    white-space: nowrap;
    font-family: var(--c-font-ui);
}

.fp-theme-btn:hover {
    border-color: var(--c-accent);
    color: var(--c-accent-light);
    background: var(--c-accent-glow);
}

.fp-theme-btn i {
    font-size: 0.875rem;
}

.fp-btn-text {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    overflow: hidden;
    transition: opacity 0.15s ease, max-width 0.25s ease;
    max-width: 4rem;
}

.fp-sidebar-version {
    font-size: 0.625rem;
    color: var(--c-text-subtle);
    font-family: var(--c-font-mono);
    white-space: nowrap;
    flex-shrink: 0;
}

/* -----------------------------------------------------------
   6. Sidebar Collapse — html.sidebar-collapsed
   ----------------------------------------------------------- */
html.sidebar-collapsed #sidebar {
    width: var(--sidebar-collapsed-w);
    min-width: var(--sidebar-collapsed-w);
}

/* Hide text elements */
html.sidebar-collapsed .fp-logo-text,
html.sidebar-collapsed .fp-btn-text,
html.sidebar-collapsed .fp-sidebar-version,
html.sidebar-collapsed #sidebar .nav-link-title,
html.sidebar-collapsed #sidebar .dropdown-toggle::after {
    display: none;
}

/* Logo centering */
html.sidebar-collapsed .fp-logo {
    padding: 0.875rem 0 0.75rem;
    display: flex;
    justify-content: center;
}

html.sidebar-collapsed .fp-logo-link {
    justify-content: center;
}

/* Footer centering */
html.sidebar-collapsed .fp-sidebar-footer {
    justify-content: center;
    padding: 0.625rem 0.25rem;
}

html.sidebar-collapsed .fp-theme-btn {
    padding: 0.375rem;
    justify-content: center;
}

/* Nav link centering */
html.sidebar-collapsed #sidebar .nav-link {
    justify-content: center;
    padding: 0.375rem 0;
    margin: 1px 0.25rem;
}

html.sidebar-collapsed #sidebar .nav-link-icon {
    margin: 0;
    width: auto;
}

/* Nav divider in collapsed state */
html.sidebar-collapsed .fp-nav-divider {
    margin: 0.375rem 0.375rem;
}

/* Popout menus in collapsed state */
/* Allow dropdowns to escape the clipping containers */
html.sidebar-collapsed #sidebar > .container-fluid,
html.sidebar-collapsed #sidebar .navbar-collapse {
    overflow: visible;
}

html.sidebar-collapsed #sidebar .nav-item.dropdown {
    position: relative;
}

html.sidebar-collapsed #sidebar .nav-item.dropdown > .dropdown-menu {
    position: absolute !important;
    left: 100% !important;
    top: 0 !important;
    margin: 0 0 0 4px !important;
    transform: none !important;
}

html.sidebar-collapsed #sidebar .dropdown-menu.show {
    display: block;
}

/* Tooltips on hover for collapsed sidebar links */
html.sidebar-collapsed #sidebar .nav-link[data-menu-label],
html.sidebar-collapsed #sidebar [data-bs-toggle="dropdown"][data-menu-label] {
    position: relative;
}

html.sidebar-collapsed #sidebar .nav-link[data-menu-label]::after,
html.sidebar-collapsed #sidebar [data-bs-toggle="dropdown"][data-menu-label]::after {
    content: attr(data-menu-label);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--c-elevated);
    color: var(--c-text);
    border: 1px solid var(--c-border);
    padding: 0.25rem 0.625rem;
    border-radius: 5px;
    white-space: nowrap;
    font-size: 0.75rem;
    font-weight: 500;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    z-index: 1060;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

html.sidebar-collapsed #sidebar .nav-link[data-menu-label]:hover::after,
html.sidebar-collapsed #sidebar [data-bs-toggle="dropdown"][data-menu-label]:hover::after {
    opacity: 1;
    visibility: visible;
    transition-delay: 0.25s;
}

/* -----------------------------------------------------------
   7. fp-topbar — Sticky top bar
   ----------------------------------------------------------- */
.fp-topbar {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0 1rem;
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.fp-sidebar-toggle {
    background: transparent;
    border: none;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: var(--c-text-muted);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
    padding: 0;
    flex-shrink: 0;
}

.fp-sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--c-text);
}

.fp-topbar-sep {
    width: 1px;
    height: 14px;
    background: var(--c-border);
    flex-shrink: 0;
}

.fp-topbar-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--c-text-muted);
    white-space: nowrap;
}

.fp-topbar-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--c-text);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fp-icon-btn {
    background: transparent;
    border: none;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: var(--c-text-muted);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
    padding: 0;
}

.fp-icon-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--c-text);
}

/* Anchor tag variant — reset link styles */
a.fp-icon-btn {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Container for topbar plugin actions — scrollable on narrow viewports */
.fp-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    overflow-x: auto;
    max-width: 40vw;
    scrollbar-width: none;
}
.fp-topbar-actions::-webkit-scrollbar { display: none; }

/* Non-interactive preview variant used in admin overview tables */
.fp-icon-btn--preview {
    display: inline-flex;
    cursor: default;
    background: var(--c-accent-dim);
    color: var(--c-accent);
    border: 1px solid var(--c-accent-bdr);
}

/* -----------------------------------------------------------
   8. fp-content — Main content area
   ----------------------------------------------------------- */
.fp-content {
    flex: 1;
    padding: 1.25rem;
    background: var(--c-bg);
    animation: fp-fade-in 0.15s ease;
}

@keyframes fp-fade-in {
    from { opacity: 0; transform: translateY(3px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Layout toggle — html.layout-fluid makes container full-width */
html.layout-fluid .fp-content .container-xl {
    max-width: none;
    width: 100%;
}
