@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --secondary: #8b5cf6;
    --accent: #ec4899;
    --dark: #100f0f;
    --dark-light: #1e293b;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --glass: rgba(255, 255, 255, 0.05);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', sans-serif;
    background: var(--dark);
    color: var(--text);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;

}

/* Header */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(24, 24, 24, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    transition: all 0.3s ease;
}

header.scrolled {
    background: rgba(15, 23, 42, 0.95);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

.nav-container {
    max-width: 2200px;
    margin: 0 auto;
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 40px;
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    position: relative;
    z-index: 2;
}

.logo-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.logo-icon::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transform: rotate(45deg);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%) rotate(45deg); }
    100% { transform: translateX(100%) rotate(45deg); }
}

.logo-icon .logo-img {
    width: 24px;
    height: 24px;
    position: relative;
    z-index: 1;
    filter: brightness(0) invert(1);
}

.logo:hover .logo-icon {
    transform: scale(1.1) rotate(-5deg);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.4);
}

.logo-text {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--primary), var(--secondary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    transition: all 0.3s ease;
}

/* Search */
.search-container {
    flex: 1;
    max-width: 500px;
    position: relative;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-input {
    width: 100%;
    padding: 14px 50px 14px 20px;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 16px;
    color: var(--text);
    font-size: 14px;
    font-weight: 400;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.search-input::placeholder {
    color: var(--text-secondary);
}

.search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.search-btn:hover {
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

/* Desktop Navigation */
.nav-menu.desktop-only {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-item {
    padding: 10px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: 12px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.nav-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
}

.nav-item:hover {
    color: white;
}

.nav-item:hover::before {
    opacity: 0.15;
}

/* User Actions */
.user-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Theme Toggle */
.theme-toggle {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--glass);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.search-wrapper {
    position: relative;
    width: 44px;        /* 항상 고정 */
    height: 44px;
    flex-shrink: 0;     /* flex에서 줄어들지 않게 */
}

.search-theme {
    position: absolute;
    top: 0;
    right: 0;           /* 오른쪽으로 확장 */
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--glass);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    z-index: 10;
}

.search-theme:hover {
    width: 160px;                   /* 호버 시 너비 확장 (원하는 만큼 조정) */
    background: rgba(99, 102, 241, 0.15);  /* 약간 보라 톤 강조 */
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

.search-icon {
    width: 20px;
    height: 20px;
    transition: all 0.4s ease;
    position: absolute;
    left: 12px;
    z-index: 2;
}

.search-theme:hover .search-icon {
    left: 16px;                     /* 호버 시 아이콘 살짝 이동 */
}

.search-input {
    position: absolute;
    left: 44px;                     /* 아이콘 오른쪽부터 시작 */
    width: 0;                       /* 기본 숨김 */
    height: 100%;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 14px;
    padding: 0 16px 0 0;
    outline: none;
    opacity: 0;
    transition: all 0.4s ease;
    cursor: pointer;
}

.search-theme:hover .search-input {
    width: calc(100% - 60px);       /* 아이콘 공간 제외하고 확장 */
    opacity: 1;
    left: 50px;                     /* 아이콘 옆으로 자연스럽게 */
}

.search-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

/* 클릭 시에도 검색 페이지로 이동 */
.search-input {
    pointer-events: auto;
}
.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
    transform: rotate(180deg) scale(1.05);
}

/* User Profile */
.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px 8px 8px;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.user-profile:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.profile-img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: cover;
    border: 2px solid var(--border);
}

.username {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.user-profile-link {
    text-decoration: none;
    color: inherit;
}

/* Mobile Menu Toggle (Hamburger) */
.mobile-menu-toggle {
    display: none;
    width: 44px;
    height: 44px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1001;
}

.hamburger-line {
    width: 20px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.mobile-menu-toggle:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
}

.mobile-menu-toggle.active .hamburger-line:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.mobile-menu-toggle.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Mobile Side Menu */
.mobile-side-menu {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 9999;
    visibility: hidden;
    opacity: 0;
        pointer-events: none;
    transition: all 0.3s ease;
}

.mobile-side-menu.active {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.mobile-menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.mobile-menu-content {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 280px;
    max-width: 85%;
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(20px);
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}

.mobile-side-menu.active .mobile-menu-content {
    transform: translateX(0);
}

.mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.menu-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.close-menu-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--glass);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.close-menu-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
}

/* Mobile User Section */
.mobile-user-section {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.mobile-user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.mobile-user-profile:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
}

.mobile-profile-img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
}

.mobile-user-info {
    flex: 1;
}

.mobile-username {
    font-size: 16px;
    font-weight: 700;
    color: white;
    margin-bottom: 4px;
}

.mobile-profile-link {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

.mobile-nav {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mobile-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.3s ease;
    cursor: pointer;
}

.mobile-nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
    transform: translateX(-4px);
}

.nav-icon {
    font-size: 20px;
}

.mobile-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 12px 0;
}

