/**
 * 실시간 인기 검색어 페이지 스타일
 * Modern & Sleek Design
 */

/* Page Container */
.popular-keywords-page {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    min-height: calc(100vh - 200px);
    padding: 30px 0;
}

.pk-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Section */
.pk-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 30px;
    padding: 30px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(99, 102, 241, 0.3);
}

.pk-title {
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    margin: 0 0 10px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.pk-title i {
    color: #fff;
    animation: pulseGlow 1.5s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.1); }
}

.pk-subtitle {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.pk-time, .pk-total {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pk-total strong {
    font-size: 16px;
    color: #fff;
}

/* Period Filter */
.pk-filter {
    display: flex;
    gap: 8px;
    background: rgba(255, 255, 255, 0.15);
    padding: 6px;
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.pk-filter-btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
    background: transparent;
    border: none;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.pk-filter-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.2);
    text-decoration: none;
}

.pk-filter-btn.active {
    color: #6366f1;
    background: #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Content Wrapper */
.pk-content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Keywords Section */
.pk-keywords-section {
    background: #fff;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.pk-keywords-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 15px;
}

/* Keyword Item */
.pk-keyword-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 16px 20px;
    background: #f8fafc;
    border-radius: 12px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    cursor: pointer;
}

.pk-keyword-item:hover {
    background: #fff;
    border-color: #e2e8f0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.pk-keyword-item.selected {
    background: linear-gradient(135deg, #eef2ff 0%, #fdf4ff 100%);
    border-color: #6366f1;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.15);
}

/* Rank Badge */
.pk-rank {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: #e2e8f0;
    font-weight: 700;
    font-size: 16px;
    color: #64748b;
    flex-shrink: 0;
    position: relative;
}

.pk-rank.gold {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(251, 191, 36, 0.4);
}

.pk-rank.silver {
    background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(148, 163, 184, 0.4);
}

.pk-rank.bronze {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(249, 115, 22, 0.4);
}

.pk-rank i {
    font-size: 12px;
    position: absolute;
    top: -5px;
    right: -5px;
}

/* Keyword Info */
.pk-keyword-info {
    flex: 1;
    min-width: 0;
}

.pk-keyword-text {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    text-decoration: none;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pk-keyword-text:hover {
    color: #6366f1;
    text-decoration: none;
}

.pk-search-count {
    font-size: 12px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Chart Button */
.pk-keyword-actions {
    flex-shrink: 0;
}

.pk-chart-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pk-chart-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

/* Empty State */
.pk-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
}

.pk-empty i {
    font-size: 48px;
    margin-bottom: 15px;
    display: block;
}

.pk-empty p {
    font-size: 16px;
    margin: 0;
}

/* Pagination */
.pk-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 30px;
    padding-top: 30px;
    border-top: 1px solid #e2e8f0;
}

.pk-page-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 42px;
    padding: 0 15px;
    border-radius: 10px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
}

.pk-page-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
    text-decoration: none;
}

.pk-page-btn.active {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

/* Chart Section */
.pk-chart-section {
    background: #fff;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pk-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e2e8f0;
}

.pk-chart-title {
    font-size: 20px;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.pk-chart-title i {
    color: #6366f1;
}

.pk-chart-keyword {
    color: #ec4899;
    font-weight: 700;
}

.pk-chart-close {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pk-chart-close:hover {
    background: #fef2f2;
    color: #ef4444;
}

.pk-charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
}

.pk-chart-box {
    background: #f8fafc;
    border-radius: 16px;
    padding: 25px;
}

.pk-chart-box-title {
    font-size: 16px;
    font-weight: 600;
    color: #475569;
    margin: 0 0 20px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pk-chart-box-title i {
    color: #6366f1;
}

.pk-chart-wrapper {
    height: 300px;
    position: relative;
}

/* Responsive */
@media (max-width: 768px) {
    .popular-keywords-page {
        padding: 15px 0;
    }

    .pk-container {
        padding: 0 15px;
    }

    .pk-header {
        padding: 20px;
        flex-direction: column;
        align-items: stretch;
    }

    .pk-title {
        font-size: 22px;
    }

    .pk-filter {
        width: 100%;
        justify-content: center;
    }

    .pk-filter-btn {
        padding: 8px 14px;
        font-size: 13px;
    }

    .pk-keywords-section {
        padding: 20px 15px;
    }

    .pk-keywords-grid {
        grid-template-columns: 1fr;
    }

    .pk-keyword-item {
        padding: 14px 16px;
    }

    .pk-charts-container {
        grid-template-columns: 1fr;
    }

    .pk-chart-wrapper {
        height: 250px;
    }
}

/* ===== 실시간 인기 검색어 드롭다운 스타일 ===== */
.popular-keywords-btn-wrapper {
    position: relative;
    display: inline-block;
}

.popular-keywords-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: #fff !important;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.popular-keywords-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(249, 115, 22, 0.4);
}

.popular-keywords-btn i.fa-line-chart {
    color: #fff;
    animation: pulseGlow 1.5s ease-in-out infinite;
}

/* Dropdown */
.pk-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 380px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.pk-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.pk-dropdown::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 20px;
    width: 16px;
    height: 16px;
    background: #fff;
    transform: rotate(45deg);
    border-radius: 3px;
}

.pk-dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 16px 16px 0 0;
}

.pk-dropdown-title {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pk-dropdown-title i.fa-line-chart {
    color: #fff;
}

.pk-dropdown-time {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
}

.pk-dropdown-list {
    list-style: none;
    margin: 0;
    padding: 10px 0;
    max-height: 400px;
    overflow-y: auto;
}

.pk-dropdown-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    transition: all 0.2s ease;
}

