/**
 * Стили для универсальной навигационной панели вебинара
 * "DeFi на Conflux: Створення Simple DEX"
 */

/* CSS Variables */
:root {
    --brand-blue: #00d4ff;
    --brand-green: #00ff9d;
    --brand-purple: #9d00ff;
    --bg-dark: #1a1a1a;
    --card-glass: rgba(35, 35, 45, 0.8);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
}

/* Sidebar Navigation Container */
.sidebar-nav {
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    height: calc(100vh + env(safe-area-inset-bottom, 0px));
    width: 380px;
    background: rgba(26, 26, 26, 0.98);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-left: 1px solid var(--border-color);
    box-shadow: -10px 0 50px rgba(0, 0, 0, 0.5);
    z-index: 999;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-nav.open {
    transform: translateX(0);
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    position: fixed;
    right: 100px;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--brand-blue), var(--brand-green));
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.4);
    transition: all 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
    opacity: 1;
}

.sidebar-toggle:hover {
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 30px rgba(0, 212, 255, 0.6);
}

/* Hide toggle when sidebar is open */
.sidebar-nav.open ~ .sidebar-toggle {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-toggle svg {
    width: 24px;
    height: 24px;
    color: white;
}

/* Desktop: show menu icon, hide close icon */
.toggle-icon-menu {
    display: block;
}

.toggle-icon-close {
    display: none;
}

/* Pulse animation for first visit */
@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(0, 212, 255, 0.4);
    }
    50% {
        box-shadow: 0 4px 40px rgba(0, 212, 255, 0.8);
        transform: translateY(-50%) scale(1.15);
    }
}

/* Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Desktop overlay - more subtle */
@media (min-width: 1201px) {
    .sidebar-overlay {
        background: rgba(0, 0, 0, 0.6);
    }

    .sidebar-overlay.active::after {
        content: 'Клікніть щоб закрити';
        position: absolute;
        top: 50%;
        left: 30%;
        transform: translate(-50%, -50%);
        color: rgba(255, 255, 255, 0.5);
        font-size: 14px;
        font-weight: 500;
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .sidebar-overlay.active:hover::after {
        opacity: 1;
    }
}

/* Sidebar Header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.1), rgba(0, 255, 157, 0.1));
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--brand-blue), var(--brand-green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.sidebar-close {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    line-height: 1;
    flex-shrink: 0;
}

.sidebar-close:hover {
    background: rgba(255, 59, 48, 0.3);
    border-color: rgba(255, 59, 48, 0.6);
    transform: rotate(90deg);
    box-shadow: 0 0 10px rgba(255, 59, 48, 0.4);
}

.sidebar-close:active {
    transform: rotate(90deg) scale(0.9);
}

/* Breadcrumbs */
.sidebar-breadcrumbs {
    padding: 12px 20px;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    background: rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.breadcrumb-link {
    color: var(--brand-blue);
    text-decoration: none;
    transition: color 0.3s ease;
}

.breadcrumb-link:hover {
    color: var(--brand-green);
    text-decoration: underline;
}

.breadcrumb-separator {
    color: var(--text-secondary);
    opacity: 0.5;
}

.breadcrumb-current {
    color: var(--text-primary);
    font-weight: 500;
}

/* Search */
.sidebar-search {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.search-input {
    width: 100%;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: white;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.search-input:focus {
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

/* Sidebar Content (scrollable) */
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 212, 255, 0.3) rgba(0, 0, 0, 0.2);
}

.sidebar-content::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: rgba(0, 212, 255, 0.3);
    border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 212, 255, 0.5);
}

/* Navigation Sections */
.nav-section {
    margin-bottom: 20px;
}

.nav-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--brand-blue);
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
}

.nav-section-title:hover {
    background: rgba(0, 212, 255, 0.1);
    transform: translateX(-3px);
}

.nav-section-toggle {
    font-size: 10px;
    transition: transform 0.3s ease;
}

.nav-section.collapsed .nav-section-toggle {
    transform: rotate(-90deg);
}

.nav-section-content {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 2000px;
    overflow: hidden;
    opacity: 1;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-section.collapsed .nav-section-content {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

/* Navigation Items */
.nav-item {
    position: relative;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--card-glass);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: linear-gradient(135deg, var(--brand-blue), var(--brand-green));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.nav-link:hover {
    border-color: var(--brand-blue);
    background: rgba(0, 212, 255, 0.05);
    transform: translateX(-3px);
}

.nav-link:hover::before {
    opacity: 1;
}

.nav-link.active {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.15), rgba(0, 255, 157, 0.15));
    border-color: var(--brand-blue);
}

.nav-link.active::before {
    opacity: 1;
}

.nav-link-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.nav-link-text {
    flex: 1;
    font-size: 13px;
}

