// Custom Dashboard Styles for Enterprise FMS

// 1. Theme Colors & Variables
$primary: #0f172a; 
$accent: #3b82f6;
$accent-glow: rgba(59, 130, 246, 0.4);
$sidebar-bg: #0f172a;
$sidebar-width: 280px;
$rtl: false !default;

// 2. Import Bootstrap
@import "bootstrap/scss/bootstrap";

// 3. Layout Components
body {
    background-color: #f8fafc;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: #1e293b;
}

.sidebar {
    width: $sidebar-width;
    height: 100vh;
    position: fixed;
    top: 0;
    inset-inline-start: 0;
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    color: #ffffff;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1010;
    overflow-y: auto;
    border-inline-end: 1px solid rgba(255, 255, 255, 0.05);

    &::-webkit-scrollbar {
        width: 4px;
    }
    &::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.1);
        border-radius: 10px;
    }

    .logo {
        padding: 2rem 1.5rem;
        font-size: 1.4rem;
        font-weight: 800;
        color: #fff;
        display: flex;
        align-items: center;
        letter-spacing: -0.025em;
        
        i {
            font-size: 1.8rem;
            background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
        }
    }

    .nav-section {
        margin-bottom: 0.5rem;
    }

    .nav-section-label {
        font-size: 0.85rem; // Increased from 0.725rem
        font-weight: 700; // Slightly bolder
        text-transform: uppercase;
        color: #ffffff !important;
        padding-block: 1.5rem 0.5rem;
        padding-inline: 1.5rem 1rem;
        letter-spacing: 0.1em;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        cursor: pointer;
        transition: color 0.2s;
        white-space: nowrap;
        overflow: hidden;

        span {
            overflow: hidden;
            text-overflow: ellipsis;
            padding-inline-end: 0.5rem;
        }

        &:hover {
            color: #fff;
        }

        .chevron {
            font-size: 0.8rem; // Slightly smaller to match
            transition: transform 0.3s;
            flex-shrink: 0;
        }

        &[aria-expanded="true"] {
            color: rgba(255, 255, 255, 0.9);
            .chevron { transform: rotate(180deg); }
        }
    }

    .nav-link {
        color: #ffffff !important;
        padding-block: 0.85rem;
        padding-inline: 1.5rem 1rem;
        margin-block: 0.125rem;
        margin-inline: 0.75rem;
        border-radius: 12px;
        display: flex;
        align-items: center;
        gap: 1rem; 
        font-size: 1.15rem; // Increased from 1.05rem
        font-weight: 500;
        transition: all 0.2s;
        text-decoration: none;
        white-space: nowrap;
        overflow: hidden;

        span {
            overflow: hidden;
            text-overflow: ellipsis;
        }

        i {
            font-size: 1.4rem; 
            transition: transform 0.2s;
            flex-shrink: 0;
            margin-inline-end: 0.75rem;
        }

        &:hover {
            background: rgba(255, 255, 255, 0.05);
            color: #fff;
            i { transform: translateX(2px); }
        }

        &.active {
            background: linear-gradient(90deg, rgba(59, 130, 246, 0.15) 0%, rgba(59, 130, 246, 0) 100%);
            color: #ffffff !important;
            border-inline-start: 3px solid #3b82f6;
            margin-inline-start: 0; 
            padding-inline-start: calc(1.5rem - 3px);
            border-radius: 0 12px 12px 0;
            
            i { color: #ffffff !important; }
        }

        &.sub-link {
            padding-inline-start: 2.8rem; // Slightly more for clarity
            font-size: 1rem; // Increased from 0.85rem
            margin-inline: 0.75rem;
            border-inline-start: none !important;
            padding-block: 0.6rem;

            .dot-icon {
                font-size: 4px; 
                opacity: 0.4;
                flex-shrink: 0;
            }

            &:hover, &.active {
                background: rgba(255, 255, 255, 0.03);
                .dot-icon { opacity: 1; color: #60a5fa; }
            }
        }
    }
}

.main-wrapper {
    margin-inline-start: $sidebar-width;
    min-height: 100vh;
}

// Top Header
.top-header {
    height: 80px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2.5rem;
    position: sticky;
    top: 0;
    z-index: 900;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

// Language Switcher Toggle
.lang-switcher {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    user-select: none;

    .lang-label {
        font-size: 0.85rem;
        font-weight: 800;
        color: #94a3b8;
        text-decoration: none;
        transition: color 0.3s;
        
        &.active {
            color: #1e293b;
        }
    }

    .lang-toggle-track {
        width: 60px;
        height: 30px;
        background: #e2e8f0;
        border-radius: 20px;
        position: relative;
        cursor: pointer;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        border: 2px solid #e2e8f0;
        overflow: hidden;
        display: block;

        &.en {
            // Simplified UK Flag approximation
            background: linear-gradient(90deg, #00247d 0%, #00247d 100%);
            &::before {
                content: '';
                position: absolute;
                inset: 0;
                background: 
                    linear-gradient(90deg, transparent 45%, #fff 45%, #fff 55%, transparent 55%),
                    linear-gradient(0deg, transparent 40%, #fff 40%, #fff 60%, transparent 60%),
                    linear-gradient(90deg, transparent 48%, #cf142b 48%, #cf142b 52%, transparent 52%),
                    linear-gradient(0deg, transparent 45%, #cf142b 45%, #cf142b 55%, transparent 55%);
            }
        }

        &.ar {
            // UAE Flag approximation (as per image)
            background: #fff;
            &::before {
                content: '';
                position: absolute;
                inset: 0;
                background: 
                    linear-gradient(180deg, #00732f 33.33%, #fff 33.33%, #fff 66.66%, #000 66.66%);
            }
            &::after {
                content: '';
                position: absolute;
                inset: 0;
                width: 30%;
                background: #ff0000;
            }
        }

        .lang-toggle-thumb {
            width: 22px;
            height: 22px;
            background: #fff;
            border-radius: 50%;
            position: absolute;
            top: 2px;
            left: 2px;
            transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
            box-shadow: 0 2px 4px rgba(0,0,0,0.2);
            z-index: 2;
        }

        &.ar .lang-toggle-thumb {
            transform: translateX(30px);
        }
    }
}

// Arabic Support & Layout Fixes
[dir="rtl"] {
    text-align: right;

    .sidebar {
        .nav-link.active {
            border-inline-start: none;
            border-inline-end: 3px solid #3b82f6;
            margin-inline: 0;
            padding-inline-start: 1rem;
            padding-inline-end: calc(1.5rem - 3px);
            border-radius: 12px 0 0 12px;
        }
        
        // Ensure proper spacing for icons in RTL
        .nav-link i, .nav-section-label i {
            margin-inline-end: 0.75rem;
            margin-inline-start: 0;
        }

        .chevron {
            transform: scaleX(-1); // Flip chevron base state
            &[aria-expanded="true"] {
                transform: scaleX(-1) rotate(-180deg);
            }
        }
    }

    .main-wrapper {
        margin-inline-start: $sidebar-width;
    }

    // Force Bootstrap Start/End flipping if natively failed
    .start-0 { right: 0; left: auto !important; }
    .end-0 { left: 0; right: auto !important; }
    
    .ms-auto { margin-right: auto !important; margin-left: 0 !important; }
    .me-auto { margin-left: auto !important; margin-right: 0 !important; }

    // Fix card icon overlapping
    .card .position-absolute.end-0 {
        left: 0 !important;
        right: auto !important;
    }

    .dropdown-menu-end {
        right: auto !important;
        left: 0 !important;
    }
    
    .text-end { text-align: left !important; }
    .text-start { text-align: right !important; }
}