﻿/* ============================================================
   EFFIORA — site.css (FINAL CLEAN VERSION)
   ============================================================
   All duplicate selectors removed. All fixes applied.
   Ready to drop in as your complete site.css replacement.
   ============================================================ */

html {
    font-size: 14px;
    margin: 0;
    padding: 0;
    height: 100%;
    min-height: 100%;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

body {
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    background-color: #f8f9fa;
}

:root {
    --sidebar-width: 250px;
    --sidebar-bg: #fff;
    --sidebar-text: #000;
    --sidebar-hover-bg: rgba(0, 0, 0, 0.02);
    --sidebar-text-active-bg: rgba(0, 0, 0, 0.05);
    --transition-speed: 0.3s;
}


/* ==========================================================
   SIDEBAR — Core
   ========================================================== */

#sidebar {
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    width: var(--sidebar-width);
    min-height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-speed);
    position: relative;
    z-index: 1000;
    overflow: hidden;
    box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
}

    #sidebar.hidden {
        position: absolute;
        transform: translateX(-100%);
    }


/* ==========================================================
   SIDEBAR — Scrollable Nav Area
   ========================================================== */

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    scroll-behavior: smooth;
    /* Firefox scrollbar */
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}

    .sidebar-scroll:hover {
        scrollbar-color: rgba(0, 0, 0, 0.12) transparent;
    }

    /* Webkit scrollbar — invisible until hover */
    .sidebar-scroll::-webkit-scrollbar {
        width: 3px;
    }

    .sidebar-scroll::-webkit-scrollbar-track {
        background: transparent;
    }

    .sidebar-scroll::-webkit-scrollbar-thumb {
        background-color: transparent;
        border-radius: 3px;
    }

    .sidebar-scroll:hover::-webkit-scrollbar-thumb {
        background-color: rgba(0, 0, 0, 0.12);
    }

    .sidebar-scroll::-webkit-scrollbar-thumb:hover {
        background-color: rgba(0, 0, 0, 0.25);
    }


/* ==========================================================
   SIDEBAR — Logo / Header Area
   ========================================================== */

#sidebar > .d-flex.justify-content-between.align-items-center {
    padding: 0.75rem 1rem 0.25rem 1rem;
    flex-shrink: 0;
}


/* ==========================================================
   SIDEBAR — Search
   ========================================================== */

.sidebar-user-box input[type="text"],
input.form-control.form-control-sm {
    background-color: #FFF;
    border: 1px solid #4B256D;
    border-radius: 6px;
    padding: 6px 12px;
    height: 40px;
    font-size: 0.875rem;
}

.modern-search-form {
    position: relative;
    width: 100%;
    height: 40px;
    display: flex;
    align-items: center;
    padding-inline: 0.8em;
    border-radius: 30px;
    background: #fff;
    transition: border-radius 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

    .modern-search-form:before {
        content: "";
        position: absolute;
        background: #4B256D;
        transform: scaleX(0);
        width: 100%;
        height: 2px;
        bottom: 0;
        left: 0;
        transition: transform 0.3s ease;
    }

    .modern-search-form:focus-within {
        border-radius: 6px;
    }

        .modern-search-form:focus-within:before {
            transform: scaleX(1);
        }

.modern-search-input {
    flex-grow: 1;
    border: none;
    background: transparent;
    padding: 0.5em;
    font-size: 0.9rem;
}

    .modern-search-input:focus {
        outline: none;
    }

.modern-search-form button {
    background: none;
    border: none;
    color: #8b8ba7;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modern-search-reset {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
}

.modern-search-input:not(:placeholder-shown) ~ .modern-search-reset {
    opacity: 1;
    visibility: visible;
}

#searchSuggestions {
    z-index: 9999 !important;
    font-size: 0.85rem;
    max-height: 200px;
    overflow-y: auto;
}

    #searchSuggestions li:hover,
    #searchSuggestions li.active {
        background-color: #0d6efd;
        color: white;
        cursor: pointer;
    }


/* ==========================================================
   MAIN CONTENT
   ========================================================== */

#mainContent {
    flex-grow: 1;
    padding: 20px;
    transition: margin-left var(--transition-speed);
}


/* ==========================================================
   SIDEBAR — Buttons (Toggle, Close, Open)
   ========================================================== */

#toggleControls {
    display: flex;
    gap: 10px;
    padding: 10px;
    align-items: center;
}

#sidebarToggle {
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Close button (inside sidebar) */
#sidebarClose {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    transition: background-color 0.15s ease, transform 0.15s ease;
    cursor: pointer;
}

    #sidebarClose:hover {
        background: rgba(75, 37, 109, 0.06);
        transform: scale(1.05);
    }

    #sidebarClose:active {
        transform: scale(0.95);
    }

