/* LEAF — Material Design-inspired layout (MudBlazor) */

:root {
    --leaf-primary: #1976d2;
    --leaf-primary-dark: #1565c0;
    --leaf-sidebar-bg: #263238;
    --leaf-sidebar-text: #cfd8dc;
    --leaf-sidebar-hover: #37474f;
    --leaf-sidebar-active: #1976d2;
    --leaf-sidebar-width: 220px;
    --leaf-appbar-height: 56px;
}

html {
    font-size: 14px;
}

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

body {
    font-family: 'Roboto', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    margin: 0;
    background: #fafafa;
    color: rgba(0, 0, 0, 0.87);
}

/* ===== Sidebar ===== */
.leaf-sidebar {
    width: var(--leaf-sidebar-width);
    min-width: var(--leaf-sidebar-width);
    max-width: var(--leaf-sidebar-width);
    min-height: calc(100vh - 32px);
    background: var(--leaf-sidebar-bg);
    transition: margin-left 0.25s ease-out;
    overflow-y: auto;
}

.sidebar-heading {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: 2px;
}

.sidebar-brand:hover {
    color: #90caf9;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 8px 0;
}

.sidebar-link {
    display: block;
    padding: 10px 20px;
    color: var(--leaf-sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 400;
    transition: background 0.15s ease;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background: var(--leaf-sidebar-hover);
    color: #fff;
    border-left-color: var(--leaf-sidebar-active);
}

.sidebar-link-disabled {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

/* Collapsible sidebar sections */
details.sidebar-section {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: 4px;
}

details.sidebar-section > summary.sidebar-section-label {
    padding: 12px 20px 8px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(207, 216, 220, 0.6);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    transition: color 0.15s ease;
}

details.sidebar-section > summary.sidebar-section-label:hover {
    color: rgba(207, 216, 220, 0.9);
}

details.sidebar-section > summary.sidebar-section-label::-webkit-details-marker {
    display: none;
}

details.sidebar-section > summary.sidebar-section-label::after {
    content: '\25B8'; /* right triangle */
    font-size: 0.7rem;
    transition: transform 0.2s ease;
    margin-right: 4px;
    opacity: 0.7;
}

details.sidebar-section[open] > summary.sidebar-section-label::after {
    transform: rotate(90deg);
}

details.sidebar-section[open] > summary.sidebar-section-label {
    color: rgba(207, 216, 220, 0.9);
}

details.sidebar-section .sidebar-link {
    padding-left: 32px;
    font-size: 0.825rem;
}

/* Collapsed sidebar */
#wrapper {
    flex: 1;
    display: flex;
}

#wrapper.toggled .leaf-sidebar {
    margin-left: calc(-1 * var(--leaf-sidebar-width));
}

/* Mobile: sidebar starts collapsed, overlay when open */
@media (max-width: 768px) {
    .leaf-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1000;
        height: 100vh;
        margin-left: calc(-1 * var(--leaf-sidebar-width));
        transition: margin-left 0.25s ease;
    }

    #wrapper.sidebar-open .leaf-sidebar {
        margin-left: 0;
    }

    #wrapper.toggled .leaf-sidebar {
        margin-left: calc(-1 * var(--leaf-sidebar-width));
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 999;
    }

    #wrapper.sidebar-open .sidebar-overlay {
        display: block;
    }
}

/* ===== App Bar ===== */
.leaf-appbar {
    display: flex;
    align-items: center;
    height: var(--leaf-appbar-height);
    padding: 0 16px;
    background: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    gap: 16px;
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    color: rgba(0, 0, 0, 0.54);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle-btn:hover {
    background: rgba(0, 0, 0, 0.04);
}

.appbar-info {
    font-size: 0.8rem;
    color: rgba(0, 0, 0, 0.54);
}

.appbar-actions {
    margin-left: auto;
}

/* ===== User menu (appbar dropdown) ===== */
.user-menu {
    position: relative;
}

.user-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    background: none;
    border: 1px solid transparent;
    border-radius: 999px;
    cursor: pointer;
    font-family: inherit;
    color: rgba(0, 0, 0, 0.87);
    transition: background 0.15s ease, border-color 0.15s ease;
}

.user-menu-btn:hover {
    background: rgba(0, 0, 0, 0.04);
}

.user-menu.open .user-menu-btn {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.12);
}

.user-menu-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--leaf-primary);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.user-menu-name {
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
}

.user-menu-caret {
    color: rgba(0, 0, 0, 0.54);
    transition: transform 0.15s ease;
}

.user-menu.open .user-menu-caret {
    transform: rotate(180deg);
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 210px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    z-index: 1100;
}

.user-menu.open .user-menu-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    font-size: 0.875rem;
    color: rgba(0, 0, 0, 0.87);
    text-decoration: none;
    border-radius: 6px;
    transition: background 0.12s ease;
}

.user-menu-item:hover {
    background: rgba(0, 0, 0, 0.04);
}