.mobile-logout-btn {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
    color: var(--danger);
}

.mobile-logout-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--danger);
}

/* Light Mode */
body.light-mode {
    --dark: #ffffff;
    --dark-light: #f8fafc;
    --text: #0f172a;
    --text-secondary: #475569;
    --border: rgba(0, 0, 0, 0.1);
    --glass: rgba(0, 0, 0, 0.03);
}

body.light-mode::before {
    background:
        radial-gradient(circle at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 40% 90%, rgba(236, 72, 153, 0.05) 0%, transparent 50%);
}

body.light-mode header {
    background: rgba(255, 255, 255, 0.8);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

body.light-mode header.scrolled {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

body.light-mode .logo-icon .logo-img {
    filter: none;
}

body.light-mode .mobile-menu-content {
    background: rgba(255, 255, 255, 0.98);
}

body.light-mode .mobile-menu-overlay {
    background: rgba(0, 0, 0, 0.5);
}

@media (max-width: 1359px) {
    .nav-menu.desktop-only {
        display: none !important;
    }
     /* 작가 센터 링크 완전 숨김 */
    .nav-item[href="/book/author-dashboard/"] {
        display: none !important;
    }

    .user-profile {
        display: none; /* 모바일에서 프로필 전체 숨김 */
    }
    .mobile-menu-toggle {
        display: flex;
    }

    .user-profile .username {
        display: none;
    }

    .user-profile {
        padding: 8px;
    }

    .search-container {
        max-width: 400px;
    }
}

/* Responsive */
@media (max-width: 1024px) {
    .nav-menu.desktop-only {
        display: none !important;
    }

    /* 작가 센터 링크 완전 숨김 */
    .nav-item[href="/book/author-dashboard/"] {
        display: none !important;
    }

    .user-profile {
        display: none; /* 모바일에서 프로필 전체 숨김 */
    }
    .mobile-menu-toggle {
        display: flex;
    }

    .user-profile .username {
        display: none;
    }

    .user-profile {
        padding: 8px;
    }

    .search-container {
        max-width: 400px;
    }
}

@media (max-width: 768px) {
    .nav-container {
        padding: 14px 20px;
        gap: 12px;
    }

    .search-container {
        flex: 1;
        max-width: none;
    }

    .logo-text {
        font-size: 20px;
    }
    .user-profile .username {
        display: none;
    }
    .theme-toggle {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .nav-container {
        padding: 12px 16px;
        gap: 8px;
    }
    .user-profile .username {
        display: none;
    }
    .logo-text {
        display: none;
    }

    .logo-icon {
        width: 36px;
        height: 36px;
    }

    .logo-icon .logo-img {
        width: 20px;
        height: 20px;
    }

    .search-input {
        padding: 12px 45px 12px 16px;
        font-size: 13px;
    }

    .theme-toggle,
    .mobile-menu-toggle {
        width: 36px;
        height: 36px;
    }

    .hamburger-line {
        width: 18px;
    }

    .profile-img {
        width: 28px;
        height: 28px;
    }
}