/**
 * LAYOUT MASTER CSS
 * Contains all shared layout styles used across the entire application
 * Imported once in _Layout.cshtml head
 * 
 * Structure:
 * - Topbar (navigation header)
 * - Sidebar (main navigation menu)
 * - Overlay (mobile menu backdrop)
 * - Menu & Submenu components
 * 
 * Design Approach:
 * - Mobile-first responsive design
 * - CSS transitions for smooth UX
 * - Reusable utility classes
 * - No page-specific styles (those go in pages/*.css)
 */

/* ======================================
   TOPBAR / HEADER
   ====================================== */

.topbar {
    position: fixed;
    inset: 0 0 auto 0;
    height: 65px;
    background: linear-gradient(356deg, rgba(34, 34, 71, 1) 21%, rgba(148, 187, 233, 1) 60%);
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    z-index: 1100;
}

.topbar .menu-toggle {
    font-size: 24px;
    background: none;
    border: 0;
    color: #fff;
    cursor: pointer;
    padding: 8px;
    display: none;
    transition: opacity 0.2s ease;
}

    .topbar .menu-toggle:hover {
        opacity: 0.8;
    }

    .topbar .menu-toggle:active {
        opacity: 0.6;
    }

@media (max-width: 768px) {
    .topbar .menu-toggle {
        display: inline-block;
    }
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-form {
    display: inline;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #fff;
    font-size: 18px;
    font-weight: 600;
}

.logo-container {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .logo-container img {
        max-width: 100%;
        height: auto;
    }


/* ======================================
   SIDEBAR / MAIN NAVIGATION
   ====================================== */

.sidebar {
    width: 55px;
    background: linear-gradient(16deg, rgb(34, 50, 71) 21%, rgb(148, 187, 233) 109%);
    position: fixed;
    left: 0;
    top: 65px;
    height: calc(100vh - 65px);
    overflow: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    color: #cbd5e1;
    transition: width 0.25s ease, transform 0.3s ease;
    z-index: 1000;
}

/* Sidebar expand on hover (desktop only) */
@media (min-width: 769px) {
    .sidebar {
        width: 55px;
    }

    .sidebar:hover {
        width: 240px;
    }
}

/* Sidebar mobile state */
@media (max-width: 768px) {
    .sidebar {
        width: 240px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }
}


/* ======================================
   SIDEBAR MENU
   ====================================== */

.sidebar-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    flex-grow: 1;
}

.sidebar-menu li {
    position: relative;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    color: #cbd5e1;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.2s ease, color 0.2s ease;
    cursor: pointer;
}

    .sidebar-menu a:hover {
        background: rgba(255, 255, 255, 0.1);
        color: #fff;
    }

    .sidebar-menu a:active {
        background: rgba(255, 255, 255, 0.15);
    }

.sidebar-menu .icon {
    font-size: 18px;
    min-width: 22px;
    text-align: center;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-menu .text {
    opacity: 0;
    transition: opacity 0.2s ease;
    flex: 1;
    text-overflow: ellipsis;
    overflow: hidden;
}

/* Show text on desktop hover */
@media (min-width: 769px) {
    .sidebar:hover .text {
        opacity: 1;
    }
}

/* Show text on mobile always */
@media (max-width: 768px) {
    .sidebar-menu .text {
        opacity: 1;
    }
}

/* Active link styling */
.sidebar-menu a.active {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-weight: 600;
}


/* ======================================
   SUBMENU
   ====================================== */

.has-submenu .submenu {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-8px);
    padding-left: 12px;
    transition: max-height 0.45s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.35s ease,
                transform 0.35s ease;
}

.has-submenu.open .submenu {
    max-height: 500px;
    opacity: 1;
    transform: translateY(0);
}

/* Submenu arrow rotation */
.has-submenu .arrow {
    margin-left: auto;
    font-size: 14px;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.has-submenu.open .arrow {
    transform: rotate(90deg);
}

/* Submenu links styling */
.submenu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.submenu li {
    position: relative;
}

.submenu li a {
    font-size: 14px;
    padding: 8px 16px 8px 42px;
    color: #e2e8f0;
    transition: background 0.2s ease, padding-left 0.2s ease;
}

    .submenu li a:hover {
        background: rgba(255, 255, 255, 0.15);
        padding-left: 46px;
    }

    .submenu li a:active {
        background: rgba(255, 255, 255, 0.2);
    }

.submenu a.active {
    background: rgba(255, 255, 255, 0.25);
    font-weight: 600;
}

.has-submenu.open > a {
    background: rgba(255, 255, 255, 0.15);
}


/* ======================================
   MAIN CONTENT AREA
   ====================================== */

.main {
    margin-top: 65px;
    margin-left: 64px;
    padding: 20px;
    transition: margin-left 0.25s ease;
    min-height: calc(100vh - 65px);
}

/* Adjust main content when sidebar hovers on desktop */
@media (min-width: 769px) {
    .sidebar:hover ~ .main {
        margin-left: 240px;
    }
}

/* Mobile main content layout */
@media (max-width: 768px) {
    .main {
        margin-left: 0;
    }
}


/* ======================================
   OVERLAY (MOBILE MENU BACKDROP)
   ====================================== */

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 999;
    display: none;
}

@media (max-width: 768px) {
    .overlay {
        display: block;
    }

    .overlay.open {
        opacity: 1;
        visibility: visible;
    }
}
