/*
 * Suite page layout: fixed top bar, fixed sidebar, content area, footer.
 *
 * These are the WMS's layout rules (they live inline in its base.html),
 * collected into one stylesheet so every module lays its pages out the
 * same way. Colours come only from the theme variables in themes.css -
 * never write a colour value in this file or in a template.
 */

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    padding-top: 60px;
    padding-bottom: 56px;
}

/* ---- Top bar ---------------------------------------------------------- */
.navbar {
    background-color: var(--navbar-bg) !important;
    min-height: 60px;
}
.navbar .navbar-brand,
.navbar .nav-company,
.navbar .btn-nav {
    color: var(--navbar-text);
}
.navbar .nav-company {
    font-weight: 500;
    opacity: 0.9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.navbar .btn-nav {
    background: none;
    border: none;
    padding: 0.4rem 0.6rem;
    border-radius: 0.375rem;
}
.navbar .btn-nav:hover,
.navbar .btn-nav:focus-visible {
    background-color: rgba(255, 255, 255, 0.12);
    color: var(--navbar-text);
}
.navbar .dropdown-menu {
    background-color: var(--card-bg);
    border-color: var(--border-color);
}
.navbar .dropdown-item {
    color: var(--text-secondary);
}
.navbar .dropdown-item:hover,
.navbar .dropdown-item.active {
    background-color: var(--dropdown-hover);
    color: var(--dropdown-hover-text);
}
.navbar .dropdown-item:hover small,
.navbar .dropdown-item.active small {
    color: var(--dropdown-hover-text) !important;
}
.plan-badge {
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
    color: var(--navbar-text);
}

/* ---- Sidebar ---------------------------------------------------------- */
.sidebar {
    background-color: var(--sidebar-bg);
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    height: calc(100vh - 60px);
    position: fixed;
    top: 60px;
    left: 0;
    width: 250px;
    padding: 20px 0 76px;
    overflow-y: auto;
    z-index: 1000;
}
.sidebar .nav-item {
    list-style: none;
    padding: 0.25rem 0.5rem;
}
.sidebar .nav-link {
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    transition: background-color 0.2s ease;
    color: var(--sidebar-text) !important;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar .nav-link:hover {
    background-color: var(--bg-secondary);
}
.sidebar .nav-link.active {
    background-color: var(--primary-accent);
    color: #FFFFFF !important;
}
.sidebar .nav-section {
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--sidebar-text);
    opacity: 0.6;
    padding: 1rem 1.25rem 0.25rem;
}
.sidebar .nav-lock {
    float: right;
    opacity: 0.7;
}
.sidebar-backdrop {
    display: none;
}

/* ---- Content ---------------------------------------------------------- */
.content-wrapper {
    margin-left: 250px;
    padding: 24px;
    min-height: calc(100vh - 116px);
}
.content-wrapper.no-sidebar {
    margin-left: 0;
}

/* ---- Expandable sections of the sidebar -------------------------------- */
.sidebar .nav-group-toggle .nav-chevron {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}
.sidebar .nav-group-toggle[aria-expanded="true"] .nav-chevron {
    transform: rotate(180deg);
}
.sidebar .collapse .nav-link,
.sidebar .collapsing .nav-link {
    padding-left: 1.25rem;
    font-size: 0.95em;
}

/* ---- Collapsible sidebar (desktop) ------------------------------------ */
.sidebar {
    transition: width 0.3s ease;
}
.content-wrapper {
    transition: margin-left 0.3s ease;
}
.sidebar-toggle-btn {
    position: fixed;
    left: 200px;
    bottom: 80px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background-color: var(--sidebar-bg);
    border: 1px solid rgba(128, 128, 128, 0.35);
    color: var(--sidebar-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    transition: left 0.3s ease, background-color 0.2s ease;
}
.sidebar-toggle-btn:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.sidebar-toggle-btn i {
    font-size: 16px;
    transition: transform 0.3s ease;
}
.sidebar.collapsed {
    width: 0;
    padding: 0;
    overflow: hidden;
}
.sidebar.collapsed .nav {
    display: none;
}
.sidebar.collapsed .sidebar-toggle-btn {
    left: 10px;
    z-index: 1050;
}
.sidebar.collapsed .sidebar-toggle-btn i {
    transform: rotate(180deg);
}
.content-wrapper.sidebar-collapsed {
    margin-left: 0;
}
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}
.page-header h1 {
    font-size: 1.6rem;
    margin: 0;
    color: var(--text-primary);
}
.page-header .page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
}
.stat-card .stat-value {
    font-size: 1.9rem;
    font-weight: 600;
    line-height: 1.1;
    color: var(--text-primary);
}
.stat-card .stat-label {
    color: var(--text-muted);
    font-size: 0.85rem;
}
a.stat-card {
    text-decoration: none;
    display: block;
}
a.stat-card:hover {
    border-color: var(--primary-accent);
}
.detail-list dt {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.85rem;
}
.detail-list dd {
    color: var(--text-primary);
    margin-bottom: 0.6rem;
    overflow-wrap: anywhere;
}
.table td, .table th {
    vertical-align: middle;
}
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
}
.empty-state i {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    display: block;
}
.timeline {
    list-style: none;
    margin: 0;
    padding: 0;
}
.timeline li {
    border-left: 2px solid var(--border-color);
    padding: 0 0 1rem 1rem;
    position: relative;
}
.timeline li::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 0.3rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--primary-accent);
}
.timeline li:last-child {
    padding-bottom: 0;
}
.timeline .timeline-time {
    color: var(--text-muted);
    font-size: 0.85rem;
}
.secret-box {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 0.75rem;
    overflow-wrap: anywhere;
    color: var(--text-primary);
}
.item-row + .item-row {
    border-top: 1px solid var(--border-color);
    padding-top: 0.75rem;
    margin-top: 0.75rem;
}

/* ---- Footer ----------------------------------------------------------- */
.footer {
    position: fixed;
    bottom: 0;
    width: 100%;
    z-index: 1030;
    background-color: var(--navbar-bg);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.footer .version-link {
    color: rgba(255, 255, 255, 0.5);
}

/* ---- Sign-in pages ---------------------------------------------------- */
.auth-container {
    min-height: calc(100vh - 116px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* ---- Phones and tablets ----------------------------------------------- */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 1040;
        width: 270px;
    }
    body.sidebar-open .sidebar {
        transform: translateX(0);
    }
    .sidebar-toggle-btn {
        display: none;
    }
    body.sidebar-open .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 60px 0 0 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 1035;
    }
    .content-wrapper {
        margin-left: 0;
        padding: 16px;
    }
    /* The footer sits at the end of the page instead of covering the screen */
    .footer.fixed-bottom {
        position: static;
    }
    body {
        padding-bottom: 0;
    }
    /* Thumb-sized targets */
    .content-wrapper .btn {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.4rem;
    }
    .content-wrapper td .btn {
        min-height: 0;
    }
}

@media print {
    .navbar, .sidebar, .footer, .page-actions, .no-print {
        display: none !important;
    }
    body {
        padding: 0;
        background: #fff;
    }
    .content-wrapper {
        margin: 0;
        padding: 0;
    }
}

/* Screen-reader-only text (.visually-hidden) is absolutely positioned. Inside
   a scrolling table it must be anchored to the table's wrapper, or on a phone
   it sits out where the unscrolled table would end and widens the whole page. */
.table-responsive {
    position: relative;
}
