* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ==================== 사용자 정보 영역 ==================== */
.user-info {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
}

.user-welcome {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.user-nickname {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
}

.admin-badge {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4a 100%);
    color: #333;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    margin-left: 10px;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.logout-btn {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.logout-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
}

.search-quota {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.quota-info {
    flex: 1;
    min-width: 200px;
}

.quota-text {
    display: block;
    font-size: 0.95rem;
    font-weight: 500;
    color: #555;
    margin-bottom: 8px;
}

.quota-bar {
    width: 100%;
    height: 8px;
    background: #e1e1e1;
    border-radius: 4px;
    overflow: hidden;
}

.quota-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ecdc4 0%, #44a08d 100%);
    transition: width 0.3s ease;
}

.remaining-count {
    font-size: 1rem;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 20px;
    white-space: nowrap;
}

.remaining-count:not(.no-searches) {
    background: linear-gradient(135deg, #4ecdc4 0%, #44a08d 100%);
    color: white;
}

.remaining-count.no-searches {
    background: linear-gradient(135deg, #303030 0%, #000000 100%);
    color: white;
}

.quota-message {
    text-align: center;
    margin-top: 15px;
    padding: 10px;
    background: rgba(255, 193, 7, 0.1);
    color: #856404;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* ==================== 기존 스타일 ==================== */
header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

.search-section {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
    font-size: 1.1rem;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e1e1e1;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#searchBtn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#searchBtn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

#searchBtn:active:not(:disabled) {
    transform: translateY(0);
}

#searchBtn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.results-section {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.shorts-section,
.regular-section {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 30px;
}

.sort-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.sort-btn {
    padding: 8px 16px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 500;
}

.sort-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.sort-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.sort-btn.desc::after {
    content: " ↓";
}

.sort-btn.asc::after {
    content: " ↑";
}

.loading {
    text-align: center;
    padding: 60px;
    font-size: 2rem;
    color: wheat;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.error-message {
    background: #fee;
    color: #c33;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #c33;
}

.results-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

/* Shorts 섹션은 더 좋은 그리드 레이아웃 */
.shorts-section .results-container {
    grid-template-columns: repeat(auto-fit, minmax(280px, 300px));
    justify-content: center;
    gap: 50px; /* Shorts는 더 넓은 간격 */
}

.content-section {
    margin-bottom: 40px;
}

.main-title-section {
    text-align: center;
    margin-bottom: 30px;
}

.main-title-section h2 {
    font-size: 2rem;
    font-weight: 700;
    color: white;
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    gap: 20px;
    flex-wrap: wrap;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    padding-bottom: 10px;
    border-bottom: 3px solid #667eea;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.section-title.shorts {
    border-bottom-color: #ff6b6b;
}

.section-title.regular {
    border-bottom-color: #4ecdc4;
}

.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.75rem;
    font-weight: 600;
}

.video-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
}

.video-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.video-thumbnail {
    width: 100%;
    height: 200px;
    overflow: hidden;
    position: relative;
    display: block; /* a 태그로 변경되어도 블록 요소로 동작 */
    text-decoration: none; /* 링크 밑줄 제거 */
}

/* Shorts 섹션의 썸네일 - YouTube 메인 대시보드처럼 세로형 */
.shorts-section .video-thumbnail {
    width: 100%;
    height: 0;
    padding-bottom: 177.78%; /* 9:16 비율 (16/9 * 100) */
    position: relative;
    border-radius: 12px 12px 0 0; /* 하단 border-radius 제거 */
    overflow: hidden;
    background: #000;
    display: block; /* a 태그로 변경되어도 블록 요소로 동작 */
    text-decoration: none; /* 링크 밑줄 제거 */
}

.shorts-section .video-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover; /* 중앙 부분을 크롭해서 세로형으로 */
    object-position: center;
}

.video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.video-card:hover .video-thumbnail img {
    transform: scale(1.05);
}

.video-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.video-info {
    flex: 1;
}

.video-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 15px;
    line-height: 1.4;
    color: #333;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: calc(1.1rem * 1.4 * 2); /* 2줄 고정 높이 */
}

.video-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.3s ease;
}

.video-title a:hover {
    color: #667eea;
}

.video-stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 15px;
}

/* 시간당 조회수 행은 1열로 (텍스트 줄바꿈 방지) */
.video-stats-row.single-column {
    grid-template-columns: 1fr;
}

.stat-item {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    color: #666;
    gap: 5px;
}

.stat-item .stat-value {
    font-weight: 600;
    color: #333;
}

.efficiency-highlight {
    grid-column: 1 / -1; /* 2열 전체 차지 */
    margin-bottom: 10px;
    text-align: center; /* 가운데 정렬 */
}

.efficiency-highlight .stat-value {
    font-size: 1.5em; /* 1.5배 크기 */
    font-weight: 700; /* 더 굵게 */
    display: block; /* 블록 요소로 만들어 가운데 정렬 적용 */
}

/* 바이럴 등급별 색상 스타일 */
.grade-hot {
    color: #ff2d55 !important; /* 지금 대박 - 빨간색 */
}

.grade-rising {
    color: #ff6b35 !important; /* 급상승 중 - 주황색 */
}

.grade-trending {
    color: #f7931e !important; /* 화제성 있음 - 노란색 */
}

.grade-attention {
    color: #4ecdc4 !important; /* 관심 집중 - 청록색 */
}

.grade-normal {
    color: #667eea !important; /* 보통 - 기본 색상 */
}

.channel-info {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 8px;
}

.upload-date {
    color: #888;
    font-size: 0.85rem;
    padding-top: 8px;
    border-top: 1px solid #f0f0f0;
}

/* ==================== 반응형 디자인 ==================== */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .search-section,
    .results-section {
        padding: 20px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .results-container {
        grid-template-columns: 1fr;
    }
    
    .user-welcome {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .search-quota {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .quota-info {
        min-width: auto;
    }
    
    .remaining-count {
        text-align: center;
    }
}

@media (max-width: 480px) {
    .sort-buttons {
        width: 100%;
        justify-content: center;
    }
    
    .sort-btn {
        flex: 1;
        text-align: center;
        min-width: 0;
        font-size: 0.8rem;
        padding: 6px 12px;
    }
    
    .video-stats-row {
        grid-template-columns: 1fr;
    }
    
    .user-info {
        padding: 15px;
    }
    
    .user-nickname {
        font-size: 1.1rem;
    }
    
    .logout-btn {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
}