/* ============================================
   HEADER.CSS - Header Styles (FINAL POLISH - PREMIUM)
   ============================================ */

/* ============================================
   MAIN HEADER
   ============================================ */

.main-header {
    background: var(--primary);
    color: white;
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.main-header.scrolled {
    box-shadow: 0 4px 40px rgba(0, 0, 0, 0.25);
    padding: 8px 0;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: rgba(13, 27, 42, 0.92);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.main-header.scrolled .logo-text {
    font-size: 1rem;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 56px;
    animation: headerFadeIn 0.6s ease;
}

@keyframes headerFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ============================================
   HEADER LEFT - Logo + Back Button
   ============================================ */

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.back-btn {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.back-btn.visible {
    display: flex;
    animation: btnPop 0.3s ease;
}

@keyframes btnPop {
    from {
        opacity: 0;
        transform: scale(0.7) rotate(-30deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.08);
    box-shadow: 0 4px 20px rgba(255, 255, 255, 0.08);
}

.back-btn:active {
    transform: scale(0.92);
}

.back-btn:focus-visible {
    outline: 2px solid var(--secondary);
    outline-offset: 2px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: white;
    font-weight: 700;
    font-size: 1.2rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.logo::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--secondary), var(--secondary-light));
    transition: width 0.3s ease;
}

.logo:hover::after {
    width: 100%;
}

.logo:hover {
    transform: scale(1.03);
}

.logo:focus-visible {
    outline: 2px solid var(--secondary);
    outline-offset: 2px;
    border-radius: 4px;
}

.logo img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid rgba(255, 255, 255, 0.08);
}

.logo img:hover {
    transform: rotate(-8deg) scale(1.08);
    border-color: var(--secondary);
}

.logo .logo-text {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    white-space: nowrap;
    transition: all 0.3s ease;
}

.logo .logo-text span {
    color: var(--secondary);
}

/* ============================================
   HEADER CENTER - Search (PREMIUM)
   ============================================ */

.header-center {
    flex: 1;
    max-width: 480px;
    min-width: 140px;
}

.search-wrapper {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 30px;
    padding: 0 16px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.search-wrapper::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 30px;
    padding: 1px;
    background: linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.search-wrapper:focus-within {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.04);
    transform: scale(1.02);
}

.search-wrapper .search-icon {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.4);
    margin-right: 10px;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.search-wrapper:focus-within .search-icon {
    color: var(--secondary);
}

.search-wrapper input {
    flex: 1;
    padding: 10px 0;
    border: none;
    outline: none;
    font-size: 14px;
    background: transparent;
    color: white;
    font-family: var(--font-family);
    min-height: 38px;
    transition: all 0.3s ease;
    width: 100%;
}

.search-wrapper input::placeholder {
    color: rgba(255, 255, 255, 0.35);
    font-size: 13px;
    transition: all 0.3s ease;
}

.search-wrapper:focus-within input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.search-wrapper input::selection {
    background: var(--secondary);
    color: var(--primary);
}

/* ===== SEARCH CLEAR BUTTON - INSIDE SEARCH BOX ===== */
.search-clear {
    display: none;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.25);
    cursor: pointer;
    font-size: 16px;
    padding: 4px 6px;
    transition: all 0.3s ease;
    flex-shrink: 0;
    border-radius: 50%;
    margin-left: 4px;
    line-height: 1;
    position: relative;
    z-index: 2;
}

.search-clear:hover {
    color: white;
    transform: scale(1.15);
    background: rgba(255, 255, 255, 0.08);
}

.search-clear:focus-visible {
    outline: 2px solid var(--secondary);
    outline-offset: 2px;
}

.search-wrapper.has-text .search-clear {
    display: block;
    animation: fadeIn 0.3s ease;
}

.search-wrapper:focus-within .search-clear {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================
   HEADER RIGHT - Actions
   ============================================ */

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.header-btn {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.04);
    position: relative;
}

.header-btn::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 50%;
    padding: 1px;
    background: linear-gradient(135deg, rgba(255,255,255,0.08), transparent);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.header-btn:hover::after {
    opacity: 1;
}

.header-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.header-btn:active {
    transform: scale(0.92);
}

