/* Enhanced Left Sidebar - IMPROVED UX/UI VERSION */

:root {
    --indicator-width: 4px;
    --preview-width: 80px;
    --sidebar-width: 320px;
    --hover-delay: 100ms;
    --hide-delay: 300ms;
    --animation-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --edge-color: rgba(239, 68, 68, 0.6);
    --edge-color-active: rgba(239, 68, 68, 0.9);
}

/* Hide original floating toggle completely */
.sidebar-system .sidebar-floating-toggle {
    display: none !important;
}

/* Hover Detection Zone - Larger for better UX */
.sidebar-hover-zone {
    position: fixed;
    top: 0;
    left: 0;
    width: 100px;
    height: 100vh;
    z-index: 1001;
    pointer-events: all;
    background: transparent;
    cursor: pointer;
}

/* Edge Indicator - More Subtle */
.sidebar-edge-indicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 2px;
    height: 100vh;
    background: linear-gradient(
        180deg,
        transparent 0%,
        rgba(239, 68, 68, 0.3) 20%,
        rgba(239, 68, 68, 0.4) 80%,
        transparent 100%
    );
    z-index: 999;
    opacity: 0.8;
    transition: all 0.3s ease;
}

.sidebar-edge-indicator.hover-active {
    opacity: 0;
    width: 0;
}

/* MAIN UX CHANGE: Icons Always Visible by Default */
.sidebar-icon-preview {
    position: fixed;
    top: 50%;
    left: 15px;
    transform: translateY(-50%);
    z-index: 1002;
    display: flex;
    flex-direction: column;
    gap: 20px;
    opacity: 1;
    transition: all 0.4s var(--animation-spring);
    pointer-events: all;
}

/* Hide icons when hovering (opposite of before) */
.sidebar-icon-preview.hide-on-hover {
    opacity: 0;
    transform: translateY(-50%) translateX(-50px);
    pointer-events: none;
}

/* Bigger, More Intuitive Icons */
.preview-icon {
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(239, 68, 68, 0.5);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ef4444;
    font-size: 16px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

/* Enhanced Icon Backgrounds */
.preview-icon::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), transparent);
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

/* Better Hover Effects for Icons */
.preview-icon:hover {
    transform: scale(1.1);
    border-color: rgba(239, 68, 68, 0.8);
    box-shadow: 0 12px 30px rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.preview-icon:hover::before {
    opacity: 1;
}

.preview-icon:active {
    transform: scale(1.05);
}

/* Icon-Specific Styling for Better Recognition */
.preview-icon[data-action="dashboard"] {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(0, 0, 0, 0.85));
    border-color: rgba(59, 130, 246, 0.5);
}

.preview-icon[data-action="marketplace"] {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.1), rgba(0, 0, 0, 0.85));
    border-color: rgba(34, 197, 94, 0.5);
}

.preview-icon[data-action="library"] {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.1), rgba(0, 0, 0, 0.85));
    border-color: rgba(168, 85, 247, 0.5);
}

.preview-icon[data-action="profile"] {
    background: linear-gradient(135deg, rgba(251, 146, 60, 0.1), rgba(0, 0, 0, 0.85));
    border-color: rgba(251, 146, 60, 0.5);
}

.preview-icon[data-action="settings"] {
    background: linear-gradient(135deg, rgba(156, 163, 175, 0.1), rgba(0, 0, 0, 0.85));
    border-color: rgba(156, 163, 175, 0.5);
}

/* Enhanced Tooltips */
.preview-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 20px);
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
    border: 1px solid rgba(239, 68, 68, 0.3);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.preview-icon:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(10px);
}

/* Sidebar States - Updated Logic */
.left-sidebar.hover-active {
    transform: translateX(0);
    transition: transform 0.4s var(--animation-spring);
    transition-delay: var(--hover-delay);
}

.left-sidebar.mouse-left {
    transform: translateX(-100%);
    transition: transform 0.4s var(--animation-spring);
    transition-delay: var(--hide-delay);
}

/* Sidebar Content Always Full Opacity When Shown */
.left-sidebar.hover-active .sidebar-container {
    opacity: 1;
    transition: opacity 0.3s ease;
    transition-delay: 200ms;
}

/* Pulsing Animation for Icon Discoverability */
@keyframes iconPulse {
    0%, 100% {
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    }
    50% {
        box-shadow: 0 8px 25px rgba(239, 68, 68, 0.2), 0 0 0 4px rgba(239, 68, 68, 0.1);
    }
}

.preview-icon {
    animation: iconPulse 4s ease-in-out infinite;
}

.preview-icon:nth-child(1) { animation-delay: 0s; }
.preview-icon:nth-child(2) { animation-delay: 0.5s; }
.preview-icon:nth-child(3) { animation-delay: 1s; }
.preview-icon:nth-child(4) { animation-delay: 1.5s; }
.preview-icon:nth-child(5) { animation-delay: 2s; }

/* Stop pulsing after user interaction */
.sidebar-system.user-discovered .preview-icon {
    animation: none;
}

/* Responsive Adjustments */
@media (max-width: 1024px) {
    .sidebar-hover-zone { width: 90px; }
    .sidebar-icon-preview { left: 12px; }
    .preview-icon { width: 42px; height: 42px; font-size: 17px; }
}

@media (max-width: 768px) {
    .sidebar-hover-zone { width: 80px; }
    .sidebar-icon-preview { left: 10px; gap: 15px; }
    .preview-icon { width: 38px; height: 38px; font-size: 16px; }
    .preview-icon::after { font-size: 12px; padding: 8px 12px; }
}

/* Touch Device Behavior */
@media (hover: none) {
    .sidebar-hover-zone { width: 70px; }
    .preview-icon { width: 55px; height: 55px; }
    .preview-icon:active { transform: scale(1.2); }
}

/* Focus States */
.preview-icon:focus {
    outline: 3px solid #ef4444;
    outline-offset: 4px;
    transform: scale(1.05);
}

/* Loading State Animation */
@keyframes iconLoad {
    0% { opacity: 0; transform: translateY(20px) scale(0.8); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.preview-icon.loading {
    animation: iconLoad 0.5s var(--animation-spring) forwards;
}

/* Ripple Effect */
.ripple-effect {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    animation: ripple 0.6s linear;
    background-color: rgba(239, 68, 68, 0.5);
}

@keyframes ripple {
    to { transform: scale(4); opacity: 0; }
}