.pk-dropdown-item:hover {
    background: #f8fafc;
}

.pk-dropdown-rank {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    margin-right: 12px;
    flex-shrink: 0;
    background: #e2e8f0;
    color: #64748b;
}

.pk-dropdown-item:nth-child(1) .pk-dropdown-rank {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #fff;
}

.pk-dropdown-item:nth-child(2) .pk-dropdown-rank {
    background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
    color: #fff;
}

.pk-dropdown-item:nth-child(3) .pk-dropdown-rank {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: #fff;
}

.pk-dropdown-link {
    flex: 1;
    color: #1e293b;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pk-dropdown-link:hover {
    color: #6366f1;
    text-decoration: none;
}

.pk-dropdown-count {
    font-size: 12px;
    color: #94a3b8;
    margin-left: 10px;
}

.pk-dropdown-footer {
    padding: 15px 20px;
    border-top: 1px solid #e2e8f0;
    text-align: center;
}

.pk-dropdown-more {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff !important;
    font-size: 14px;
    font-weight: 600;
    border-radius: 10px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.pk-dropdown-more:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
    text-decoration: none;
    color: #fff !important;
}

/* Header Search Integration */
.header-search .input-group-btn {
    display: flex;
    align-items: center;
    gap: 4px;
}

.header-search .popular-keywords-btn-wrapper {
    margin-left: 4px;
}

.header-search .popular-keywords-btn {
    height: 34px;
    padding: 0 12px;
    font-size: 12px;
}

/* Mobile Search Integration */
.m_fsearch {
    display: flex;
    align-items: center;
    gap: 5px;
}

.m_fsearch .popular-keywords-btn-wrapper {
    flex-shrink: 0;
}

.m_fsearch .popular-keywords-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
    border-radius: 6px;
}

/* Pulse Animation for New/Hot Keywords */
.pk-keyword-item.hot::after {
    content: 'HOT';
    position: absolute;
    top: -8px;
    right: -8px;
    padding: 2px 6px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 4px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Loading Skeleton */
.pk-skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: skeleton 1.5s ease-in-out infinite;
    border-radius: 8px;
}

@keyframes skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Mobile Dropdown */
@media (max-width: 768px) {
    .pk-dropdown {
        position: fixed;
        top: auto !important;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 70vh;
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
    }

    .pk-dropdown.show {
        transform: translateY(0);
    }

    .pk-dropdown::before {
        display: none;
    }

    .pk-dropdown-list {
        max-height: calc(70vh - 150px);
    }

    .popular-keywords-btn span {
        display: none;
    }

    .popular-keywords-btn {
        padding: 8px 12px;
    }

    /* Mobile backdrop */
    .pk-dropdown-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9998;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    .pk-dropdown-backdrop.show {
        opacity: 1;
        visibility: visible;
    }
}

/* Stats Cards for Page */
.pk-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.pk-stat-card {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.pk-stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.pk-stat-icon {
    width: 50px;
    height: 50px;
    margin: 0 auto 15px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.pk-stat-icon.purple {
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
}

.pk-stat-icon.pink {
    background: rgba(236, 72, 153, 0.1);
    color: #ec4899;
}

.pk-stat-icon.orange {
    background: rgba(249, 115, 22, 0.1);
    color: #f97316;
}

.pk-stat-icon.green {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.pk-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 5px;
}

.pk-stat-label {
    font-size: 14px;
    color: #64748b;
}

/* ===== 모바일 검색창 버튼 레이아웃 개선 ===== */
@media (max-width: 768px) {
    /* 모바일 검색 form 레이아웃 */
    .m_fsearch form {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
    }

    /* 검색 입력창 - 버튼 공간 확보를 위해 너비 조정 */
    .m_fsearch .input_text,
    .m_fsearch input[name="stx"] {
        flex: 1;
        width: auto !important;
        min-width: 0;
        max-width: calc(100% - 90px) !important;
    }

    /* 검색 버튼 (돋보기) - 고정 위치 */
    .m_fsearch button[type="submit"] {
        position: relative !important;
        right: auto !important;
        top: auto !important;
        transform: none !important;
        flex-shrink: 0;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* 인기 검색어 버튼 wrapper - 고정 위치 */
    .m_fsearch .popular-keywords-btn-wrapper {
        position: relative !important;
        display: flex !important;
        flex-shrink: 0;
    }

    /* 인기 검색어 버튼 - 돋보기와 같은 크기 */
    .m_fsearch .popular-keywords-btn {
        width: 36px !important;
        height: 36px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
}

/* 더 작은 모바일 (375px 이하) */
@media (max-width: 375px) {
    .m_fsearch .input_text,
    .m_fsearch input[name="stx"] {
        max-width: calc(100% - 80px) !important;
    }

    .m_fsearch button[type="submit"],
    .m_fsearch .popular-keywords-btn {
        width: 32px !important;
        height: 32px !important;
    }
}

/* ===== 모바일 검색창 버튼 위치 강제 재배치 (2026-01-26 v2) ===== */
@media (max-width: 768px) {
    /* 인기 검색어 버튼이 검색창 밖에 위치하도록 강제 */
    .m_fsearch .popular-keywords-btn-wrapper {
        position: static !important;
        right: auto !important;
        top: auto !important;
        flex: 0 0 auto !important;
        margin-left: 0 !important;
    }

    .m_fsearch .popular-keywords-btn {
        width: 38px !important;
        height: 38px !important;
        padding: 0 !important;
        border-radius: 50% !important;
    }

    /* 드롭다운 위치 조정 */
    .m_fsearch .pk-dropdown {
        right: 0 !important;
        left: auto !important;
        top: calc(100% + 8px) !important;
    }
}
