/* Custom CSS for Morning US Market */
* {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html {
    scroll-behavior: smooth;
}

body {
    overflow-x: hidden;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Navigation enhancements */
nav {
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

nav.scrolled {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
}

/* Hero section animations */
.hero-fade-in {
    animation: fadeInUp 0.8s ease-out;
}

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

/* Market cards hover effects */
.market-card {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.market-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.market-card:hover::before {
    left: 100%;
}

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

/* Sector buttons */
.sector-btn {
    transition: all 0.3s ease;
    position: relative;
}

.sector-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.sector-btn.active {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.sector-btn.active i {
    color: white !important;
}

/* News cards */
.news-card {
    transition: all 0.3s ease;
    background: white;
    border-radius: 16px;
    padding: 24px;
    border: 1px solid #e5e7eb;
    position: relative;
    overflow: hidden;
}

.news-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #ef4444, #f97316, #eab308);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.news-card:hover::before {
    transform: scaleX(1);
}

.news-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
    border-color: transparent;
}

.news-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.5;
    margin-bottom: 12px;
    color: #111827;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.news-summary {
    font-size: 14px;
    line-height: 1.6;
    color: #6b7280;
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.news-meta {
    display: flex;
    justify-content: between;
    align-items: center;
    font-size: 12px;
    color: #9ca3af;
}

.news-source {
    font-weight: 500;
    color: #ef4444;
}

.sentiment-positive {
    color: #059669;
    background: #d1fae5;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.sentiment-negative {
    color: #dc2626;
    background: #fee2e2;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.sentiment-neutral {
    color: #6b7280;
    background: #f3f4f6;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

/* Loading animations */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #ef4444;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Feature cards */
.feature-card {
    transition: all 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-2px);
}

/* Gradient backgrounds */
.gradient-bg {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Responsive design improvements */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2.5rem !important;
    }
    
    .nav-mobile {
        display: block;
    }
    
    .nav-desktop {
        display: none;
    }
}

/* Search bar styling */
.search-container {
    position: relative;
    max-width: 400px;
    margin: 0 auto 2rem auto;
}

.search-input {
    width: 100%;
    padding: 12px 20px 12px 45px;
    border: 2px solid #e5e7eb;
    border-radius: 25px;
    background: white;
    font-size: 14px;
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
}

/* Tags */
.tag {
    display: inline-block;
    padding: 4px 10px;
    background: #f3f4f6;
    color: #6b7280;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    margin: 2px;
}

.tag.ai { background: #dbeafe; color: #1e40af; }
.tag.defense { background: #dcfce7; color: #166534; }
.tag.ev { background: #f3e8ff; color: #7c2d92; }
.tag.semiconductor { background: #fed7aa; color: #c2410c; }
.tag.energy { background: #fef3c7; color: #92400e; }
.tag.biotech { background: #fecaca; color: #b91c1c; }
.tag.bigtech { background: #e0e7ff; color: #3730a3; }

/* Animations for section reveals */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s ease;
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* View counter */
.view-counter {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #9ca3af;
    font-size: 12px;
}

.view-counter i {
    font-size: 10px;
}

/* Dark mode support (future enhancement) */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #0f172a;
        --bg-secondary: #1e293b;
        --text-primary: #f1f5f9;
        --text-secondary: #cbd5e1;
        --border-color: #334155;
    }
}

/* Period selection buttons */
.period-btn {
    padding: 8px 16px;
    border: 2px solid #e5e7eb;
    background: white;
    color: #6b7280;
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.period-btn:hover {
    border-color: #ef4444;
    color: #ef4444;
}

.period-btn.active {
    background: #ef4444;
    border-color: #ef4444;
    color: white;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

/* Market index cards with click effects */
.market-index-card {
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    background: white;
    border: 1px solid #e5e7eb;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.market-index-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.1), transparent);
    transition: left 0.5s ease;
}

.market-index-card:hover::before {
    left: 100%;
}

.market-index-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
    border-color: #3b82f6;
}

.market-index-card:active {
    transform: translateY(-2px);
}

/* Special grid layout for 5 cards */
#market-indices {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

@media (min-width: 768px) {
    #market-indices {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    #market-indices {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Responsive adjustments for 5 cards */
@media (min-width: 1024px) {
    .market-index-card:nth-child(4) {
        grid-column: 1;
    }
    
    .market-index-card:nth-child(5) {
        grid-column: 2;
    }
}

/* News page styles */
.sector-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border: 2px solid #e5e7eb;
    background: white;
    border-radius: 12px;
    transition: all 0.3s ease;
    cursor: pointer;
    min-height: 80px;
}

.sector-nav-btn:hover {
    border-color: #ef4444;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.sector-nav-btn.active {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border-color: #ef4444;
    color: white;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.sector-nav-btn.active i {
    color: white !important;
}

.news-article-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 24px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.news-article-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #ef4444, #f97316);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.news-article-card:hover::before {
    transform: scaleX(1);
}

.news-article-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    border-color: transparent;
}

/* Korean-optimized news article styles */
.news-article-card.korean-optimized {
    position: relative;
    padding: 24px 28px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.news-article-card.korean-optimized:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: #3b82f6;
}

/* 순위 배지 */
.ranking-badge {
    position: absolute;
    top: 16px;
    right: 20px;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.rank-number {
    color: white;
    font-weight: bold;
    font-size: 14px;
}

/* 기사 제목 한글 최적화 */
.article-title {
    line-height: 1.4;
    word-break: keep-all;
    overflow-wrap: break-word;
    font-family: 'Inter', 'Noto Sans KR', sans-serif;
    letter-spacing: -0.025em;
}

/* 한글 본문 최적화 */
.line-height-korean {
    line-height: 1.7;
    word-break: keep-all;
    overflow-wrap: break-word;
    letter-spacing: -0.01em;
}

/* 언론사 배지 */
.publisher-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 500;
    font-size: 11px;
}

.publisher-badge.hankyung { background: #1e40af; color: white; }
.publisher-badge.maeil { background: #059669; color: white; }
.publisher-badge.chosun { background: #dc2626; color: white; }
.publisher-badge.etnews { background: #7c3aed; color: white; }
.publisher-badge.sedaily { background: #ea580c; color: white; }
.publisher-badge.news1 { background: #0891b2; color: white; }
.publisher-badge.yonhap { background: #1f2937; color: white; }
.publisher-badge.defense { background: #166534; color: white; }
.publisher-badge.kookbang { background: #92400e; color: white; }
.publisher-badge.auto { background: #7c2d92; color: white; }
.publisher-badge.mt { background: #b91c1c; color: white; }
.publisher-badge.edaily { background: #0d9488; color: white; }
.publisher-badge.carglobal { background: #4338ca; color: white; }
.publisher-badge.paxnet { background: #be185d; color: white; }
.publisher-badge.inews24 { background: #0369a1; color: white; }
.publisher-badge.default { background: #6b7280; color: white; }

/* 감성 분석 표시 */
.sentiment-indicator {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

/* 카테고리 태그 */
.category-tag {
    display: inline-block;
    padding: 2px 6px;
    background: #f3f4f6;
    color: #6b7280;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 500;
    margin-left: 4px;
}

/* 원문 보기 버튼 */
.read-more-btn {
    transition: all 0.2s ease;
}

.read-more-btn:hover {
    transform: translateX(2px);
}

/* 조회수 표시 강화 */
.view-count {
    background: #f8fafc;
    padding: 2px 6px;
    border-radius: 6px;
    color: #64748b;
}

/* 애니메이션 */
.news-article-card.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s ease;
}

.news-article-card.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* Korean-optimized search */
.korean-search {
    font-family: 'Inter', 'Noto Sans KR', sans-serif;
    letter-spacing: -0.01em;
}

.search-clear-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: #e5e7eb;
    border: none;
    border-radius: 50%;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    transition: all 0.2s ease;
}

.search-clear-btn:hover {
    background: #dc2626;
    color: white;
}

.search-suggestions {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.suggestion-tag {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    color: #374151;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.suggestion-tag:hover {
    background: #ef4444;
    border-color: #ef4444;
    color: white;
}

/* Search stats styling */
.search-stats {
    background: #dbeafe;
    padding: 2px 8px;
    border-radius: 12px;
    color: #1e40af !important;
}

.sector-stats {
    background: #f3f4f6;
    padding: 2px 8px;
    border-radius: 12px;
}

/* Toast message styling */
.toast-message {
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* 반응형 조정 */
@media (max-width: 768px) {
    .news-article-card.korean-optimized {
        padding: 20px;
    }
    
    .ranking-badge {
        width: 28px;
        height: 28px;
        top: 12px;
        right: 16px;
    }
    
    .rank-number {
        font-size: 12px;
    }
    
    .article-title {
        font-size: 16px;
        margin-bottom: 12px;
    }
    
    .article-actions {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    
    .korean-search {
        font-size: 16px; /* iOS에서 줌 방지 */
    }
    
    .search-suggestions {
        margin-top: 8px;
    }
    
    .suggestion-tag {
        font-size: 11px;
        padding: 3px 6px;
    }
}

/* Chart container */
#indexChart {
    width: 100% !important;
    height: 100% !important;
}

/* Statistics cards */
.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-label {
    color: #6b7280;
    font-size: 14px;
}

.stat-value {
    font-weight: 600;
    font-size: 14px;
}

/* Related news items */
.news-item {
    padding: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.news-item:hover {
    border-color: #ef4444;
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.news-item h5 {
    font-weight: 600;
    margin-bottom: 8px;
    color: #111827;
    line-height: 1.4;
}

.news-item p {
    color: #6b7280;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 8px;
}

.news-item .news-meta {
    font-size: 12px;
    color: #9ca3af;
}

/* 🌟 Top Picks Styles */
.top-pick-item {
    transition: all 0.3s ease;
    border: 1px solid #e5e7eb;
}

.top-pick-item:hover {
    border-color: #ef4444;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.1);
    transform: translateX(2px);
}

.ranking-badge-small {
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.sticky {
    position: -webkit-sticky;
    position: sticky;
}

/* Top picks loading animation */
.loading {
    width: 24px;
    height: 24px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #ef4444;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Top picks responsive adjustments */
@media (max-width: 1024px) {
    /* Stack hero content vertically on smaller screens */
    .hero-section-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .top-picks-container {
        position: static !important;
        max-width: 500px;
        margin: 0 auto;
    }
}

@media (max-width: 768px) {
    .top-pick-item {
        padding: 12px;
    }
    
    .ranking-badge-small {
        width: 18px;
        height: 18px;
        font-size: 10px;
    }
    
    .line-clamp-2 {
        -webkit-line-clamp: 3;
    }
}

/* Print styles */
@media print {
    nav, footer {
        display: none;
    }
    
    .news-card {
        break-inside: avoid;
        margin-bottom: 1rem;
    }
    
    .top-picks-container {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}