/* ---------- THEME VARIABLES ---------- */

:root {
    --ap-bg: #f8fafc;
    --ap-surface: #ffffff;
    --ap-surface-soft: #f8fafc;
    --ap-border-soft: rgba(148, 163, 184, 0.25);
    --ap-border-strong: rgba(148, 163, 184, 0.45);
    --ap-text: #0f172a;
    --ap-text-muted: #64748b;
    --ap-sidebar-bg: #ffffff;
    --ap-main-bg: #f8fafc;
    --ap-sidebar-border: rgba(226, 232, 240, 0.8);
}

.theme-dark {
    --ap-bg: #0b1120;
    --ap-surface: #1a2332;
    --ap-surface-soft: #0f1824;
    --ap-border-soft: rgba(42, 58, 79, 0.8);
    --ap-border-strong: rgba(59, 130, 246, 0.3);
    --ap-text: #f1f5f9;
    --ap-text-muted: #94a3b8;
    --ap-sidebar-bg: #1a2332;
    --ap-main-bg: #0b1120;
    --ap-sidebar-border: rgba(42, 58, 79, 0.8);
}

/* Accent gradient - Modern blue gradient */
:root {
    --ap-accent-gradient: linear-gradient(135deg, #3b82f6, #2563eb);
}

.theme-dark {
    --ap-accent-gradient: linear-gradient(135deg, #60a5fa, #3b82f6);
}

/* Reset Blazor default layout that centers content with max-width */
.page {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Make sure the whole app can use full width/height */
html,
body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background-color: var(--ap-main-bg);
}

body {
    overflow-x: hidden;
    font-size: 1rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- USER-FRIENDLY TYPOGRAPHY ---------- */

h1, .h1 { font-size: 1.75rem; font-weight: 700; line-height: 1.3; margin-bottom: 0.5rem; }
h2, .h2 { font-size: 1.375rem; font-weight: 600; line-height: 1.35; margin-bottom: 0.5rem; }
h3, .h3 { font-size: 1.125rem; font-weight: 600; line-height: 1.4; margin-bottom: 0.5rem; }
h4, .h4 { font-size: 1rem; font-weight: 600; line-height: 1.45; margin-bottom: 0.375rem; }

p, li, td, th, label, .form-label {
    font-size: 0.9375rem;
    line-height: 1.6;
}

small, .small, .text-muted, .form-text {
    font-size: 0.8125rem;
    line-height: 1.5;
}

.btn, button {
    font-size: 0.9375rem;
}

.form-control, .form-select, input, textarea, select {
    font-size: 0.9375rem;
}

/* Mobile-first: slightly larger touch-friendly text on small screens */
@media (max-width: 575.98px) {
    body { font-size: 1rem; }
    h1, .h1 { font-size: 1.5rem; }
    h2, .h2 { font-size: 1.25rem; }
    h3, .h3 { font-size: 1.0625rem; }
    p, li, td, th, label, .form-label { font-size: 0.9375rem; }
    .btn, button { font-size: 0.9375rem; padding: 0.5rem 1rem; }
    .form-control, .form-select, input, textarea, select { font-size: 1rem; /* prevent iOS zoom on focus */ }
}

/* ---------- LAYOUT SHELL ---------- */

.ap-shell {
    min-height: 100vh;
    width: 100%;
    display: flex;
    background-color: var(--ap-main-bg);
    color: var(--ap-text);
    overflow-x: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Roboto, Helvetica, Arial, sans-serif;
}

/* Sidebar */
.ap-sidebar {
    width: 80px;
    background-color: var(--ap-sidebar-bg);
    border-right: 1px solid var(--ap-sidebar-border);
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    z-index: 101;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                background-color 0.25s ease, 
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm, 0 1px 3px 0 rgba(0, 0, 0, 0.1));
}

.ap-sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ap-shell.sidebar-open .ap-sidebar-backdrop {
    opacity: 1;
}

/* Main area */
.ap-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ap-main-body {
    padding: 1.5rem;
    background-color: var(--ap-main-bg);
    min-height: calc(100vh - 68px);
}

/* Responsive padding */
@media (min-width: 768px) {
    .ap-main-body {
        padding: 2rem;
    }
}

@media (min-width: 1024px) {
    .ap-main-body {
        padding: 2rem 2.5rem;
    }
}

/* ---------- NAV MENU ---------- */

.ap-nav {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.ap-nav-top {
    padding-inline: 0.5rem;
}

.ap-nav-bottom {
    padding-inline: 0.5rem;
}

.ap-nav-list {
    list-style: none;
    margin: 0;
    padding: 0 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

/* Shared nav item styles */
.ap-nav-item,
.ap-nav-subitem {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg, 0.875rem);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--ap-text-muted);
    text-decoration: none;
    border: none;
    background: transparent;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.ap-nav-item:hover,
.ap-nav-subitem:hover {
    background: var(--ap-nav-item-hover-bg, rgba(59, 130, 246, 0.1));
    color: var(--ap-text);
    transform: translateX(2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
}

.theme-dark .ap-nav-item:hover,
.theme-dark .ap-nav-subitem:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Active link with modern gradient */
.ap-nav-item.active {
    background: var(--ap-accent-gradient);
    color: #ffffff;
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4), 0 2px 8px rgba(59, 130, 246, 0.2);
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.ap-nav-item.active .ap-nav-icon {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transform: scale(1.05);
}

.ap-nav-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: var(--radius-md, 0.625rem);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(99, 102, 241, 0.15));
    font-size: 1.125rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #60a5fa;
}

.theme-dark .ap-nav-icon {
    color: #93c5fd;
}

.ap-nav-item:hover .ap-nav-icon {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(99, 102, 241, 0.25));
    color: #3b82f6;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.theme-dark .ap-nav-item:hover .ap-nav-icon {
    color: #60a5fa;
}

/* Icon-specific colors for visual distinction */
.ap-nav-item:nth-child(1) .ap-nav-icon { color: #60a5fa; background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(147, 197, 253, 0.15)); }\n.ap-nav-item:nth-child(2) .ap-nav-icon { color: #a78bfa; background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(167, 139, 250, 0.15)); }\n.ap-nav-item:nth-child(3) .ap-nav-icon { color: #34d399; background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(52, 211, 153, 0.15)); }\n.ap-nav-item:nth-child(4) .ap-nav-icon { color: #fbbf24; background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(251, 191, 36, 0.15)); }\n.ap-nav-item:nth-child(5) .ap-nav-icon { color: #f472b6; background: linear-gradient(135deg, rgba(236, 72, 153, 0.15), rgba(244, 114, 182, 0.15)); }\n.ap-nav-item:nth-child(6) .ap-nav-icon { color: #fb923c; background: linear-gradient(135deg, rgba(249, 115, 22, 0.15), rgba(251, 146, 60, 0.15)); }\n.ap-nav-item:nth-child(7) .ap-nav-icon { color: #38bdf8; background: linear-gradient(135deg, rgba(14, 165, 233, 0.15), rgba(56, 189, 248, 0.15)); }\n.ap-nav-item:nth-child(8) .ap-nav-icon { color: #a3e635; background: linear-gradient(135deg, rgba(132, 204, 22, 0.15), rgba(163, 230, 53, 0.15)); }\n.ap-nav-item:nth-child(9) .ap-nav-icon { color: #f87171; background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(248, 113, 113, 0.15)); }\n.ap-nav-item:nth-child(10) .ap-nav-icon { color: #c084fc; background: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(192, 132, 252, 0.15)); }\n\n/* Hover state for specific icons */\n.ap-nav-item:nth-child(1):hover .ap-nav-icon { color: #3b82f6; box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4); }\n.ap-nav-item:nth-child(2):hover .ap-nav-icon { color: #8b5cf6; box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4); }\n.ap-nav-item:nth-child(3):hover .ap-nav-icon { color: #10b981; box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4); }\n.ap-nav-item:nth-child(4):hover .ap-nav-icon { color: #f59e0b; box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4); }\n.ap-nav-item:nth-child(5):hover .ap-nav-icon { color: #ec4899; box-shadow: 0 4px 12px rgba(236, 72, 153, 0.4); }\n.ap-nav-item:nth-child(6):hover .ap-nav-icon { color: #f97316; box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4); }\n.ap-nav-item:nth-child(7):hover .ap-nav-icon { color: #0ea5e9; box-shadow: 0 4px 12px rgba(14, 165, 233, 0.4); }\n.ap-nav-item:nth-child(8):hover .ap-nav-icon { color: #84cc16; box-shadow: 0 4px 12px rgba(132, 204, 22, 0.4); }\n.ap-nav-item:nth-child(9):hover .ap-nav-icon { color: #ef4444; box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4); }\n.ap-nav-item:nth-child(10):hover .ap-nav-icon { color: #a855f7; box-shadow: 0 4px 12px rgba(168, 85, 247, 0.4); }


/* Expanded sidebar (desktop) */
@media (min-width: 992px) {
    .ap-shell.sidebar-open .ap-sidebar {
        width: 240px;
    }
}

/* Mobile off-canvas with improved animation */
@media (max-width: 991.98px) {
    .ap-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        width: 280px;
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
    }

    .ap-shell.sidebar-open .ap-sidebar {
        transform: translateX(0);
    }

    .ap-sidebar-backdrop {
        display: block;
    }

    .ap-main-body {
        padding: 1.25rem;
    }
}
}


