/* 메인 스타일시트 - 유튜브 모니터링 대시보드 */
:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --accent-color: #f093fb;
    --text-primary: #333;
    --text-secondary: #666;
    --text-light: #999;
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f5f5f5;
    --border-color: #e0e0e0;
    --shadow-light: 0 2px 10px rgba(0,0,0,0.1);
    --shadow-medium: 0 4px 20px rgba(0,0,0,0.15);
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --transition: all 0.3s ease;
}

/* 다크모드 */
[data-theme="dark"] {
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-light: #888;
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #404040;
    --border-color: #404040;
    --shadow-light: 0 2px 10px rgba(0,0,0,0.3);
    --shadow-medium: 0 4px 20px rgba(0,0,0,0.4);
}

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

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
    transition: var(--transition);
}

/* 컨테이너 */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* 헤더 */
.header {
    background: #FFD700;
    color: #000000;
    padding: 20px 30px;
    border-radius: var(--border-radius-lg);
    margin-bottom: 30px;
    text-align: center;
    position: relative;
    overflow: hidden;
    border: 2px solid #FFA500;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

/* 컴팩트 헤더 */
.header-compact {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 20px 30px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    text-align: center;
}

.header-compact h1 {
    font-size: 1.8em;
    margin-bottom: 5px;
    font-weight: 600;
}

.header-compact .subtitle {
    font-size: 0.95em;
    opacity: 0.9;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="white" opacity="0.1"/><circle cx="75" cy="75" r="1" fill="white" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    opacity: 0.3;
}

.header h1 {
    font-size: 2.8em;
    margin-bottom: 10px;
    font-weight: 700;
    position: relative;
    z-index: 1;
}

.header .subtitle {
    font-size: 1.2em;
    opacity: 0.9;
    position: relative;
    z-index: 1;
}

/* 네비게이션 */
.nav {
    background: var(--bg-primary);
    padding: 15px 0;
    border-radius: var(--border-radius);
    margin-bottom: 30px;
    box-shadow: var(--shadow-light);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.nav-links {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.nav-links a {
    color: var(--text-primary);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    transition: var(--transition);
    font-weight: 500;
}

.nav-links a:hover, .nav-links a.active {
    background: var(--primary-color);
    color: white;
}

.theme-toggle {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.theme-toggle:hover {
    background: var(--primary-color);
    color: white;
}

/* 통계 카드 */
.stats {
    background: var(--bg-primary);
    padding: 30px;
    border-radius: var(--border-radius-lg);
    margin-bottom: 30px;
    box-shadow: var(--shadow-light);
}

/* 컴팩트 통계 */
.stats-compact {
    background: var(--bg-primary);
    padding: 15px 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow-light);
}

.stats-inline {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

.stat-compact {
    color: var(--text-secondary);
    font-size: 0.95em;
}

.stat-compact strong {
    color: var(--primary-color);
    font-weight: 600;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
}

.stat-item {
    text-align: center;
    padding: 25px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
}

.stat-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-medium);
}

.stat-number {
    font-size: 2.5em;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
    display: block;
}

.stat-label {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 1.1em;
}

/* 섹션 */
.section {
    background: var(--bg-primary);
    padding: 30px;
    border-radius: var(--border-radius-lg);
    margin-bottom: 30px;
    box-shadow: var(--shadow-light);
}

.section-title {
    font-size: 1.8em;
    margin-bottom: 25px;
    color: var(--text-primary);
    border-bottom: 3px solid var(--primary-color);
    padding-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-title::before {
    content: '';
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
}

/* 필터 */
.filters {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 25px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    font-size: 0.9em;
    color: var(--text-secondary);
    font-weight: 500;
}

.filter-group select,
.filter-group input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.95em;
}

/* 비디오 카드 */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 25px;
}

/* 컴팩트 비디오 그리드 (5개씩) */
.video-grid-5 {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
}

.video-section {
    background: var(--bg-primary);
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow-light);
}

.video-card-compact {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: var(--transition);
}

.video-card-compact:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-medium);
    border-color: var(--primary-color);
}

.video-thumbnail-compact {
    position: relative;
    aspect-ratio: 16/9;
    overflow: hidden;
}

.video-thumbnail-compact img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.video-card-compact:hover .video-thumbnail-compact img {
    transform: scale(1.03);
}

.video-info-compact {
    padding: 12px;
}

.video-title-compact {
    font-size: 0.9em;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-title-compact a {
    color: inherit;
    text-decoration: none;
}

.video-title-compact a:hover {
    color: var(--primary-color);
}

.video-meta-compact {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8em;
}

.video-views-compact {
    color: var(--primary-color);
    font-weight: 600;
}

.video-date-compact {
    color: var(--text-light);
}

.video-channel-compact {
    color: var(--text-secondary);
    font-size: 0.8em;
    font-weight: 500;
}

/* 비디오 필터 버튼 */
.video-filters {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    background: var(--bg-secondary);
    padding: 15px 20px;
    border-radius: var(--border-radius);
}

.filter-group {
    display: flex;
    gap: 10px;
}

.sort-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sort-group::before {
    content: '정렬:';
    font-size: 0.9em;
    color: var(--text-secondary);
    font-weight: 500;
}

.filter-btn {
    padding: 8px 20px;
    border: 2px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    border-radius: 25px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    font-size: 0.9em;
}

.filter-btn:hover {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
}

.filter-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* 재생시간 배지 */
.video-duration-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7em;
    font-weight: 500;
}

