/*
 * Gnet ISP sidebar styles.
 *
 * Targets the markup produced by resources/views/isp/partials/sidebar.blade.php
 * and the <x-sidebar.*> Blade components. Designed to live inside the existing
 * .sidebar / .sidebar-isp wrapper from public/css/app.css.
 *
 * Important: CSS here must not change menu naming/order/route arrangement.
 * Keep structural menu edits in Blade only when explicitly requested.
 */

:root {
    --isp-sidebar-bg: #0b1730;
    --isp-sidebar-surface: #0e1e3d;
    --isp-sidebar-border: #1c3159;
    --isp-sidebar-border-soft: #233a67;
    --isp-sidebar-text: #dfe9ff;
    --isp-sidebar-text-muted: #9eb0d6;
    --isp-sidebar-text-faint: #7e93c1;
    --isp-sidebar-accent: #4da3ff;
    --isp-sidebar-accent-soft: rgba(77, 163, 255, 0.15);
    --isp-sidebar-accent-strong: #85c2ff;
    --isp-sidebar-hover: #11264a;
    --isp-sidebar-gradient: linear-gradient(135deg, #1f63c4 0%, #0c3f93 100%);
    --isp-sidebar-shadow-sm: 0 1px 2px rgba(3, 8, 21, 0.3);
    --isp-sidebar-shadow-md: 0 8px 20px rgba(3, 8, 21, 0.34);
    --isp-sidebar-radius: 10px;
    --isp-sidebar-radius-sm: 8px;
    --isp-sidebar-ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Root container ===== */
.isp-sidebar {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    background: var(--isp-sidebar-bg);
    color: var(--isp-sidebar-text);
    font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-image: radial-gradient(circle at top left, rgba(77, 163, 255, 0.08), transparent 36%);
}

/* ===== Header / brand ===== */
.isp-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--isp-sidebar-border);
    background: var(--isp-sidebar-bg);
}

.isp-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    flex: 1;
    min-width: 0;
}

.isp-sidebar-brand:hover {
    color: var(--isp-sidebar-accent-strong);
}

.isp-brand-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--isp-sidebar-radius-sm);
    background: var(--isp-sidebar-gradient);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: var(--isp-sidebar-shadow-sm);
}

.isp-sidebar-brand strong {
    display: block;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    color: #f2f6ff;
}

.isp-sidebar-brand small {
    display: block;
    font-size: 10px;
    color: var(--isp-sidebar-text-muted);
    font-weight: 500;
    letter-spacing: 0.02em;
}

.isp-sidebar-collapse {
    background: transparent;
    border: 1px solid var(--isp-sidebar-border);
    color: var(--isp-sidebar-text-muted);
    width: 28px;
    height: 28px;
    border-radius: var(--isp-sidebar-radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s var(--isp-sidebar-ease), color 0.15s var(--isp-sidebar-ease);
    flex-shrink: 0;
}

.isp-sidebar-collapse:hover {
    background: var(--isp-sidebar-hover);
    color: var(--isp-sidebar-accent);
}

/* ===== Profile ===== */
.isp-sidebar-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--isp-sidebar-border);
    background: var(--isp-sidebar-surface);
}

.isp-sidebar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--isp-sidebar-gradient);
    color: #ffffff;
    font-weight: 700;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: var(--isp-sidebar-shadow-sm);
}

.isp-sidebar-profile-text {
    display: block;
    min-width: 0;
    flex: 1;
}

.isp-sidebar-profile-text strong {
    display: block;
    font-size: 12.8px;
    font-weight: 600;
    color: #f1f5ff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.isp-sidebar-profile-text small {
    display: block;
    font-size: 10px;
    color: var(--isp-sidebar-text-muted);
    margin-top: 1px;
}

/* ===== Nav list ===== */
.isp-nav-list {
    list-style: none;
    margin: 0;
    padding: 8px 8px 12px;
    flex: 1;
    overflow-y: auto;
}

.isp-nav-list::-webkit-scrollbar {
    width: 6px;
}
.isp-nav-list::-webkit-scrollbar-track {
    background: transparent;
}
.isp-nav-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}
.isp-nav-list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.isp-nav-item {
    margin: 0;
    list-style: none;
}

/* ===== Section titles ===== */
.isp-sidebar-section-title {
    margin: 8px 0 4px;
    padding: 6px 10px 3px;
    font-size: 9.8px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--isp-sidebar-text-faint);
    list-style: none;
    position: sticky;
    top: 0;
    z-index: 2;
    background: color-mix(in srgb, var(--isp-sidebar-bg) 96%, transparent);
    border-top: 1px solid color-mix(in srgb, var(--isp-sidebar-border) 80%, transparent);
}

