/* Shared custom styles (consolidated from template inline styles) */

/* Required field indicator — use via .required-star after label text or auto via CSS */
.form-label .text-danger,
.required-star {
    color: #dc3545;
    font-weight: bold;
    margin-left: 2px;
}

.text-xs {
    font-size: 0.7rem;
}

.text-gray-800 {
    color: #5a5c69 !important;
}

body.dark-theme .text-gray-800 {
    color: #b0b0b0 !important;
}

.avatar-sm {
    width: 36px;
    height: 36px;
    font-size: 0.85rem;
}

/* ── Breadcrumb Bar ──────────────────────────────────────── */
.breadcrumb-bar {
    padding: 0.45rem 0;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    font-size: 0.8rem;
    border-bottom: 1px solid #e9ecef;
}

body.dark-theme .breadcrumb-bar {
    border-bottom-color: #404040;
}

.breadcrumb-bar .breadcrumb {
    background: none;
    padding: 0;
    margin: 0;
}

.breadcrumb-bar .breadcrumb-item a {
    color: #5a6a85;
    text-decoration: none;
    transition: color 0.15s;
    font-weight: 400;
}

.breadcrumb-bar .breadcrumb-item a:hover {
    color: #4e73df;
}

.breadcrumb-bar .breadcrumb-item a i {
    opacity: 0.55;
    margin-right: 0.25rem;
}

body.dark-theme .breadcrumb-bar .breadcrumb-item a {
    color: #8eaadc;
}

body.dark-theme .breadcrumb-bar .breadcrumb-item a:hover {
    color: #b4ccf0;
}

.breadcrumb-bar .breadcrumb-item.active {
    color: #858a95;
    font-weight: 400;
}

body.dark-theme .breadcrumb-bar .breadcrumb-item.active {
    color: #999;
}

.breadcrumb-bar .breadcrumb-item + .breadcrumb-item::before {
    content: "/";
    color: #c5c9d4;
    font-size: 0.75rem;
    padding: 0 0.35rem;
}

body.dark-theme .breadcrumb-bar .breadcrumb-item + .breadcrumb-item::before {
    color: #555;
}

/* ── Flash Banners ────────────────────────────────────────── */
.flash-banner {
    position: relative;
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    animation: flashSlideIn 0.35s ease-out;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.flash-banner.flash-dismissing {
    opacity: 0;
    transform: translateY(-10px);
}

.flash-body {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    gap: 0.75rem;
}

.flash-icon {
    font-size: 1.15rem;
    flex-shrink: 0;
}

.flash-msg {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.4;
}

.flash-msg a {
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.flash-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    opacity: 0.6;
    transition: opacity 0.2s, background-color 0.2s;
    flex-shrink: 0;
    font-size: 0.8rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.flash-close:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.08);
}

.flash-progress {
    height: 3px;
    width: 100%;
}

.flash-progress-bar {
    height: 100%;
    width: 100%;
    animation: flashCountdown 5s linear forwards;
}

@keyframes flashSlideIn {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes flashCountdown {
    from { width: 100%; }
    to   { width: 0%; }
}

/* Card enhancements */
.card {
    border: none;
}

.card-header {
    border-bottom: 1px solid #e3e6f0;
}

body.dark-theme .card-header {
    border-bottom: 1px solid #444444;
}

/* Table header styling */
.table th {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Responsive adjustments */
@media (max-width: 992px) {
    .table-responsive {
        font-size: 0.875rem;
    }

    .table th {
        font-size: 0.75rem;
        padding: 0.5rem;
    }

    .table td {
        padding: 0.5rem;
    }
}

@media (max-width: 768px) {
    .btn-group {
        flex-direction: column;
        gap: 0.25rem;
    }

    .btn-group .btn {
        width: 100%;
    }
}

/* ============================================================
   Sidebar Layout
   ============================================================ */
:root {
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 60px;
    --sidebar-bg: #1e293b;
    --sidebar-text: rgba(255, 255, 255, 0.7);
    --sidebar-text-hover: #ffffff;
    --sidebar-active-bg: rgba(255, 255, 255, 0.08);
    --sidebar-active-accent: #3b82f6;
    --sidebar-border: rgba(255, 255, 255, 0.08);
    --sidebar-submenu-bg: rgba(0, 0, 0, 0.15);
    --sidebar-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Sidebar container --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--sidebar-bg);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: width var(--sidebar-transition);
    overflow: hidden;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

/* --- Sidebar header --- */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.75rem;
    min-height: 56px;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: #fff !important;
    text-decoration: none !important;
    font-size: 1.05rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s;
}

.sidebar-brand:hover {
    color: #fff !important;
    text-decoration: none !important;
}

.sidebar-version {
    font-size: 0.6rem;
    font-weight: 400;
    opacity: 0.5;
    letter-spacing: 0.02em;
    margin-left: -0.3rem;
    align-self: flex-end;
    margin-bottom: 0.1rem;
}

.sidebar-brand i {
    font-size: 1.25rem;
    min-width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    padding: 0.3rem;
    font-size: 0.9rem;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}

.sidebar-toggle:hover {
    color: var(--sidebar-text-hover);
    background: var(--sidebar-active-bg);
}

.sidebar.collapsed .sidebar-label {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 0 0.5rem;
}

/* --- Sidebar navigation --- */
/* Tenant switcher — inherit sidebar text colours */
.sidebar-tenant-switcher .btn {
    color: var(--sidebar-text) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    background: transparent !important;
}

.sidebar-tenant-switcher .btn:hover,
.sidebar-tenant-switcher .btn:focus,
.sidebar-tenant-switcher .btn:active,
.sidebar-tenant-switcher .btn.show,
.sidebar #tenantSwitcherBtn:hover,
.sidebar #tenantSwitcherBtn:focus,
.sidebar #tenantSwitcherBtn:active {
    color: var(--sidebar-text-hover) !important;
    background: var(--sidebar-active-bg) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
    box-shadow: none !important;
}