/* 숏폼 특별 표시 */
.video-card-compact[data-url*="/shorts/"] .video-duration-badge {
    background: #ff4444;
}

.video-card-compact[data-url*="/shorts/"]::before {
    content: "SHORTS";
    position: absolute;
    top: 8px;
    left: 8px;
    background: #ff4444;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7em;
    font-weight: 600;
    z-index: 1;
}

.video-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    transition: var(--transition);
    position: relative;
}

.video-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-medium);
    border-color: var(--primary-color);
}

.video-thumbnail {
    position: relative;
    aspect-ratio: 16/9;
    overflow: hidden;
}

.video-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: 500;
}

.video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.video-card:hover .video-thumbnail img {
    transform: scale(1.05);
}

.video-info {
    padding: 20px;
}

.video-title {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.video-date {
    color: var(--text-light);
    font-size: 0.85em;
    font-style: italic;
}

.video-channel {
    color: var(--text-secondary);
    font-size: 0.95em;
    font-weight: 500;
}

.video-views {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.95em;
}

.video-keyword {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 500;
}

/* 키워드 분석 */
.keywords-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.keyword-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.keyword-item:hover {
    background: var(--primary-color);
    color: white;
}

.keyword-name {
    font-weight: 500;
}

.keyword-count {
    background: var(--primary-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
}

.keyword-item:hover .keyword-count {
    background: rgba(255, 255, 255, 0.2);
}

/* 차트 컨테이너 */
.chart-container {
    position: relative;
    height: 350px;
    margin: 20px 0;
}

/* 로딩 */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    color: var(--text-secondary);
}

.loading::after {
    content: '';
    width: 30px;
    height: 30px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

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

/* 채널 그리드 */
.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.channel-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    transition: var(--transition);
}

.channel-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-medium);
    border-color: var(--primary-color);
}

.channel-info {
    text-align: left;
}

.channel-name {
    font-size: 1.2em;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.channel-name a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

.channel-name a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

.channel-handle {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-style: italic;
}

.channel-stats {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.channel-video-count, .channel-views, .channel-avg {
    font-size: 0.9em;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.channel-video-count::before {
    content: "🎥";
    font-size: 1.1em;
}

.channel-views::before {
    content: "👁️";
    font-size: 1.1em;
}

.channel-avg::before {
    content: "📊";
    font-size: 1.1em;
}

/* 반응형 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .header {
        padding: 15px 20px;
    }
    
    .header h1 {
        font-size: 2.2em;
    }
    
    .header-compact {
        padding: 15px 20px;
    }
    
    .header-compact h1 {
        font-size: 1.5em;
    }
    
    .nav-container {
        padding: 0 15px;
        flex-direction: column;
        text-align: center;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 15px;
    }
    
    .stats-inline {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .video-grid {
        grid-template-columns: 1fr;
    }
    
    .video-grid-5 {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .channel-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .video-filters {
        flex-direction: column;
        gap: 15px;
    }
    
    .filter-group {
        justify-content: center;
    }
    
    .sort-group {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.8em;
    }
    
    .header-compact h1 {
        font-size: 1.3em;
    }
    
    .section {
        padding: 20px;
    }
    
    .video-section {
        padding: 15px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .video-grid-5 {
        grid-template-columns: 1fr;
    }
    
    .stats-inline {
        gap: 5px;
    }
    
    .stat-compact {
        font-size: 0.85em;
    }
}

/* Archive-specific styles */
.keyword-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.keyword-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 15px;
    text-align: center;
    transition: var(--transition);
    box-shadow: var(--shadow-light);
}

.keyword-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.keyword-name {
    font-size: 1.2em;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--primary-color);
}

.keyword-stats {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.keyword-count,
.keyword-views,
.keyword-avg {
    font-size: 0.9em;
    color: var(--text-secondary);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.summary-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow-light);
}

.summary-item h3 {
    font-size: 1.1em;
    margin-bottom: 10px;
    color: var(--primary-color);
}

.summary-content {
    font-size: 0.95em;
    line-height: 1.5;
}

.summary-content strong {
    color: var(--text-primary);
}

.video-keyword-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--primary-color);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7em;
    font-weight: 500;
}

.video-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
}

.video-tag {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.7em;
    border: 1px solid var(--border-color);
}

/* 키워드 검색 그리드 */
.keyword-search-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 15px;
}

.keyword-search-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
    font-size: 0.9em;
    font-weight: 500;
}

.keyword-search-tag:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-light);
}

.keyword-count {
    background: var(--primary-color);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.8em;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
}

.keyword-search-tag:hover .keyword-count {
    background: rgba(255, 255, 255, 0.9);
    color: var(--primary-color);
}

.channel-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
}

.channel-keyword-tag {
    background: var(--accent-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 500;
}

.nav-btn {
    background: var(--bg-primary);
    color: var(--text-primary);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    font-size: 0.9em;
}

.nav-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-1px);
}

.filter-select {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 8px 12px;
    font-size: 0.9em;
    transition: var(--transition);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

/* Responsive adjustments for archive styles */
@media (max-width: 768px) {
    .keyword-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 10px;
    }
    
    .summary-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .nav-container {
        flex-direction: column;
        gap: 10px;
    }
    
    .nav-links {
        justify-content: center;
    }
}