/* ============================================================================
   SHARED UI COMPONENTS - SIDEBAR & STATUS INDICATORS
   ============================================================================ */

/* Design Tokens - shadcn/ui (Zinc) Inspired */
:root {
    /* Colors */
    --color-sidebar-bg: #09090b; /* zinc-950 */
    --color-sidebar-text: #fafafa; /* zinc-50 */
    --color-sidebar-text-inactive: #a1a1aa; /* zinc-400 */
    --color-sidebar-hover-bg: #18181b; /* zinc-900 */
    --color-sidebar-border: #27272a; /* zinc-800 */
    
    --color-sidebar-active-bg: #18181b;
    --color-sidebar-active-indicator: #fafafa;

    /* Status Colors */
    --color-status-healthy: #10b981;
    --color-status-error: #ef4444;
    --color-status-warning: #f59e0b;
    --color-status-healthy-shadow: rgba(16, 185, 129, 0.2);
    --color-status-error-shadow: rgba(239, 68, 68, 0.2);
    --color-status-warning-shadow: rgba(245, 158, 11, 0.2);

    /* Spacing */
    --sidebar-width: 16rem;
    --sidebar-width-collapsed: 4.5rem;
    --sidebar-item-py: 0.625rem;
    --sidebar-item-px: 0.875rem;

    /* Typography */
    --sidebar-title-size: 1.125rem;
    --sidebar-title-weight: 600;
    --sidebar-item-size: 0.875rem;
}

/* ============================================================================
   SIDEBAR NAVIGATION COMPONENT
   ============================================================================ */

.sidebar-nav {
    background: var(--color-sidebar-bg);
    color: var(--color-sidebar-text);
    /* Fixed positioning is handled by container */
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--sidebar-width);
    z-index: 30;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid var(--color-sidebar-border);
    display: flex;
    flex-direction: column;
}

/* Scroll area for items */
.sidebar-nav-list-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Mobile: Hidden by default, show with transform */
@media (max-width: 1023px) {
    .sidebar-nav {
        transform: translateX(-100%);
    }

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

/* Desktop: Visible by default */
@media (min-width: 1024px) {
    .sidebar-nav {
        transform: translateX(0);
    }
}

.sidebar-header {
    display: flex;
    align-items: center;
    height: 4.5rem;
    border-bottom: 1px solid var(--color-sidebar-border);
    padding: 0 1rem;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.sidebar-header-content {
    display: flex;
    align-items: center;
    width: 100%;
    transition: justify-content 0.3s ease;
}

.sidebar-header-logo {
    width: 2.25rem;
    height: 2.25rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--color-sidebar-border);
    border-radius: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.sidebar-header-logo img {
    width: 1.5rem;
    height: 1.5rem;
    object-contain;
}

.sidebar-header-text {
    color: var(--color-sidebar-text);
    font-size: 1rem;
    font-weight: 600;
    margin-left: 0.75rem;
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.sidebar-collapse-btn {
    position: absolute;
    right: -1rem;
    top: 50%;
    transform: translateY(-50%) scale(1);
    background: var(--color-sidebar-bg);
    border: 1px solid var(--color-sidebar-border);
    color: var(--color-sidebar-text-inactive);
    cursor: pointer;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    z-index: 50;
}

.sidebar-collapse-btn:hover {
    background-color: var(--color-sidebar-hover-bg);
    color: var(--color-sidebar-text);
    transform: translateY(-50%) scale(1.1);
}

.sidebar-collapse-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--color-sidebar-active-indicator);
}

.sidebar-nav.collapsed .sidebar-collapse-btn i {
    transform: rotate(180deg);
}

/* Sidebar Navigation */
.sidebar-nav-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 2rem 1rem;
    list-style: none;
    margin: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: var(--sidebar-item-py) var(--sidebar-item-px);
    margin: 0.125rem 0.75rem;
    color: var(--color-sidebar-text-inactive);
    text-decoration: none;
    border-radius: 0.375rem;
    font-size: var(--sidebar-item-size);
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
    cursor: pointer;
}

/* Nav Item States */
.nav-item:hover {
    background-color: var(--color-sidebar-hover-bg);
    color: var(--color-sidebar-text);
}

.nav-item:focus-visible {
    outline: 2px solid var(--color-sidebar-active-from);
    outline-offset: -2px;
    background-color: rgba(168, 85, 247, 0.1);
}

.nav-item.active,
.nav-item[aria-current="page"] {
    background-color: var(--color-sidebar-active-bg);
    color: var(--color-sidebar-text);
    font-weight: 600;
}