.isp-sidebar-section-title:first-child {
    margin-top: 4px;
}

/* ===== Nav links ===== */
.isp-nav-link {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    min-height: 34px;
    padding: 6px 10px;
    border-radius: var(--isp-sidebar-radius-sm);
    color: var(--isp-sidebar-text);
    text-decoration: none;
    font-size: 12.8px;
    font-weight: 600;
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s var(--isp-sidebar-ease), color 0.15s var(--isp-sidebar-ease);
    position: relative;
    font-family: inherit;
    line-height: 1.3;
}

.isp-nav-link:hover,
.isp-nav-link:focus-visible {
    background: var(--isp-sidebar-hover);
    color: var(--isp-sidebar-accent-strong);
    outline: none;
}

.isp-nav-link > span {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.isp-nav-icon-wrap,
.isp-nav-link > i:first-child {
    width: 18px;
    text-align: center;
    color: var(--isp-sidebar-text-muted);
    font-size: 13px;
    flex-shrink: 0;
    transition: color 0.15s var(--isp-sidebar-ease);
    opacity: 0.95;
}

.isp-nav-link:hover .isp-nav-icon-wrap,
.isp-nav-link:hover > i:first-child {
    color: var(--isp-sidebar-accent);
}

/* Active top-level item */
.isp-nav-item.is-active > .isp-nav-link {
    background: var(--isp-sidebar-accent-soft);
    color: var(--isp-sidebar-accent-strong);
    font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(93, 171, 255, 0.24);
}

.isp-nav-item.is-active > .isp-nav-link .isp-nav-icon-wrap,
.isp-nav-item.is-active > .isp-nav-link > i:first-child {
    color: var(--isp-sidebar-accent);
}

.isp-nav-item.is-active > .isp-nav-link::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 5px;
    bottom: 5px;
    width: 3px;
    background: var(--isp-sidebar-accent);
    border-radius: 0 3px 3px 0;
}

/* Placeholder / disabled */
.isp-nav-item.is-placeholder > .isp-nav-link {
    color: var(--isp-sidebar-text-faint);
    cursor: not-allowed;
}

.isp-nav-item.is-placeholder > .isp-nav-link:hover {
    background: transparent;
    color: var(--isp-sidebar-text-faint);
}

.isp-soon-chip {
    margin-left: auto;
    background: #fef3c7;
    color: #92400e;
    font-size: 9.5px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===== Dropdown trigger + chevron ===== */
.isp-nav-dropdown-trigger {
    width: 100%;
}

.isp-chevron {
    margin-left: auto;
    font-size: 11px;
    color: var(--isp-sidebar-text-faint);
    transition: transform 0.2s var(--isp-sidebar-ease), color 0.15s var(--isp-sidebar-ease);
    flex-shrink: 0;
}

.isp-nav-dropdown.is-open > .isp-nav-dropdown-trigger .isp-chevron {
    transform: rotate(180deg);
    color: var(--isp-sidebar-accent);
}

.isp-nav-dropdown.is-route-active > .isp-nav-dropdown-trigger {
    color: var(--isp-sidebar-accent-strong);
}

.isp-nav-dropdown.is-route-active > .isp-nav-dropdown-trigger .isp-nav-icon-wrap {
    color: var(--isp-sidebar-accent);
}

.isp-nav-dropdown.is-open > .isp-nav-dropdown-trigger {
    background: #f8fbff;
}

/* ===== Submenu ===== */
.isp-submenu {
    list-style: none;
    margin: 2px 0 4px;
    padding: 2px 0 4px 16px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.25s var(--isp-sidebar-ease),
                opacity 0.18s var(--isp-sidebar-ease),
                padding 0.2s var(--isp-sidebar-ease);
    border-left: 1px solid var(--isp-sidebar-border-soft);
    margin-left: 12px;
}

.isp-nav-dropdown.is-open > .isp-submenu {
    /* Large value is fine: we animate to natural height via max-height fallback.
       Browsers without subgrid still animate smoothly between 0 and 800px. */
    max-height: 800px;
    opacity: 1;
    padding-top: 2px;
    padding-bottom: 4px;
}

.isp-submenu-item {
    list-style: none;
    margin: 0;
}

.isp-submenu-link {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 30px;
    padding: 5px 9px;
    margin-right: 2px;
    border-radius: var(--isp-sidebar-radius-sm);
    color: var(--isp-sidebar-text-muted);
    text-decoration: none;
    font-size: 12.1px;
    font-weight: 500;
    transition: background 0.15s var(--isp-sidebar-ease), color 0.15s var(--isp-sidebar-ease);
    position: relative;
}

.isp-submenu-link::before {
    content: '';
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--isp-sidebar-text-faint) 90%, transparent);
    flex-shrink: 0;
}

