/* ==========================================================================
   2026-01-23 [Sprint 10] Wynlo Sidebar CSS
   --------------------------------------------------------------------------
   Goal:
   - ChatGPT-like thin rail sidebar + clean tooltips
   - Keep tooltip visible outside sidebar rail
   - Keep sidebar styling token-driven for light/dark themes
   ========================================================================== */

/* =========================
   0) Sidebar variables
   --------------------------------------------------------------------------
   Sidebar-specific aliases.
   Global theme tokens should remain in foundation.css.
   ========================= */
:root {
    --wynlo-brand: var(--brand);
    --wynlo-muted: var(--muted);
    --wynlo-muted-strong: var(--text-sub);
    --wynlo-sep: var(--border);

    --wynlo-tooltip-bg: rgba(17, 24, 39, 0.92);
    --wynlo-tooltip-text: #ffffff;

    --sidebar-brand-hover-bg: var(--surface-2);

    --sidebar-icon-filter: invert(27%) sepia(6%) saturate(350%) hue-rotate(180deg) brightness(92%) contrast(90%);
    --sidebar-icon-hover-filter: invert(22%) sepia(8%) saturate(420%) hue-rotate(180deg) brightness(85%) contrast(95%);
    --sidebar-icon-active-filter: invert(18%) sepia(10%) saturate(520%) hue-rotate(180deg) brightness(78%) contrast(100%);
}

/* Keep manual DARK and system DARK visually aligned */
html[data-theme="DARK"] {
    --wynlo-tooltip-bg: rgba(244, 245, 246, 0.94);
    --wynlo-tooltip-text: #111315;

    --sidebar-icon-filter: invert(92%) sepia(5%) saturate(120%) hue-rotate(180deg) brightness(96%) contrast(92%);
    --sidebar-icon-hover-filter: invert(100%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(100%) contrast(96%);
    --sidebar-icon-active-filter: invert(100%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(100%) contrast(100%);
}

@media (prefers-color-scheme: dark) {
    html[data-theme="SYSTEM"] {
        --wynlo-tooltip-bg: rgba(244, 245, 246, 0.94);
        --wynlo-tooltip-text: #111315;

        --sidebar-icon-filter: invert(92%) sepia(5%) saturate(120%) hue-rotate(180deg) brightness(96%) contrast(92%);
        --sidebar-icon-hover-filter: invert(100%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(100%) contrast(96%);
        --sidebar-icon-active-filter: invert(100%) sepia(0%) saturate(0%) hue-rotate(180deg) brightness(100%) contrast(100%);
    }
}

/* =========================
   1) Header breadcrumb tuning
   ========================= */
.wynlo-page-title {
    color: var(--wynlo-brand);
}

.wynlo-breadcrumb-root {
    color: var(--wynlo-muted);
    font-weight: 700;
    letter-spacing: 0.15px;
}

.wynlo-breadcrumb-sep {
    color: var(--wynlo-sep);
}

/* =========================
   2) Sidebar thin rail layout
   ========================= */
.sidebar-thin nav {
    padding: 0.25rem;
}

.sidebar-thin .sidebar-link {
    gap: 0.5rem;
    padding: 0.48rem 0.45rem;
    border-radius: 12px;
}

.sidebar-thin .sidebar-icon {
    width: 17px;
    height: 17px;
}

/* =========================
   3) Top brand toggle button
   ========================= */
.sidebar-brand-btn {
    width: 100%;
    border-bottom: 1px solid var(--border);
    padding: 10px 0;
    background: transparent;
    transition: background 120ms ease;
}

.sidebar-brand-btn:hover {
    background: var(--sidebar-brand-hover-bg);
}

.sidebar-logo-symbol-size {
    width: 34px;
    height: 34px;
}

.sidebar-logo-full-size {
    height: 24px;
}

.sidebar-logo-full {
    margin-left: 6px;
}

#sidebarDesktopWrap:not(.sidebar-collapsed) .sidebar-brand-btn {
    justify-content: flex-start !important;
    padding-left: 12px;
    padding-right: 12px;
}

#sidebarDesktopWrap.sidebar-collapsed .sidebar-brand-btn {
    justify-content: center !important;
    padding-left: 0;
    padding-right: 0;
}

/* =========================
   4) Sidebar icon coloring
   ========================= */
.sidebar-icon {
    filter: var(--sidebar-icon-filter);
    transition: transform 120ms ease, filter 120ms ease;
}

.sidebar-link:hover .sidebar-icon {
    filter: var(--sidebar-icon-hover-filter);
    transform: translateY(-0.5px);
}

/* Legacy active state support */
.sidebar-link.bg-gray-100 .sidebar-icon {
    filter: var(--sidebar-icon-active-filter);
}

/* Stable active state */
.sidebar-link.is-active .sidebar-icon {
    filter: var(--sidebar-icon-active-filter);
}

/* =========================
   5) Collapsed sidebar behavior
   ========================= */
.sidebar-collapsed .sidebar-label {
    display: none !important;
}

.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding-left: 0.35rem;
    padding-right: 0.35rem;
}