.nav-item.active::before,
.nav-item[aria-current="page"]::before {
    content: '';
    position: absolute;
    left: -0.75rem;
    top: 0.5rem;
    bottom: 0.5rem;
    width: 2px;
    background-color: var(--color-sidebar-active-indicator);
    border-radius: 0 1px 1px 0;
}

.nav-item-icon {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-item-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Collapsed sidebar state */
.sidebar-nav.collapsed {
    width: var(--sidebar-width-collapsed);
    overflow: visible; /* Allow button to float on edge */
}

.sidebar-nav.collapsed .sidebar-header {
    padding: 0;
    justify-content: center;
}

.sidebar-nav.collapsed .sidebar-header-content {
    justify-content: center;
}

.sidebar-nav.collapsed .sidebar-header-text,
.sidebar-nav.collapsed .nav-item-label {
    opacity: 0;
    visibility: hidden;
    width: 0;
    margin: 0;
}

.sidebar-nav.collapsed .nav-item {
    justify-content: center;
    margin: 0.25rem 0.5rem;
    padding: 0.625rem;
}

.sidebar-nav.collapsed .nav-item.active::before,
.sidebar-nav.collapsed .nav-item[aria-current="page"]::before {
    left: -0.5rem;
}

/* Sidebar Footer - System Status */
.sidebar-footer {
    margin-top: auto;
    padding: 1rem 0.75rem;
    border-top: 1px solid var(--color-sidebar-border);
    transition: all 0.3s ease;
    min-height: 4rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.sidebar-nav.collapsed .sidebar-footer {
    padding: 1rem 0;
    align-items: center;
}

.sidebar-nav.collapsed .sidebar-footer .status-section-title,
.sidebar-nav.collapsed .sidebar-footer .status-text,
.sidebar-nav.collapsed .sidebar-footer .status-meta {
    display: none;
}

/* Status Indicator Pattern for Collapsed */
.sidebar-nav.collapsed .sidebar-footer::after {
    content: '';
    width: 0.75rem;
    height: 0.75rem;
    background-color: var(--color-status-healthy);
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2);
    animation: status-pulse-glow 2s infinite;
}

@keyframes status-pulse-glow {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.status-section-title {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.status-indicator {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    display: inline-block;
    animation: pulse-indicator 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.status-indicator.healthy {
    background-color: var(--color-status-healthy);
    box-shadow: 0 0 0 2px var(--color-status-healthy-shadow);
}

.status-indicator.error {
    background-color: var(--color-status-error);
    box-shadow: 0 0 0 2px var(--color-status-error-shadow);
    animation: pulse-indicator-error 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.status-indicator.warning {
    background-color: var(--color-status-warning);
    box-shadow: 0 0 0 2px var(--color-status-warning-shadow);
    animation: pulse-indicator-warning 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.status-text {
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-meta {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 0.25rem;
}

/* ============================================================================
   SYSTEM STATUS HEADER COMPONENT
   ============================================================================ */

.system-status-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    gap: 1rem;
}

.system-status-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.system-status-badge.healthy {
    background-color: #f0fdf4;
    border-color: #86efac;
    color: #166534;
}

.system-status-badge.warning {
    background-color: #fffbeb;
    border-color: #fcd34d;
    color: #92400e;
}

.system-status-badge.error {
    background-color: #fef2f2;
    border-color: #fca5a5;
    color: #991b1b;
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */

@keyframes pulse-indicator {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

@keyframes pulse-indicator-error {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes pulse-indicator-warning {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

/* ============================================================================
   RESPONSIVE & UTILITIES
   ============================================================================ */

/* Main content layout */
.main-with-sidebar {
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-nav.collapsed ~ .main-with-sidebar {
    margin-left: var(--sidebar-width-collapsed);
}

@media (max-width: 1023px) {
    .main-with-sidebar {
        margin-left: 0;
    }

    .main-with-sidebar.sidebar-open {
        margin-left: 0;
    }
}

/* Hamburger Menu Button */
.sidebar-toggle {
    display: none;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0.5rem;
    background: none;
    border: none;
    color: #4b5563;
    cursor: pointer;
    border-radius: 0.375rem;
    transition: background-color 0.2s ease;
}

.sidebar-toggle:hover {
    background-color: #f3f4f6;
}

.sidebar-toggle:focus-visible {
    outline: 2px solid var(--color-sidebar-active-from);
    outline-offset: 2px;
}

@media (max-width: 1023px) {
    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Accessibility - Skip to content */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000;
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-to-main:focus {
    top: 0;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {

    .nav-item,
    .sidebar-nav,
    .status-indicator {
        transition: none;
        animation: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: more) {
    .nav-item:focus-visible {
        outline-width: 3px;
    }

    .sidebar-nav {
        border-right: 2px solid white;
    }
}