.user-menu-item svg {
    color: rgba(0, 0, 0, 0.54);
    flex-shrink: 0;
}

.user-menu-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.08);
    margin: 6px 4px;
}

@media (max-width: 600px) {
    .user-menu-name {
        display: none;
    }
}

/* ===== Content area ===== */
#page-content-wrapper {
    min-width: 0;           /* allow flex child to shrink below content size */
    overflow: hidden;       /* prevent wide tables from blowing out the layout */
}

.leaf-content {
    padding: 24px;
    flex: 1;
    overflow-x: auto;       /* scroll horizontally if content is wider than viewport */
}

/* ===== Login (unauthenticated) ===== */
.leaf-login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 24px;
    background: linear-gradient(135deg, #263238 0%, #37474f 50%, #455a64 100%);
}

/* Login Card */
.leaf-login-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.24);
    padding: 48px 40px 32px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

/* Logo + Branding */
.leaf-login-logo {
    margin-bottom: 32px;
}

.leaf-login-icon {
    width: 56px;
    height: 56px;
    margin-bottom: 12px;
}

.leaf-login-title {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 4px;
    color: rgba(0, 0, 0, 0.87);
    margin: 0 0 4px;
}

.leaf-login-tagline {
    font-size: 0.9rem;
    color: rgba(0, 0, 0, 0.54);
    margin: 0;
}

/* Error Message */
.leaf-login-error {
    background: #fce4ec;
    color: #c62828;
    border: 1px solid #ef9a9a;
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 0.85rem;
    margin-bottom: 20px;
}

/* Buttons */
.leaf-login-btn {
    display: block;
    width: 100%;
    padding: 12px 24px;
    font-size: 0.9375rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 6px;
    text-decoration: none;
    text-align: center;
    transition: background 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    border: none;
}

.leaf-login-btn-primary {
    background: var(--leaf-primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.3);
}

.leaf-login-btn-primary:hover {
    background: var(--leaf-primary-dark);
    color: #fff;
    box-shadow: 0 4px 12px rgba(25, 118, 210, 0.4);
    text-decoration: none;
}

.leaf-login-btn-secondary {
    background: transparent;
    color: var(--leaf-primary);
    border: 1px solid var(--leaf-primary);
    margin-top: 10px;
}

.leaf-login-btn-secondary:hover {
    background: rgba(67, 160, 71, 0.08);
    color: var(--leaf-primary-dark);
    text-decoration: none;
}

.leaf-login-btn-dev {
    background: transparent;
    color: rgba(0, 0, 0, 0.54);
    border: 1px solid rgba(0, 0, 0, 0.23);
    margin-top: 10px;
    font-size: 0.8125rem;
}

.leaf-login-btn-dev:hover {
    background: rgba(0, 0, 0, 0.04);
    color: rgba(0, 0, 0, 0.87);
    text-decoration: none;
}

/* Hint Text */
.leaf-login-hint {
    font-size: 0.8rem;
    color: rgba(0, 0, 0, 0.45);
    margin: 16px 0 0;
}

/* Footer inside card */
.leaf-login-footer {
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    font-size: 0.75rem;
    color: rgba(0, 0, 0, 0.38);
}

/* Responsive */
@media (max-width: 480px) {
    .leaf-login-card {
        padding: 36px 24px 24px;
        border-radius: 8px;
    }

    .leaf-login-container {
        padding: 16px;
    }
}

/* ===== Footer ===== */
.leaf-footer {
    text-align: center;
    padding: 8px 0;
    font-size: 0.75rem;
    color: rgba(0, 0, 0, 0.38);
    border-top: 1px solid rgba(0, 0, 0, 0.12);
    margin-top: auto;
}

/* ===== Licensee Switcher ===== */
.licensee-switcher-form {
    display: inline;
}

.licensee-switcher {
    appearance: auto;
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.23);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.8rem;
    font-family: 'Roboto', sans-serif;
    color: rgba(0, 0, 0, 0.54);
    cursor: pointer;
    max-width: 220px;
}

.licensee-switcher:hover {
    border-color: rgba(0, 0, 0, 0.54);
}

.licensee-switcher:focus {
    border-color: var(--leaf-primary);
    outline: none;
    box-shadow: 0 0 0 1px var(--leaf-primary);
}

/* ===== Focus ===== */
.btn:focus, .btn:active:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

/* ===== Data Grid — always-visible sort arrows ===== */
/* MudBlazor hides sort icons until hover; show them at low opacity so users know columns are sortable */
.mud-data-grid .mud-table-cell .column-header .sort-direction-icon {
    opacity: 0.25 !important;
}
/* Active sort (asc/desc) stays fully visible */
.mud-data-grid .mud-table-cell .column-header .sort-direction-icon.mud-direction-asc,
.mud-data-grid .mud-table-cell .column-header .sort-direction-icon.mud-direction-desc {
    opacity: 1 !important;
}