/* Only show labels when expanded (desktop) */
@media (min-width: 992px) {
    .ap-shell.sidebar-closed .ap-nav-label {
        display: none;
    }

    .ap-shell.sidebar-closed .ap-nav-item {
        justify-content: center;
        padding-inline: 0.45rem;
    }
}

/* Avatar item at very top */
.ap-nav-avatar {
    position: relative;
    justify-content: flex-start;
}

.ap-status-dot {
    position: absolute;
    bottom: 6px;
    left: 12px;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background-color: #22c55e;
    border: 2px solid var(--ap-sidebar-bg);
}

/* Dropdown group */
.ap-nav-group .ap-nav-dropdown-toggle {
    padding-right: 0.9rem;
}

.ap-nav-group-open .ap-nav-dropdown-toggle {
    background: rgba(148, 163, 184, 0.15);
}

.ap-nav-submenu {
    list-style: none;
    margin: 0.2rem 0 0.3rem 2.5rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
}

.ap-nav-subitem {
    border-radius: 999px;
    font-size: 0.8rem;
    padding-inline: 0.6rem 0.8rem;
    color: var(--ap-text-muted);
}

/* ---------- TOP BAR ---------- */

.ap-topbar {
    height: 72px;
    background-color: var(--ap-surface);
    border-bottom: 1px solid var(--ap-border-soft);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 50;
}