/* Open / Hamburger button (shown when sidebar is hidden) */
#sidebarOpen {
    position: fixed;
    top: 15px;
    left: 15px;
    display: none;
    z-index: 2000;
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 8px;
    padding: 8px;
    transition: background-color 0.2s ease;
}

    #sidebarOpen:hover {
        background-color: rgba(75, 37, 109, 0.1);
    }


/* ==========================================================
   SIDEBAR — Nav Links
   ========================================================== */

.nav-link {
    color: var(--sidebar-text) !important;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    transition: background-color 0.15s ease, transform 0.1s ease, padding-left 0.15s ease;
    border-radius: 8px;
    margin: 1px 0;
    font-size: 0.875rem;
}

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

    .nav-link.active {
        background-color: var(--sidebar-text-active-bg) !important;
        font-weight: 600;
        border-radius: 8px;
        color: var(--sidebar-text) !important;
        border-left: 3px solid #4B256D;
        padding-left: 13px;
    }

.nav-icon {
    font-size: 1.2rem;
    margin-right: 10px;
    min-width: 24px;
    text-align: center;
}

.bi-box-arrow-right {
    color: var(--sidebar-text);
}


/* ==========================================================
   SIDEBAR — Nav Item Layout
   ========================================================== */

.nav-item {
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* Nav pills container — let sidebar-scroll handle overflow */
.nav-pills {
    padding-bottom: 1rem;
    display: flex;
    flex-direction: column;
}


/* ==========================================================
   SIDEBAR — Collapsible Chevron Animation
   ========================================================== */

.nav-link[data-bs-toggle="collapse"] {
    position: relative;
}

    /* Single chevron — L-shaped border approach */
    .nav-link[data-bs-toggle="collapse"]::after {
        content: "";
        display: inline-block;
        width: 8px;
        height: 8px;
        margin-left: auto;
        border-right: 2px solid #9ca3af;
        border-bottom: 2px solid #9ca3af;
        transform: rotate(45deg);
        transition: transform 0.25s ease, border-color 0.25s ease;
        flex-shrink: 0;
    }

    /* When expanded (not collapsed), rotate up */
    .nav-link[data-bs-toggle="collapse"]:not(.collapsed)::after {
        transform: rotate(-135deg);
        border-color: #4B256D;
    }

    /* Hide any Bootstrap icons used as chevrons (we use CSS instead) */
    .nav-link[data-bs-toggle="collapse"] .bi-chevron-down,
    .nav-link[data-bs-toggle="collapse"] .bi-chevron-up {
        display: none;
    }


/* ==========================================================
   SIDEBAR — Sub-nav Items (inside collapse menus)
   ========================================================== */

.btn-toggle-nav {
    padding-left: 0;
    width: 100%;
}

    .btn-toggle-nav .nav-link {
        padding: 8px 16px 8px 3rem;
        font-size: 0.82rem;
        color: #4b5563 !important;
        border-radius: 6px;
        margin: 0;
    }

        .btn-toggle-nav .nav-link:hover {
            background-color: rgba(75, 37, 109, 0.04);
            color: #1f2937 !important;
        }

        .btn-toggle-nav .nav-link.active {
            background-color: rgba(75, 37, 109, 0.08) !important;
            color: #4B256D !important;
            font-weight: 600;
            border-left: 2px solid #4B256D;
            padding-left: calc(3rem - 2px);
        }


/* ==========================================================
   SIDEBAR — Dividers
   ========================================================== */

/* Main sidebar divider (between logo and nav) */
#sidebar > hr,
#sidebar > .sidebar-scroll hr.text-secondary {
    border: none;
    height: 1px;
    background: linear-gradient( to right, transparent, rgba(0, 0, 0, 0.08) 20%, rgba(0, 0, 0, 0.08) 80%, transparent );
    margin: 0.5rem 1rem;
}

/* Sub-menu dividers */
.btn-toggle-nav hr.dropdown-divider {
    border: none;
    height: 1px;
    background: rgba(0, 0, 0, 0.05);
    margin: 2px 8px;
}


/* ==========================================================
   SIDEBAR — Tenant Selector
   ========================================================== */