/* =========================
   6) Tooltip
   ========================= */
.sidebar-link {
    position: relative;
}

.sidebar-tooltip {
    position: absolute;
    left: 52px;
    top: 50%;
    transform: translateY(-50%);
    padding: 6px 10px;
    border-radius: 9999px;
    background: var(--wynlo-tooltip-bg);
    color: var(--wynlo-tooltip-text);
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
    z-index: 9999;
    box-shadow: var(--shadow-sm);
}

.sidebar-tooltip::before {
    content: "";
    position: absolute;
    left: -5px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    background: var(--wynlo-tooltip-bg);
    clip-path: polygon(100% 0, 0 50%, 100% 100%);
}

.sidebar-collapsed .sidebar-link:hover .sidebar-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(2px);
}

/* ==========================================================================
   Mobile overlay/drawer layering
   ========================================================================== */
#sidebarMobileWrap {
    position: relative;
    z-index: 50;
}

#mobileOverlay {
    z-index: 40;
}

/* ==========================================================================
   Auth notice component
   ========================================================================== */
.notice {
    border-radius: 14px;
    border: 1px solid var(--border);
    padding: 12px;
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
}

.notice--info {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text);
}

.notice--success {
    background: rgba(16, 185, 129, .10);
    border-color: rgba(16, 185, 129, .25);
    color: rgba(6, 95, 70, 1);
}

.notice--error {
    background: rgba(239, 68, 68, .10);
    border-color: rgba(239, 68, 68, .25);
    color: rgba(153, 27, 27, 1);
}

/* ==========================================================================
   Auth-only visual tuning
   ========================================================================== */
.auth-card {
    border-color: var(--border) !important;
}

/* ==========================================================================
   Sidebar token-driven hover/active + separators
   ========================================================================== */
.sidebar-sep {
    border-top: 1px solid var(--border);
}

.sidebar-link {
    transition: background .12s ease;
}

.sidebar-link:hover {
    background: var(--surface-2);
}

.sidebar-link.is-active {
    background: var(--surface-2);
}

.sidebar-mobile-top {
    border-bottom: 1px solid var(--border);
}

.sidebar-mobile-link {
    transition: background .12s ease;
}

.sidebar-mobile-link:hover {
    background: var(--surface-2);
}

.sidebar-mobile-link.is-active {
    background: var(--surface-2);
}

/* ==========================================================================
   Layout surfaces
   ========================================================================== */
.sidebar-surface {
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.overlay-backdrop {
    background: rgba(17, 19, 21, .40);
}

.drawer-shadow {
    box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Input error state
   ========================================================================== */
.input-app--error {
    border-color: var(--danger-border);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger-border) 20%, transparent);
}