.ap-title-icon {
    width: 40px;
    height: 40px;
    border-radius: 18px;
    background: var(--ap-accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 1.25rem;
}

.ap-title-text {
    display: flex;
    flex-direction: column;
}

.ap-page-title {
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.1;
}

.ap-page-subtitle {
    font-size: 0.75rem;
    color: var(--ap-text-muted);
}

/* Search box */
.ap-search-box {
    width: 100%;
    max-width: 420px;
    border-radius: 999px;
    padding: 0.25rem 0.5rem; /* reduced internal padding so icon and input sit neatly */
    background-color: transparent !important; /* <== FIXED */
    border: 1px solid var(--ap-border-soft);
    display: flex;
    align-items: center;
    gap: 0.5rem; /* space between icon and input */
}

/* Icon inside the search box - make it visually part of the pill */
.ap-search-box .ap-icon-button,
.ap-search-box i {
    background: transparent !important;
    border: none !important;
    color: var(--ap-text-muted) !important;
    width: 36px;
    height: 36px;
    min-width: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    box-shadow: none !important;
}

/* Hover state still gives subtle highlight but keeps inside the pill */
.ap-search-box .ap-icon-button:hover {
    background-color: rgba(148, 163, 184, 0.08);
    color: var(--ap-text) !important;
}

.ap-search-input {
    background: transparent !important;
    color: var(--ap-text) !important;
    font-size: 0.9rem;
    border: none !important; /* remove inner border */
    padding: 0.45rem 0.5rem; /* vertical alignment with icon */
    outline: none;
    width: 100%;
}

/* Placeholder color */
.ap-search-input::placeholder {
    color: var(--ap-text-muted) !important;
    opacity: 1;
}

/* Remove autofill background issues */
.ap-search-input:-webkit-autofill,
.ap-search-input:-webkit-autofill:hover,
.ap-search-input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 30px transparent inset !important;
    -webkit-text-fill-color: var(--ap-text) !important;
    background: transparent !important;
}

