/**
 * Boat.Rent Directory - App Shell UI
 * Powers the SPA Portal Layout (Sidebar, Topbar, Grid Layouts).
 *
 * @package BoatRentDirectory
 * @version 3.0.0
 */

/* ==========================================================================
   1. SAAS VARIABLES
   ========================================================================== */
:root {
    /* Brand Colors */
    --br-primary: #1B4E7A;
    --br-primary-hover: #123656;
    --br-gold: #eab308;
    
    /* Layout Colors */
    --br-bg-main: #f8fafc;
    --br-sidebar-bg: #0f172a;
    --br-sidebar-hover: rgba(255, 255, 255, 0.05);
    --br-sidebar-active: rgba(234, 179, 8, 0.1);
    
    /* Text Colors */
    --br-text-dark: #0f172a;
    --br-text-main: #334155;
    --br-text-muted: #64748b;
    --br-text-sidebar: #94a3b8;
    
    /* System */
    --br-border: #e2e8f0;
    --br-sidebar-width: 260px;
    --br-nav-height: 65px; /* For mobile bottom nav */
}

/* Force Font Awesome to override aggressive theme styles */
i.fa-solid, 
i.fa-brands, 
i.fa-regular {
    font-family: "Font Awesome 6 Free" !important;
    font-style: normal !important;
    font-variant: normal !important;
    text-rendering: auto !important;
    line-height: 1 !important;
}

i.fa-solid {
    font-weight: 900 !important;
}

i.fa-brands {
    font-family: "Font Awesome 6 Brands" !important;
    font-weight: 400 !important;
}

/* ==========================================================================
   2. APP SHELL LOCKDOWN
   ========================================================================== */
.br-app-body {
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden; /* Locks the body, scrolling happens inside main */
    background-color: var(--br-bg-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--br-text-main);
    height: 100vh;
    width: 100vw;
}

.br-app-wrapper {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
    position: relative;
}

/* ==========================================================================
   3. THE SIDEBAR
   ========================================================================== */
.br-app-sidebar {
    width: var(--br-sidebar-width);
    background-color: var(--br-sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 100;
    border-right: 1px solid #1e293b;
    transition: transform 0.3s ease;
}

.br-sidebar-header {
    height: 80px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #f8fafc;
    border-bottom: 1px solid #1e293b;
}

.br-logo-mark {
    background: var(--br-gold);
    color: #000;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "Times New Roman", Times, serif;
    font-size: 18px;
    margin-right: 12px;
}

.br-nav-links {
    list-style: none;
    padding: 20px 12px;
    margin: 0;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.br-nav-links::-webkit-scrollbar {
    width: 4px;
}
.br-nav-links::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}

.nav-item {
    margin-bottom: 4px;
    border-radius: 8px;
    transition: background 0.2s;
}

.br-nav-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: var(--br-text-sidebar);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.br-nav-item i,
.br-nav-item .dashicons {
    margin-right: 12px;
    font-size: 18px;
    width: 20px;
    text-align: center;
    transition: color 0.2s;
}

/* Hover & Active States */
.nav-item:hover .br-nav-item {
    background-color: var(--br-sidebar-hover);
    color: #f8fafc;
}

.nav-item.active .br-nav-item {
    background-color: var(--br-sidebar-active);
    color: var(--br-gold);
    font-weight: 600;
}

.nav-item.active .br-nav-item i,
.nav-item.active .br-nav-item .dashicons {
    color: var(--br-gold);
}

/* ==========================================================================
   4. MAIN CONTENT AREA
   ========================================================================== */
.br-app-main {
    flex-grow: 1;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    background-color: var(--br-bg-main);
    position: relative;
    scroll-behavior: smooth;
}

.br-table td, th {
    border: none !important;
}

#br-app-root {
    padding: 40px;
    max-width: 1400px;
    margin: 0 auto;
    min-height: 100%;
    box-sizing: border-box;
}

/* View Transition Animation */
.br-animate-up {
    animation: brFadeUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes brFadeUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   5. LOADING SPINNER OVERLAY
   ========================================================================== */
#br-app-loader {
    position: absolute;
    inset: 0;
    background: rgba(248, 250, 252, 0.7);
    backdrop-filter: blur(2px);
    z-index: 50;
    display: none; /* Toggled via JS */
    align-items: center;
    justify-content: center;
}

#br-app-loader.active {
    display: flex;
}

.app-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--br-primary);
    border-radius: 50%;
    animation: brAppSpin 0.8s linear infinite;
}

@keyframes brAppSpin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   6. RESPONSIVE DESIGN (Mobile App View)
   ========================================================================== */
@media (max-width: 900px) {
    
    .br-app-wrapper {
        flex-direction: column;
    }

    /* Transform Sidebar to Bottom Navigation */
    .br-app-sidebar {
        order: 2; /* Move to bottom */
        width: 100%;
        height: var(--br-nav-height);
        flex-direction: row;
        border-right: none;
        border-top: 1px solid #1e293b;
        padding-bottom: env(safe-area-inset-bottom); /* iOS support */
    }

    .br-sidebar-header {
        display: none; /* Hide logo on mobile to save space */
    }

    .br-nav-links {
        flex-direction: row;
        padding: 0;
        width: 100%;
        justify-content: space-around;
        align-items: center;
        overflow-y: hidden;
        overflow-x: auto;
    }

    .nav-item {
        margin: 0;
        flex: 1;
        display: flex;
        justify-content: center;
    }

    .br-nav-item {
        flex-direction: column;
        padding: 8px 4px;
        font-size: 10px;
        text-align: center;
        gap: 4px;
        justify-content: center;
    }

    .br-nav-item i,
    .br-nav-item .dashicons {
        margin-right: 0;
    }

    /* Hide text for utility links on mobile to save space */
    .nav-item.logout span,
    .nav-item[data-view="settings"] span {
        display: none;
    }

    /* Main Content Adjustments */
    .br-app-main {
        order: 1; /* Move to top */
        height: calc(100vh - var(--br-nav-height) - env(safe-area-inset-bottom));
    }

    #br-app-root {
        padding: 20px;
    }
}