.header-btn:focus-visible {
    outline: 2px solid var(--secondary);
    outline-offset: 2px;
}

.header-btn.menu-toggle.active {
    background: rgba(255, 255, 255, 0.15);
    transform: rotate(90deg);
    border-color: rgba(255, 255, 255, 0.1);
}

.header-btn.dark-toggle {
    font-size: 16px;
}

.header-btn.dark-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.08);
}

/* ============================================
   SIDEBAR - Premium
   ============================================ */

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

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

.sidebar {
    position: fixed;
    top: 0;
    left: -320px;
    width: 300px;
    height: 100%;
    background: var(--bg-white);
    z-index: 9999;
    box-shadow: 8px 0 50px rgba(0, 0, 0, 0.12);
    transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    left: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    flex-shrink: 0;
}

.sidebar-header .sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
    font-weight: 700;
    font-size: 1.15rem;
}

.sidebar-header .sidebar-logo img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    transition: all 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.08);
}

.sidebar-header .sidebar-logo img:hover {
    transform: rotate(-5deg) scale(1.05);
    border-color: var(--secondary);
}

.sidebar-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
    box-shadow: 0 4px 20px rgba(255, 255, 255, 0.04);
}

.sidebar-close:focus-visible {
    outline: 2px solid var(--secondary);
    outline-offset: 2px;
}

.sidebar-nav {
    padding: 16px 14px;
    flex: 1;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-dark);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 2px;
    animation: slideIn 0.4s ease forwards;
    opacity: 0;
    position: relative;
}

.sidebar-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 3px;
    height: 60%;
    background: linear-gradient(180deg, var(--secondary), var(--secondary-light));
    border-radius: 0 3px 3px 0;
    transition: all 0.3s ease;
}

.sidebar-link:hover::before,
.sidebar-link.active::before {
    transform: translateY(-50%) scaleY(1);
}

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

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

.sidebar-link:hover {
    background: rgba(0, 0, 0, 0.04);
    transform: translateX(6px);
}

.sidebar-link.active {
    background: rgba(0, 0, 0, 0.06);
    color: var(--primary);
    font-weight: 600;
}

.sidebar-link.active .link-icon {
    color: var(--secondary);
}

.sidebar-link .link-icon {
    font-size: 20px;
    width: 30px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-link .link-text {
    flex: 1;
}

.sidebar-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 12px 16px;
    animation: slideIn 0.4s ease forwards;
    opacity: 0;
    animation-delay: 0.45s;
}

/* ============================================
   DARK MODE - Header (Premium Glass)
   ============================================ */

body.dark-mode .main-header {
    background: rgba(8, 8, 15, 0.75) !important;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
}

