/* ============================================
   HEADER STYLES
   Mobile-first responsive header with animations
   ============================================ */

/* Burger Icon Animation */
.burger-icon {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 24px;
    height: 18px;
    position: relative;
}

.burger-icon__line {
    display: block;
    width: 100%;
    height: 2px;
    background-color: currentColor;
    border-radius: 2px;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
    position: relative;
}

/* Анимация трансформации в крестик */
.header__burger.is-active .burger-icon__line:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.header__burger.is-active .burger-icon__line:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.header__burger.is-active .burger-icon__line:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

/* Hover эффект для бургера */
.header__burger:not(.is-active):hover .burger-icon__line {
    background-color: var(--color-primary, #3b82f6);
}

/* Header Layout */
.header {
    position: sticky;
    top: 0;
    z-index: 1002;
    background: var(--color-bg, #ffffff);
    border-bottom: 1px solid var(--color-border, #e5e7eb);
    backdrop-filter: blur(8px);
    background: rgba(255, 255, 255, 0.95);
}

[data-theme="dark"] .header {
    background: rgba(31, 41, 55, 0.95);
    border-bottom-color: var(--color-border, #374151);
}

.header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    position: relative;
    max-width: 1400px;
    margin: 0 auto;
}

.header__burger {
    display: none;
    order: -1;
    flex-shrink: 0;
    padding: 0.5rem;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--color-text, #111827);
    transition: color 0.2s;
    z-index: 1003;
    position: relative;
}

[data-theme="dark"] .header__burger {
    color: var(--color-text, #f9fafb);
}

.header__burger:hover {
    color: var(--color-primary, #3b82f6);
}

.header__burger:focus {
    outline: 2px solid var(--color-primary, #3b82f6);
    outline-offset: 2px;
    border-radius: 0.375rem;
}

.header__logo {
    flex-shrink: 0;
    order: 0;
}

.header__nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 2rem;
    flex: 1;
}

.header__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    flex-shrink: 0;
}

.header__user-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header__user-name {
    display: inline;
}

.header__login-btn,
.header__register-btn {
    display: inline-flex;
}

/* Dropdown Items with Icons */
.dropdown__item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.dropdown__item svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.dropdown__item:hover svg {
    opacity: 1;
}

/* Mobile Navigation */
.mobile-nav {
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    background: var(--color-bg, #ffffff);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.1);
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    will-change: transform;
}

[data-theme="dark"] .mobile-nav {
    background: var(--color-bg, #1f2937);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.3);
}

.mobile-nav.is-active {
    transform: translateX(0);
}

/* Анимация элементов меню при открытии */
.mobile-nav.is-active .mobile-nav__item {
    animation: fadeInSlide 0.3s ease-out forwards;
    opacity: 0;
}

.mobile-nav.is-active .mobile-nav__item:nth-child(1) { animation-delay: 0.05s; }
.mobile-nav.is-active .mobile-nav__item:nth-child(2) { animation-delay: 0.1s; }
.mobile-nav.is-active .mobile-nav__item:nth-child(3) { animation-delay: 0.15s; }
.mobile-nav.is-active .mobile-nav__item:nth-child(4) { animation-delay: 0.2s; }
.mobile-nav.is-active .mobile-nav__item:nth-child(5) { animation-delay: 0.25s; }
.mobile-nav.is-active .mobile-nav__item:nth-child(6) { animation-delay: 0.3s; }
.mobile-nav.is-active .mobile-nav__item:nth-child(7) { animation-delay: 0.35s; }
.mobile-nav.is-active .mobile-nav__item:nth-child(8) { animation-delay: 0.4s; }
.mobile-nav.is-active .mobile-nav__item:nth-child(9) { animation-delay: 0.45s; }
.mobile-nav.is-active .mobile-nav__item:nth-child(10) { animation-delay: 0.5s; }

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.mobile-nav__content {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-nav__item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    color: var(--color-text, #111827);
    text-decoration: none;
    transition: all 0.2s ease;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    font-size: 0.9375rem;
    cursor: pointer;
    position: relative;
    border-left: 3px solid transparent;
}

[data-theme="dark"] .mobile-nav__item {
    color: var(--color-text, #f9fafb);
}

.mobile-nav__item svg {
    flex-shrink: 0;
    opacity: 0.7;
    width: 20px;
    height: 20px;
    transition: all 0.2s ease;
}

.mobile-nav__item:hover,
.mobile-nav__item:focus {
    background: var(--color-bg-secondary, #f3f4f6);
    padding-left: 1.25rem;
}

[data-theme="dark"] .mobile-nav__item:hover,
[data-theme="dark"] .mobile-nav__item:focus {
    background: var(--color-bg-secondary, #374151);
}

.mobile-nav__item:hover svg,
.mobile-nav__item:focus svg {
    opacity: 1;
    transform: scale(1.1);
}

.mobile-nav__item.is-active {
    color: var(--color-primary, #3b82f6);
    background: var(--color-primary-light, #eff6ff);
    border-left-color: var(--color-primary, #3b82f6);
    font-weight: 500;
}

[data-theme="dark"] .mobile-nav__item.is-active {
    color: var(--color-primary, #60a5fa);
    background: rgba(59, 130, 246, 0.15);
    border-left-color: var(--color-primary, #60a5fa);
}

.mobile-nav__item.is-active svg {
    opacity: 1;
}

.mobile-nav__divider {
    height: 1px;
    background: var(--color-border, #e5e7eb);
    margin: 0.5rem 1rem;
}

[data-theme="dark"] .mobile-nav__divider {
    background: var(--color-border, #374151);
}

.mobile-nav__item--button {
    font-family: inherit;
}

/* Mobile Navigation Overlay */
.mobile-nav-overlay {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    backdrop-filter: blur(2px);
    pointer-events: none;
}

[data-theme="dark"] .mobile-nav-overlay {
    background: rgba(0, 0, 0, 0.7);
}

.mobile-nav-overlay.is-active {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

/* Dropdown Overlay */
.dropdown-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 998;
    pointer-events: none;
}

[data-theme="dark"] .dropdown-overlay {
    background: rgba(0, 0, 0, 0.5);
}

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

/* На мобильных overlay для dropdown более заметный */
@media (max-width: 768px) {
    .dropdown-overlay {
        background: rgba(0, 0, 0, 0.5);
    }
    
    [data-theme="dark"] .dropdown-overlay {
        background: rgba(0, 0, 0, 0.7);
    }
}

/* Scrollbar для мобильного меню */
.mobile-nav::-webkit-scrollbar {
    width: 6px;
}

.mobile-nav::-webkit-scrollbar-track {
    background: transparent;
}

.mobile-nav::-webkit-scrollbar-thumb {
    background: var(--color-border, #e5e7eb);
    border-radius: 3px;
}

[data-theme="dark"] .mobile-nav::-webkit-scrollbar-thumb {
    background: var(--color-border, #4b5563);
}

.mobile-nav::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-secondary, #9ca3af);
}

[data-theme="dark"] .mobile-nav::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-secondary, #6b7280);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .header__inner {
        /* Три колонки: burger | logo | actions */
        display: grid;
        grid-template-columns: auto 1fr auto;
        gap: 0.5rem;
        align-items: center;
    }
    
    .header__burger {
        display: flex;
        grid-column: 1;
        justify-self: start;
    }
    
    .header__logo {
        grid-column: 2;
        justify-self: center;
        max-width: 150px;
        position: relative;
        transform: none;
    }
    
    .header__nav {
        display: none;
    }
    
    .header__actions {
        grid-column: 3;
        justify-self: end;
        margin-left: 0;
    }
    
    .header__user-name {
        display: none;
    }
    
    .header__register-btn {
        display: none;
    }
    
    /* Hide desktop theme switcher on mobile */
    .header__actions [data-theme-toggle] {
        display: none;
    }
}

@media (min-width: 769px) {
    .mobile-nav,
    .mobile-nav-overlay {
        display: none;
    }
}

/* Tablet Responsive */
@media (max-width: 1024px) and (min-width: 769px) {
    .header__nav {
        gap: 0.25rem;
        margin-left: 1rem;
    }
    
    .header__nav-item {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }
}

/* Small mobile optimization */
@media (max-width: 480px) {
    .header__inner {
        padding: 0.5rem 0.75rem;
        gap: 0.25rem;
    }
    
    .header__logo {
        max-width: 120px;
    }
    
    .header__actions {
        gap: 0.25rem;
    }
    
    .btn--icon {
        width: 32px;
        height: 32px;
        padding: 0.375rem;
    }
    
    .btn--icon svg {
        width: 18px;
        height: 18px;
    }
}


/* ============================================
   DROPDOWN IMPROVEMENTS FOR HEADER
   ============================================ */

/* Desktop specific styles */
@media (min-width: 769px) {
    .dropdown__item--mobile-only {
        display: none !important;
    }
    
    .dropdown__divider--mobile-only {
        display: none !important;
    }
}

/* Mobile - iOS style bottom sheet */
@media (max-width: 768px) {
    .dropdown__item--mobile-only {
        display: flex !important;
    }
    
    .dropdown__divider--mobile-only {
        display: block !important;
    }
    
    /* Bottom Sheet для всех dropdown - переопределяем desktop стили */
    .dropdown__menu {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        min-width: 100% !important;
        max-width: 100% !important;
        max-height: 70vh;
        border-radius: 1rem 1rem 0 0 !important;
        border: none !important;
        /* По умолчанию скрыто */
        opacity: 0 !important;
        visibility: hidden !important;
        transform: translateY(100%) !important;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        z-index: 999 !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15) !important;
        overflow-y: auto;
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
    
    .dropdown.is-open .dropdown__menu {
        opacity: 1 !important;
        visibility: visible !important;
        transform: translateY(0) !important;
    }
    
    /* Handle для свайпа */
    .dropdown__menu::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: var(--border, #e5e7eb);
        border-radius: 2px;
        margin: 0.75rem auto 0.5rem;
    }
    
    /* Увеличенные touch targets */
    .dropdown__item {
        padding: 1rem 1.25rem !important;
        font-size: 1rem !important;
        min-height: 52px;
    }
    
    /* Специальные стили для уведомлений */
    .dropdown__menu--notifications {
        max-height: 80vh;
    }
    
    .notifications-panel__list {
        max-height: calc(80vh - 120px);
    }
    
    .notification-dropdown-item {
        padding: 1rem 1.25rem;
        min-height: auto;
    }
}

/* ============================================
   SEARCH OVERLAY
   ============================================ */

.search-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
}

.search-overlay.is-active {
    opacity: 1;
    visibility: visible;
}

.search-container {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg-primary, #ffffff);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-100%);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 101;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.search-container.is-active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border, #e5e7eb);
    width: 100%;
    max-width: 1200px;
    min-width: 320px;
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1.125rem;
    background: transparent;
    color: var(--text-primary, #111827);
}

.search-input::placeholder {
    color: var(--text-tertiary, #9ca3af);
}

.search-results {
    flex: 1;
    overflow-y: auto;
}

.search-results__group {
    margin-bottom: 1.5rem;
}

.search-results__title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary, #6b7280);
    margin-bottom: 0.75rem;
    padding: 0 1rem;
}

.search-results__item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--text-primary, #111827);
    transition: background-color 0.15s;
}

.search-results__item:hover {
    background: var(--bg-secondary, #f3f4f6);
}

.search-results__item-image {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--bg-secondary, #f3f4f6);
}

.search-results__item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.search-results__icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: var(--text-tertiary, #9ca3af);
}

.search-results__icon svg {
    width: 100%;
    height: 100%;
}

.search-results__content {
    flex: 1;
    min-width: 0;
}

.search-results__item-title {
    font-weight: 500;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-results__item-excerpt {
    font-size: 0.875rem;
    color: var(--text-secondary, #6b7280);
    margin-bottom: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-results__item-meta {
    font-size: 0.75rem;
    color: var(--text-tertiary, #9ca3af);
}

.search-results__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-secondary, #6b7280);
}

.search-results__empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.search-results__error {
    padding: 2rem 1rem;
    text-align: center;
    color: #ef4444;
}

.search-results__loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 3rem 1rem;
    color: var(--text-secondary, #6b7280);
    font-size: 1rem;
}

.loading-dots {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.loading-dots__dot {
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
    animation: loading-dots 1.4s ease-in-out infinite;
}

.loading-dots__dot:nth-child(1) {
    animation-delay: 0s;
}

.loading-dots__dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots__dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes loading-dots {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    30% {
        opacity: 1;
        transform: scale(1.2);
    }
}

[data-theme="dark"] .search-container {
    background: var(--bg-primary, #1f2937);
}

/* ============================================
   AVATAR COMPONENT
   ============================================ */

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    overflow: hidden;
    background: var(--bg-secondary, #f3f4f6);
}

.avatar--sm {
    width: 32px;
    height: 32px;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar__placeholder {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary, #6b7280);
}

/* Notification Badge */
.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
    color: white;
    background: #ef4444;
    border-radius: 9px;
}

.notification-btn {
    position: relative;
}

/* ============================================
   SEARCH DROPDOWN
   ============================================ */

.search-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    max-height: 400px;
    overflow-y: auto;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 50;
}

.search-dropdown__loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 1.5rem;
    color: #6b7280;
    font-size: 0.875rem;
}

.search-dropdown__error {
    padding: 1.5rem;
    text-align: center;
    color: #ef4444;
}

.search-dropdown__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    text-align: center;
    color: #6b7280;
}

.search-dropdown__empty svg {
    width: 40px;
    height: 40px;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.search-dropdown__results {
    padding: 0.5rem;
}

.search-dropdown__group {
    margin-bottom: 0.75rem;
}

.search-dropdown__group:last-child {
    margin-bottom: 0;
}

.search-dropdown__group-title {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.search-dropdown__group-items {
    display: flex;
    flex-direction: column;
}

.search-dropdown__item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    text-decoration: none;
    color: #111827;
    border-radius: 6px;
    transition: background-color 0.15s;
}

.search-dropdown__item:hover,
.search-dropdown__item.active {
    background: #f3f4f6;
}

.search-dropdown__item-image {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 4px;
    overflow: hidden;
    background: #f3f4f6;
}

.search-dropdown__item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.search-dropdown__item-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    color: #9ca3af;
}

.search-dropdown__item-icon svg {
    width: 100%;
    height: 100%;
}

.search-dropdown__item-content {
    flex: 1;
    min-width: 0;
}

.search-dropdown__item-title {
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.125rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-dropdown__item-excerpt {
    font-size: 0.75rem;
    color: #6b7280;
    margin-bottom: 0.125rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.search-dropdown__item-meta {
    font-size: 0.75rem;
    color: #9ca3af;
}

/* Dark mode */
[data-theme="dark"] .search-dropdown {
    background: #1f2937;
    border-color: #374151;
}

[data-theme="dark"] .search-dropdown__item {
    color: #f9fafb;
}

[data-theme="dark"] .search-dropdown__item:hover,
[data-theme="dark"] .search-dropdown__item.active {
    background: #374151;
}

[data-theme="dark"] .search-dropdown__item-image {
    background: #374151;
}

[data-theme="dark"] .search-dropdown__item-excerpt {
    color: #9ca3af;
}

[data-theme="dark"] .search-dropdown__item-meta {
    color: #6b7280;
}

[data-theme="dark"] .search-dropdown__empty {
    color: #9ca3af;
}

[data-theme="dark"] .search-dropdown__group-title {
    color: #9ca3af;
}

[data-theme="dark"] .search-dropdown__spinner {
    border-color: #374151;
    border-top-color: #6366f1;
}
@media (max-width: 768px) {
    .search-dropdown {
        max-height: 300px;
    }
    
    .search-dropdown__item-image {
        width: 40px;
        height: 40px;
    }
}

/* Search highlight */
mark {
    background: #fef3c7;
    color: inherit;
    padding: 0 0.125rem;
    border-radius: 2px;
    font-weight: 500;
}

[data-theme="dark"] mark {
    background: #78350f;
    color: #fef3c7;
}