#tenantSelect {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: #f8f7fa;
    border: 1px solid rgba(75, 37, 109, 0.15);
    border-radius: 8px;
    padding: 8px 32px 8px 12px;
    font-size: 0.82rem;
    font-weight: 500;
    color: #2d1a42;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    /* Custom dropdown arrow */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234B256D' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
}

    #tenantSelect:hover {
        border-color: rgba(75, 37, 109, 0.35);
        background-color: #f3f0f7;
    }

    #tenantSelect:focus {
        outline: none;
        border-color: #4B256D;
        box-shadow: 0 0 0 3px rgba(75, 37, 109, 0.1);
        background-color: #fff;
    }

    /* Override Bootstrap form-select arrow */
    #tenantSelect.form-select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234B256D' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
        background-position: right 10px center !important;
        background-size: 12px !important;
        padding-right: 32px;
    }

.tenant-switcher-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9ca3af;
    margin-bottom: 4px;
    padding-left: 2px;
}


/* ==========================================================
   SIDEBAR — User Box (bottom)
   ========================================================== */

.sidebar-user-box {
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 10px;
    padding: 0.65rem 0.75rem;
    margin: 0.25rem 0.5rem;
    margin-top: auto;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    color: inherit;
    text-decoration: none;
    max-width: 100%;
    overflow: hidden;
}

    .sidebar-user-box:hover,
    .sidebar-user-box:focus,
    .sidebar-user-box:active {
        background-color: rgba(75, 37, 109, 0.04);
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
        text-decoration: none;
        color: inherit;
    }

    /* Avatar ring */
    .sidebar-user-box img.rounded-circle {
        border: 2px solid rgba(75, 37, 109, 0.1);
        transition: border-color 0.2s ease;
    }

    .sidebar-user-box:hover img.rounded-circle {
        border-color: rgba(75, 37, 109, 0.3);
    }

    /* Text container — allow shrinking for truncation */
    .sidebar-user-box .d-flex.flex-column {
        min-width: 0;
        flex: 1;
    }

    /* Name — truncate */
    .sidebar-user-box .fw-semibold {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: block;
        max-width: 100%;
        font-size: 0.85rem;
    }

    /* Email — truncate + smaller */
    .sidebar-user-box small {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: block;
        max-width: 100%;
        font-size: 0.72rem;
        color: #6b7280;
        line-height: 1.3;
    }


/* ==========================================================
   SIDEBAR — Logout Button
   ========================================================== */

#logout_sidebar {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease, transform 0.15s ease;
    cursor: pointer;
}

    #logout_sidebar:hover {
        background: rgba(220, 38, 38, 0.06);
        transform: scale(1.05);
    }

        #logout_sidebar:hover svg {
            stroke: #dc2626;
        }


/* ==========================================================
   MOBILE BEHAVIOR
   ========================================================== */

@media (max-width: 768px) {

    /* Base mobile sidebar — hidden by default (slid off-screen) */
    #sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: 88vw; /* Nearly full screen */
        max-width: 320px; /* Cap for larger phones / small tablets */
        max-height: 100vh;
        z-index: 1050;
        transform: translateX(-100%); /* Hidden by default */
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
    }

        /* When .show is added (by JS), slide the sidebar in */
        #sidebar.show {
            transform: translateX(0);
            box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
        }

        /* Override: .hidden should NOT use position: absolute on mobile */
        #sidebar.hidden {
            position: fixed;
            transform: translateX(-100%);
        }

    /* Hamburger button — always show on mobile */
    #sidebarOpen {
        display: block !important;
    }

    /* Hide hamburger when sidebar is visible */
    #sidebar.show ~ #sidebarOpen {
        display: none !important;
    }
}

/* ─── BACKDROP OVERLAY ) ─── */

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 1049; /* Just below sidebar (1050) */
    transition: background 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

    .sidebar-backdrop.show {
        display: block;
        background: rgba(0, 0, 0, 0.4);
        -webkit-backdrop-filter: blur(2px);
        backdrop-filter: blur(2px);
    }

/* ==========================================================
   DRAWER (side panels / detail views)
   ========================================================== */

.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .4);
    display: flex;
    justify-content: flex-end;
    z-index: 1050;
}

.drawer {
    width: 360px;
    background: #fff;
    height: 100%;
    box-shadow: -3px 0 10px rgba(0, 0, 0, .2);
    animation: slideIn .25s ease-out;
}

.drawer-header {
    padding: 1rem;
    border-bottom: 1px solid #eee;
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
}

.drawer-footer {
    background: #fafafa;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}


/* Fix: position:fixed elements inside flex body need this */
@media (max-width: 768px) {
    body {
        display: block; /* Fixed positioning breaks inside flex on mobile */
    }

    #sidebar.hidden + #sidebarBackdrop + #sidebarOpen + #mainContent,
    #mainContent {
        min-height: 100vh;
    }
}