body.dark-mode .main-header.scrolled {
    background: rgba(8, 8, 15, 0.9) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 4px 40px rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

body.dark-mode .logo .logo-text {
    color: #e0e0e0;
}

body.dark-mode .logo .logo-text span {
    color: #818cf8;
}

body.dark-mode .back-btn {
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

body.dark-mode .back-btn:hover {
    background: rgba(255, 255, 255, 0.08) !important;
}

body.dark-mode .header-btn {
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

body.dark-mode .header-btn:hover {
    background: rgba(255, 255, 255, 0.08) !important;
}

body.dark-mode .header-btn.menu-toggle.active {
    background: rgba(255, 255, 255, 0.08) !important;
}

body.dark-mode .search-wrapper {
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

body.dark-mode .search-wrapper:focus-within {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(129, 140, 248, 0.2) !important;
    box-shadow: 0 0 0 4px rgba(129, 140, 248, 0.04) !important;
}

body.dark-mode .search-wrapper input {
    color: #e0e0e0;
}

body.dark-mode .search-wrapper input::placeholder {
    color: #8888aa;
}

body.dark-mode .search-wrapper .search-icon {
    color: #8888aa;
}

body.dark-mode .search-wrapper:focus-within .search-icon {
    color: #818cf8;
}

body.dark-mode .search-clear {
    color: rgba(255, 255, 255, 0.15);
}

body.dark-mode .search-clear:hover {
    color: #e0e0e0;
    background: rgba(255, 255, 255, 0.04);
}

body.dark-mode .sidebar {
    background: rgba(17, 17, 34, 0.9) !important;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid rgba(255, 255, 255, 0.03);
}

body.dark-mode .sidebar-header {
    background: rgba(13, 27, 42, 0.9) !important;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom-color: rgba(255, 255, 255, 0.03);
}

body.dark-mode .sidebar-link {
    color: #e0e0e0;
}

body.dark-mode .sidebar-link:hover {
    background: rgba(255, 255, 255, 0.04);
}

body.dark-mode .sidebar-link.active {
    background: rgba(129, 140, 248, 0.08);
    color: #818cf8;
}

body.dark-mode .sidebar-link.active .link-icon {
    color: #818cf8;
}

body.dark-mode .sidebar-divider {
    border-top-color: rgba(255, 255, 255, 0.03);
}

body.dark-mode .sidebar-overlay {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

body.dark-mode .sidebar-close {
    background: rgba(255, 255, 255, 0.04);
}

body.dark-mode .sidebar-close:hover {
    background: rgba(255, 255, 255, 0.08);
}

body.dark-mode .back-btn:focus-visible,
body.dark-mode .logo:focus-visible,
body.dark-mode .header-btn:focus-visible,
body.dark-mode .sidebar-close:focus-visible,
body.dark-mode .search-clear:focus-visible {
    outline-color: #818cf8;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
    .header-center {
        max-width: 380px;
    }
}

@media (max-width: 768px) {
    .main-header {
        padding: 8px 0;
    }
    
    .header-row {
        min-height: 46px;
        gap: 10px;
    }
    
    .logo .logo-text {
        font-size: 0.95rem;
    }
    
    .logo img {
        width: 32px;
        height: 32px;
    }
    
    .header-btn {
        width: 34px;
        height: 34px;
        font-size: 16px;
    }
    
    .back-btn {
        width: 34px;
        height: 34px;
        font-size: 16px;
    }
    
    .search-wrapper input {
        font-size: 13px;
        min-height: 32px;
    }
    
    .search-wrapper input::placeholder {
        font-size: 12px;
    }
    
    .search-wrapper .search-icon {
        font-size: 14px;
    }
    
    .header-center {
        max-width: 280px;
        min-width: 100px;
    }
    
    .sidebar {
        width: 280px;
        left: -280px;
    }
    
    .sidebar-link {
        padding: 10px 14px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .header-row {
        gap: 8px;
        min-height: 40px;
    }
    
    .logo .logo-text {
        font-size: 0.8rem;
    }
    
    .logo img {
        width: 28px;
        height: 28px;
    }
    
    .header-btn {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
    
    .back-btn {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
    
    .search-wrapper {
        padding: 0 10px;
    }
    
    .search-wrapper input {
        font-size: 12px;
        min-height: 28px;
        padding: 6px 0;
    }
    
    .search-wrapper input::placeholder {
        font-size: 11px;
    }
    
    .search-wrapper .search-icon {
        font-size: 12px;
        margin-right: 6px;
    }
    
    .header-center {
        max-width: 140px;
        min-width: 80px;
    }
    
    .sidebar {
        width: 260px;
        left: -260px;
    }
    
    .sidebar-header {
        padding: 16px 18px;
    }
    
    .sidebar-header .sidebar-logo {
        font-size: 0.95rem;
    }
    
    .sidebar-link {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .sidebar-link .link-icon {
        font-size: 16px;
        width: 26px;
    }
}

/* ============================================
   REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .main-header,
    .header-btn,
    .back-btn,
    .logo,
    .sidebar,
    .sidebar-link {
        transition: none !important;
    }
    
    .sidebar-link {
        animation: none !important;
        opacity: 1 !important;
    }
    
    .sidebar-divider {
        animation: none !important;
        opacity: 1 !important;
    }
    
    .header-row {
        animation: none !important;
    }
    
    .back-btn.visible {
        animation: none !important;
    }
    
    .search-clear {
        animation: none !important;
    }
}

/* ============================================
   PRINT
   ============================================ */

@media print {
    .main-header {
        display: none !important;
    }
}