.isp-submenu-link i {
    width: 14px;
    text-align: center;
    font-size: 11px;
    color: var(--isp-sidebar-text-faint);
}

.isp-submenu-link > span {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.isp-submenu-link:hover,
.isp-submenu-link:focus-visible {
    background: var(--isp-sidebar-hover);
    color: var(--isp-sidebar-accent-strong);
    outline: none;
}

.isp-submenu-link:hover i {
    color: var(--isp-sidebar-accent);
}

.isp-submenu-link:hover::before,
.isp-submenu-item.is-active > .isp-submenu-link::before {
    background: var(--isp-sidebar-accent);
}

.isp-submenu-item.is-active > .isp-submenu-link {
    background: var(--isp-sidebar-accent-soft);
    color: var(--isp-sidebar-accent-strong);
    font-weight: 600;
}

.isp-submenu-item.is-active > .isp-submenu-link i {
    color: var(--isp-sidebar-accent);
}

.isp-submenu-item.is-placeholder > .isp-submenu-link {
    color: var(--isp-sidebar-text-faint);
    cursor: not-allowed;
}

/* ===== Footer ===== */
.isp-sidebar-footer {
    border-top: 1px solid var(--isp-sidebar-border);
    padding: 8px 12px;
    background: var(--isp-sidebar-surface);
}

.isp-sidebar-footer p {
    margin: 0;
    font-size: 10px;
    color: var(--isp-sidebar-text-muted);
    line-height: 1.4;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* ===== Responsive (mobile drawer style) ===== */
@media (max-width: 768px) {
    .isp-sidebar-header {
        padding: 10px 12px;
    }

    .isp-nav-list {
        padding: 6px 6px 10px;
    }

    .isp-nav-link {
        min-height: 36px;
        padding: 7px 10px;
        font-size: 13px;
    }

    .isp-submenu {
        padding-left: 14px;
        margin-left: 10px;
    }

    .isp-submenu-link {
        min-height: 32px;
        padding: 6px 10px;
        font-size: 12.4px;
    }
}

html[data-theme='dark'] .isp-sidebar {
    background: var(--isp-sidebar-bg);
    color: var(--gnet-text, #e5eef7);
}

html[data-theme='dark'] .isp-sidebar-header,
html[data-theme='dark'] .isp-sidebar-profile,
html[data-theme='dark'] .isp-sidebar-footer {
    background: color-mix(in srgb, var(--gnet-bg-elevated, #121d32) 92%, transparent);
    border-color: var(--gnet-border, #22314b);
}

html[data-theme='dark'] .isp-sidebar-brand strong,
html[data-theme='dark'] .isp-sidebar-profile-text strong {
    color: var(--gnet-text, #e5eef7);
}

html[data-theme='dark'] .isp-nav-link,
html[data-theme='dark'] .isp-submenu-link {
    color: var(--gnet-text, #e5eef7);
}

html[data-theme='dark'] .isp-nav-link:hover,
html[data-theme='dark'] .isp-nav-link:focus-visible,
html[data-theme='dark'] .isp-submenu-link:hover,
html[data-theme='dark'] .isp-submenu-link:focus-visible,
html[data-theme='dark'] .isp-nav-dropdown.is-open > .isp-nav-dropdown-trigger {
    background: var(--gnet-brand-soft, rgba(83, 197, 245, 0.14));
}

html[data-theme='dark'] .isp-submenu,
html[data-theme='dark'] .isp-nav-list::-webkit-scrollbar-thumb {
    border-color: var(--gnet-border, #22314b);
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 72px;
        left: 0;
        height: calc(100vh - 72px);
        width: min(280px, 84vw);
        max-width: 280px;
        transform: translateX(-102%);
        transition: transform 0.24s ease, box-shadow 0.24s ease, opacity 0.24s ease;
        z-index: 1250;
        box-shadow: 18px 0 40px rgba(11, 35, 55, 0.2);
        opacity: 0;
        pointer-events: none;
        will-change: transform;
    }

    .sidebar:not(.collapsed),
    body.sidebar-open .sidebar {
        transform: translateX(0);
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar.collapsed {
        width: min(280px, 84vw);
    }

    .sidebar-overlay {
        display: block;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.2s ease, visibility 0.2s ease;
    }

    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }
}