.nav-link-badge {
    padding: 2px 8px;
    background: rgba(0, 212, 255, 0.2);
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    color: var(--brand-blue);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Subitems */
.nav-subitems {
    margin-top: 6px;
    margin-left: 20px;
    padding-left: 15px;
    border-left: 2px solid rgba(0, 212, 255, 0.2);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-subitem {
    position: relative;
}

.nav-sublink {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 12px;
    transition: all 0.3s ease;
}

.nav-sublink:hover {
    background: rgba(0, 212, 255, 0.1);
    color: var(--text-primary);
    transform: translateX(3px);
}

.nav-sublink-arrow {
    font-size: 12px;
    color: var(--brand-blue);
    flex-shrink: 0;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.sidebar-footer-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.1), rgba(0, 255, 157, 0.1));
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: white;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.sidebar-footer-link:hover {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.2), rgba(0, 255, 157, 0.2));
    border-color: var(--brand-blue);
    transform: translateX(-3px);
}

.sidebar-footer-link span:first-child {
    font-size: 18px;
}

/* Responsive Design */

/* Tablet (1200px and below) */
@media (max-width: 1200px) {
    .sidebar-nav {
        width: 350px;
    }

    .sidebar-toggle {
        right: 80px;
    }
}

/* Mobile Landscape & Portrait (768px and below) */
@media (max-width: 768px) {
    /* Sidebar fullscreen on mobile */
    .sidebar-nav {
        width: 100%;
        max-width: 100%;
        border-left: none;
    }

    /* Toggle button - positioned to not overlap main menu */
    .sidebar-toggle {
        position: fixed;
        width: 50px;
        height: 50px;
        right: 30px;
        top: 89px;
        transform: none;
        z-index: 999;
        box-shadow: 0 4px 20px rgba(0, 212, 255, 0.6);
    }

    /* Mobile: Toggle button changes icon when sidebar opens */
    .sidebar-nav.open ~ .sidebar-toggle .toggle-icon-menu {
        display: none;
    }

    .sidebar-nav.open ~ .sidebar-toggle .toggle-icon-close {
        display: block;
    }

    /* Keep toggle visible when sidebar is open on mobile - it acts as close button */
    .sidebar-nav.open ~ .sidebar-toggle {
        opacity: 1;
        pointer-events: auto;
        z-index: 1001;
    }

    /* Hide header close button on mobile - toggle button does this job */
    .sidebar-close {
        display: none;
    }

    .sidebar-toggle:hover,
    .sidebar-toggle:active {
        transform: scale(1.05);
    }

    /* Header */
    .sidebar-header {
        padding: 18px 15px;
    }

    .sidebar-title {
        font-size: 17px;
    }

    .sidebar-close {
        width: 44px;
        height: 44px;
        font-size: 36px;
        background: rgba(255, 59, 48, 0.3);
        border-color: rgba(255, 59, 48, 0.6);
        box-shadow: 0 2px 10px rgba(255, 59, 48, 0.4);
    }

    .sidebar-close:hover {
        background: rgba(255, 59, 48, 0.5);
        transform: rotate(90deg) scale(1.05);
    }

    /* Breadcrumbs */
    .sidebar-breadcrumbs {
        padding: 10px 15px;
        font-size: 12px;
    }

    /* Search */
    .sidebar-search {
        padding: 12px 15px;
    }

    .search-input {
        padding: 12px 15px;
        font-size: 15px;
    }

    /* Content - add extra padding at bottom for footer visibility */
    .sidebar-content {
        padding: 15px;
        padding-bottom: 20px;
    }

    /* Section titles */
    .nav-section-title {
        padding: 12px 14px;
        font-size: 11px;
    }

    /* Nav links */
    .nav-link {
        padding: 12px 14px;
        font-size: 14px;
    }

    .nav-link-icon {
        font-size: 20px;
    }

    .nav-link-text {
        font-size: 13px;
    }

    .nav-link-badge {
        font-size: 9px;
        padding: 3px 7px;
    }

    /* Subitems */
    .nav-subitems {
        margin-left: 15px;
        padding-left: 12px;
    }

    .nav-sublink {
        padding: 8px 12px;
        font-size: 13px;
    }

    /* Footer - improved visibility on mobile */
    .sidebar-footer {
        padding: 15px 15px;
        padding-bottom: calc(15px + env(safe-area-inset-bottom));
        background: rgba(0, 0, 0, 0.4);
        border-top: 2px solid rgba(0, 212, 255, 0.3);
    }

    .sidebar-footer-link {
        padding: 14px 15px;
        font-size: 15px;
        font-weight: 600;
        background: linear-gradient(135deg, rgba(0, 212, 255, 0.15), rgba(0, 255, 157, 0.15));
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }

    /* Overlay more prominent on mobile */
    .sidebar-overlay {
        background: rgba(0, 0, 0, 0.8);
    }

    .sidebar-overlay.active {
        opacity: 1;
        backdrop-filter: blur(8px);
    }

    /* Visual hint to close on mobile */
    .sidebar-overlay.active::after {
        content: '← Натисніть, щоб закрити';
        position: absolute;
        left: 20px;
        top: 50%;
        transform: translateY(-50%);
        color: rgba(255, 255, 255, 0.6);
        font-size: 14px;
        font-weight: 600;
        pointer-events: none;
        animation: fadeInOut 3s ease-in-out infinite;
    }

    @keyframes fadeInOut {
        0%, 100% { opacity: 0.4; }
        50% { opacity: 0.8; }
    }
}