/* Tenant dropdown — force dark styling on all items */
.sidebar-tenant-switcher .dropdown-menu {
    background-color: #1e293b !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

.sidebar-tenant-switcher .dropdown-item {
    color: rgba(255, 255, 255, 0.7) !important;
}

.sidebar-tenant-switcher .dropdown-item:hover,
.sidebar-tenant-switcher .dropdown-item:focus {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.08) !important;
}

.sidebar-tenant-switcher .dropdown-item.active {
    color: #ffffff !important;
    background-color: rgba(59, 130, 246, 0.25) !important;
}

.sidebar-tenant-switcher .dropdown-divider {
    border-color: rgba(255, 255, 255, 0.1) !important;
}

/* Timer button — green accent on sidebar dark background */
.sidebar-timer .btn {
    color: #51cf66 !important;
    border-color: rgba(81, 207, 102, 0.4) !important;
    background: transparent !important;
}

.sidebar-timer .btn:hover {
    color: #ffffff !important;
    background: rgba(81, 207, 102, 0.2) !important;
    border-color: #51cf66 !important;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 1rem;
    color: var(--sidebar-text) !important;
    text-decoration: none !important;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
    font-size: 0.88rem;
    position: relative;
    border-left: 3px solid transparent;
}

.sidebar-nav .nav-link:hover {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-text-hover) !important;
}

.sidebar-nav .nav-link.active {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-text-hover) !important;
    border-left-color: var(--sidebar-active-accent);
}

.sidebar-nav .nav-link > i:first-child {
    width: 1.25em;
    text-align: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.sidebar-nav .nav-link .link-text {
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.15s;
}

.sidebar.collapsed .sidebar-nav .nav-link .link-text,
.sidebar.collapsed .sidebar-nav .submenu-arrow,
.sidebar.collapsed .sidebar-footer .link-text,
.sidebar.collapsed .sidebar-timer .link-text,
.sidebar.collapsed .sidebar-tenant-switcher .link-text {
    display: none !important;
}

.sidebar.collapsed .sidebar-nav .nav-link {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
    border-left: none;
    gap: 0;
}

.sidebar.collapsed .sidebar-nav .nav-link.active {
    background-color: var(--sidebar-active-bg);
}

.sidebar.collapsed .sidebar-timer,
.sidebar.collapsed .sidebar-tenant-switcher {
    padding: 0 !important;
}

.sidebar.collapsed .sidebar-timer .btn,
.sidebar.collapsed .sidebar-tenant-switcher .btn {
    width: 100%;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    padding: 0.6rem 0 !important;
    justify-content: center;
    font-size: 0.95rem;
}

.sidebar.collapsed .sidebar-timer .btn:hover,
.sidebar.collapsed .sidebar-tenant-switcher .btn:hover {
    background: var(--sidebar-active-bg) !important;
}

/* Collapsed tenant — align icon for both switcher button and static display */
.sidebar.collapsed .sidebar-tenant-switcher .btn > i:first-child,
.sidebar.collapsed .sidebar-tenant-switcher .d-flex > i:first-child {
    margin-right: 0 !important;
    width: 1.25em;
    text-align: center;
}

/* Static tenant display (single-tenant users) — center icon when collapsed */
.sidebar.collapsed .sidebar-tenant-switcher > .d-flex {
    justify-content: center;
    padding: 0.6rem 0 !important;
}

/* Collapsed tenant dropdown — pop out to the right of the sidebar */
.sidebar.collapsed .sidebar-tenant-switcher .dropdown-menu.show {
    position: fixed !important;
    left: var(--sidebar-collapsed-width) !important;
    width: auto !important;
    min-width: 200px;
    z-index: 1080;
}

/* --- Sub-menu arrow --- */
.submenu-arrow {
    margin-left: auto;
    font-size: 0.6rem;
    transition: transform 0.25s;
    flex-shrink: 0;
}

.nav-item.open > .nav-link .submenu-arrow {
    transform: rotate(90deg);
}

/* --- Sub-menu --- */
.sidebar-nav .submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background-color: var(--sidebar-submenu-bg);
}