/* In dark theme slightly tint the search box to match surface */
.theme-dark .ap-search-box {
    background-color: rgba(255,255,255,0.02) !important;
    border: 1px solid rgba(255,255,255,0.04);
}

/* Icon buttons & user pill */
.ap-icon-button {
    border: none;
    background: transparent;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--ap-text-muted);
    transition: background-color 0.18s ease, color 0.18s ease;
}

.theme-light .ap-icon-button:hover {
    background-color: rgba(148, 163, 184, 0.18);
    color: var(--ap-text);
}

.theme-dark .ap-icon-button:hover {
    background-color: rgba(15, 23, 42, 0.85);
    color: #e5e7eb;
}

.ap-dot-badge {
    position: absolute;
    top: 5px;
    right: 4px;
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background-color: #ef4444;
}

/* User pill */
.ap-user-pill {
    border: none;
    background: var(--ap-accent-gradient);
    color: #ffffff;
    border-radius: 999px;
    padding: 0.2rem 0.75rem;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.ap-user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background-color: rgba(15, 23, 42, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.ap-search-input:-webkit-autofill,
.ap-search-input:-webkit-autofill:hover,
.ap-search-input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 30px transparent inset !important;
    -webkit-text-fill-color: var(--ap-text) !important;
    background: transparent !important;
}

.ap-user-name {
    white-space: nowrap;
}

/* Dropdown menu skin */
.ap-dropdown-menu {
    font-size: 0.85rem;
}

/* Mobile tweaks */
@media (max-width: 575.98px) {
    .ap-main-body {
        padding-inline: 1rem;
    }

    .ap-page-title {
        font-size: 0.95rem;
    }
}

/* Search box (Bootstrap input-group variant in topbar) - container holds the border and radius */
.ap-topbar .input-group {
    border: 1px solid var(--ap-border-soft);
    border-radius: 10px;
    overflow: hidden; /* keep inner elements clipped to rounded corners */
    background-color: transparent;
    display: inline-flex;
    align-items: center;
    gap: 0;
    height: 40px; /* match visual size */
}

/* Make the input-group-text (icon container) visually part of the pill */
.ap-topbar .input-group .input-group-text {
    background: transparent !important;
    border: 0 !important;
    padding: 0 10px;
    color: var(--ap-text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

/* Remove border from the input and let the parent container provide it */
.ap-topbar .input-group .form-control,
.ap-topbar .input-group .form-control:focus {
    border: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    background: transparent !important;
    min-height: 100vh;
    padding: 0 12px;
}

/* Remove the Bootstrap utility border overrides that may reintroduce edges */
.ap-topbar .input-group .border-start-0,
.ap-topbar .input-group .border-end-0 {
    border: 0 !important;
}

/* Slight hover focus visual for the whole pill */
.ap-topbar .input-group:hover {
    border-color: rgba(148, 163, 184, 0.6);
}

/* Dark theme variant: soften border and ensure icon color */
.theme-dark .ap-topbar .input-group {
    border: 1px solid rgba(255,255,255,0.04);
}

.theme-dark .ap-topbar .input-group .input-group-text,
.theme-dark .ap-topbar .input-group .form-control {
    color: var(--ap-text-muted);
}

/* Ensure small screens scale nicely */
@media (max-width: 575.98px) {
    .ap-topbar .input-group { height: 36px; }
}