/* Small Mobile (480px and below) */
@media (max-width: 480px) {
    /* Toggle button slightly smaller */
    .sidebar-toggle {
        width: 48px;
        height: 48px;
        right: 25px;
        top: 84px;
    }

    /* Compact header */
    .sidebar-header {
        padding: 15px 12px;
    }

    .sidebar-title {
        font-size: 16px;
    }

    .sidebar-close {
        width: 42px;
        height: 42px;
        font-size: 32px;
        background: rgba(255, 59, 48, 0.3);
        border-color: rgba(255, 59, 48, 0.6);
        box-shadow: 0 2px 10px rgba(255, 59, 48, 0.4);
    }

    .sidebar-close:active {
        background: rgba(255, 59, 48, 0.6);
        transform: rotate(90deg) scale(0.95);
    }

    /* Breadcrumbs */
    .sidebar-breadcrumbs {
        padding: 8px 12px;
        font-size: 11px;
    }

    /* Search */
    .sidebar-search {
        padding: 10px 12px;
    }

    .search-input {
        padding: 10px 12px;
        font-size: 14px;
    }

    /* Content - extra padding at bottom for footer visibility */
    .sidebar-content {
        padding: 12px;
        padding-bottom: 15px;
    }

    /* Compact sections */
    .nav-section {
        margin-bottom: 15px;
    }

    .nav-section-title {
        padding: 10px 12px;
        font-size: 10px;
    }

    .nav-section-toggle {
        font-size: 9px;
    }

    /* Compact links */
    .nav-link {
        padding: 10px 12px;
        font-size: 13px;
    }

    .nav-link-icon {
        font-size: 18px;
    }

    .nav-link-text {
        font-size: 12px;
        line-height: 1.3;
    }

    .nav-link-badge {
        font-size: 8px;
        padding: 2px 5px;
    }

    /* Compact subitems */
    .nav-subitems {
        margin-left: 10px;
        padding-left: 10px;
        gap: 3px;
    }

    .nav-sublink {
        padding: 6px 10px;
        font-size: 12px;
    }

    .nav-sublink-arrow {
        font-size: 11px;
    }

    /* Footer - improved visibility */
    .sidebar-footer {
        padding: 12px 12px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
        gap: 10px;
        background: rgba(0, 0, 0, 0.5);
        border-top: 2px solid rgba(0, 212, 255, 0.4);
    }

    .sidebar-footer-link {
        padding: 12px 12px;
        font-size: 14px;
        font-weight: 600;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    }

    .sidebar-footer-link span:first-child {
        font-size: 18px;
    }
}

/* Extra Small Mobile (360px and below) */
@media (max-width: 360px) {
    .sidebar-toggle {
        width: 45px;
        height: 45px;
        right: 12px;
        top: 65px;
    }

    .sidebar-title {
        font-size: 15px;
    }

    .nav-link-text {
        font-size: 11px;
    }

    .sidebar-footer-link {
        font-size: 12px;
    }
}

/* Landscape orientation on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .sidebar-header {
        padding: 10px 15px;
    }

    .sidebar-title {
        font-size: 14px;
    }

    .sidebar-search {
        padding: 8px 15px;
    }

    .search-input {
        padding: 8px 12px;
    }

    .sidebar-content {
        padding: 10px 15px;
    }

    .nav-section {
        margin-bottom: 10px;
    }

    .nav-section-title {
        padding: 8px 12px;
    }

    .nav-link {
        padding: 8px 12px;
    }

    .sidebar-footer {
        padding: 8px 15px;
    }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .sidebar-toggle {
        width: 52px;
        height: 52px;
    }

    .sidebar-close {
        width: 40px;
        height: 40px;
    }

    .nav-link {
        padding: 14px 16px;
        min-height: 48px;
    }

    .nav-section-title {
        padding: 12px 14px;
        min-height: 44px;
    }

    .nav-sublink {
        padding: 10px 14px;
        min-height: 44px;
    }

    /* Remove hover effects on touch devices */
    .nav-link:hover,
    .nav-sublink:hover,
    .sidebar-footer-link:hover {
        transform: none;
    }

    /* Add active states for touch */
    .nav-link:active {
        transform: scale(0.98);
        opacity: 0.9;
    }

    .nav-section-title:active {
        opacity: 0.8;
    }
}

/* Desktop: Show close button in header (toggle button disappears when sidebar opens) */
@media (min-width: 769px) {
    .sidebar-close {
        display: flex !important;
    }
}

/* Print styles - hide navigation when printing */
@media print {
    .sidebar-nav,
    .sidebar-toggle,
    .sidebar-overlay {
        display: none !important;
    }
}