.sidebar-nav .nav-item.open > .submenu {
    max-height: 500px;
}

.sidebar-nav .submenu .nav-link {
    padding-left: 2.5rem;
    font-size: 0.84rem;
    border-left-width: 0;
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
}

.sidebar-nav .submenu .nav-link > i:first-child {
    width: 1.25em;
    font-size: 0.82rem;
}

.sidebar.collapsed .submenu {
    max-height: 0 !important;
}

/* --- Submenu group headings --- */
.submenu-heading {
    padding: 0.4rem 2.5rem 0.15rem;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sidebar-text-muted, rgba(255,255,255,0.4));
    border-top: 1px solid var(--sidebar-border, rgba(255,255,255,0.08));
    margin-top: 0.25rem;
    list-style: none;
}

.submenu-heading:first-child {
    border-top: none;
    margin-top: 0;
}

.sidebar.collapsed .submenu-heading {
    display: none;
}

/* --- Sidebar divider --- */
.sidebar-divider {
    border-top: 1px solid var(--sidebar-border);
    margin: 0.4rem 0.75rem;
}

/* --- Sidebar section label (e.g. "Admin") --- */
.sidebar-section-label {
    list-style: none;
    padding: 0.35rem 1rem 0.1rem;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.35);
}
.sidebar.collapsed .sidebar-section-label .link-text {
    display: none;
}

/* --- Sidebar footer --- */
.sidebar-footer {
    border-top: 1px solid var(--sidebar-border);
    padding: 0.25rem 0;
    flex-shrink: 0;
}

.sidebar-footer .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.45rem 1rem;
    color: var(--sidebar-text) !important;
    text-decoration: none !important;
    white-space: nowrap;
    font-size: 0.84rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.sidebar-footer .nav-link:hover {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-text-hover) !important;
}

.sidebar-footer .nav-link > i:first-child {
    width: 1.25em;
    text-align: center;
    flex-shrink: 0;
}

.sidebar.collapsed .sidebar-footer .nav-link {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
    gap: 0;
}

.sidebar-user-badge {
    font-size: 0.65rem;
    vertical-align: middle;
}

/* --- Main content area --- */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--sidebar-transition);
}

.main-content.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed-width);
}

/* --- Mobile top bar --- */
.main-topbar {
    display: none;
}

/* --- Mobile overlay --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1039;
    transition: opacity 0.25s;
}

.sidebar-overlay.active {
    display: block;
}

/* --- Mobile responsive --- */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
        transition: transform var(--sidebar-transition);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
    }

    .main-topbar {
        display: flex;
        align-items: center;
        padding: 0.6rem 1rem;
        background-color: var(--sidebar-bg);
        color: #fff;
        position: sticky;
        top: 0;
        z-index: 1030;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    }

    .main-topbar .mobile-toggle {
        background: none;
        border: none;
        color: #fff;
        font-size: 1.15rem;
        padding: 0.25rem 0.5rem;
        cursor: pointer;
    }

    .main-topbar .brand-text {
        font-weight: 600;
        font-size: 1rem;
        margin-left: 0.75rem;
    }
}

/* ── Help Panel ────────────────────────────────────────────── */
#helpPanel {
    width: 440px;
    max-width: 100%;
    z-index: 1060;
}

#helpPanel .offcanvas-header {
    background-color: var(--sidebar-bg, #1e293b);
    color: #fff;
}

#helpPanel .offcanvas-header .btn-close {
    filter: invert(1);
}

#helpPanel .offcanvas-footer {
    background-color: #f8f9fa;
}

/* Help content typography */
.help-content h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #dee2e6;
}

.help-content h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.help-content h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
}

.help-content p {
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

.help-content ul,
.help-content ol {
    padding-left: 1.5rem;
    margin-bottom: 0.75rem;
}

.help-content li {
    margin-bottom: 0.35rem;
    line-height: 1.5;
}

.help-content table {
    width: 100%;
    margin-bottom: 1rem;
    border-collapse: collapse;
}

.help-content th,
.help-content td {
    padding: 0.5rem 0.75rem;
    border: 1px solid #dee2e6;
    text-align: left;
}

.help-content th {
    background-color: #f8f9fa;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.help-content code {
    background-color: #f1f3f5;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.875em;
}

.help-content strong {
    font-weight: 600;
}

/* Help index cards */
.help-card {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
}

.help-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

@media (max-width: 768px) {
    #helpPanel {
        width: 100%;
    }
}
