/* ====================================
   YouTube 자동 요약 - 스타일시트
   모던 다크 테마 + 글래스모피즘
   ==================================== */

/* CSS 변수 */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(25, 25, 35, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.05);
    --bg-hover: rgba(255, 255, 255, 0.08);

    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #606070;

    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);

    --border-color: rgba(255, 255, 255, 0.08);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.5);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    --sidebar-width: 280px;
}

/* 리셋 & 기본 */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* 배경 그라데이션 효과 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* 앱 레이아웃 */
.app {
    display: flex;
    min-height: 100vh;
}

/* ====== 사이드바 ====== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* 네비게이션 */
.nav {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    margin-bottom: 4px;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-gradient);
    color: white;
}

.nav-icon {
    font-size: 1.1rem;
}

.badge {
    margin-left: auto;
    background: var(--bg-glass);
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.nav-item.active .badge {
    background: rgba(255, 255, 255, 0.2);
}

/* 사이드바 푸터 */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.sync-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.sync-btn:hover {
    background: var(--accent-gradient);
    border-color: transparent;
}

.sync-btn.syncing .sync-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.last-sync {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* ====== 메인 컨텐츠 ====== */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px;
    min-height: 100vh;
}

/* 헤더 */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
}

.search-box input {
    padding: 10px 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    width: 250px;
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

/* ====== 영상 목록 ====== */
.video-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

/* 영상 카드 */
.video-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    backdrop-filter: blur(10px);
}

.video-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-lg);
}

.video-thumbnail {
    position: relative;
    aspect-ratio: 16/9;
    overflow: hidden;
}

.video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.video-card:hover .video-thumbnail img {
    transform: scale(1.05);
}

.video-category {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    color: white;
}

.video-status {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
}

.video-status.pending {
    background: #f59e0b;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.video-info {
    padding: 16px;
}

.video-title {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.video-channel {
    display: flex;
    align-items: center;
    gap: 4px;
}

.video-date {
    color: var(--text-muted);
}

.video-summary-preview {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ====== 상세 패널 ====== */
.detail-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 200;
}

.detail-overlay.active {
    opacity: 1;
    visibility: visible;
}

.detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 60%;
    max-width: 800px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    z-index: 201;
}

.detail-overlay.active .detail-panel {
    transform: translateX(0);
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
    z-index: 10;
}

.close-btn:hover {
    background: var(--bg-hover);
}

.detail-content {
    padding: 32px;
}

/* 상세 헤더 */
.detail-header {
    margin-bottom: 32px;
}

.detail-thumbnail {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 20px;
}

.detail-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.detail-title {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 12px;
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.detail-category {
    display: inline-block;
    padding: 4px 12px;
    background: var(--accent-gradient);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    color: white;
}

/* 요약 섹션 */
.summary-section {
    margin-bottom: 28px;
}

.summary-section h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--accent-primary);
}

.summary-section h3 .icon {
    font-size: 1.2rem;
}

/* 간단요약 */
.quick-summary {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-primary);
    background: var(--bg-glass);
    padding: 20px;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--accent-primary);
}

/* 핵심 인사이트 */
.insights-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.insight-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: var(--bg-glass);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.insight-item:hover {
    background: var(--bg-hover);
}

.insight-number {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-gradient);
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
}

.insight-text {
    flex: 1;
    line-height: 1.6;
}

/* 타임라인 */
.timeline {
    position: relative;
    padding-left: 32px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 11px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.timeline-item {
    position: relative;
    padding-bottom: 24px;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -26px;
    top: 4px;
    width: 12px;
    height: 12px;
    background: var(--accent-primary);
    border-radius: 50%;
    border: 2px solid var(--bg-secondary);
}

.timeline-time {
    display: inline-block;
    padding: 2px 8px;
    background: var(--accent-gradient);
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.timeline-content {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* 심층요약 */
.deep-summary {
    line-height: 1.8;
    color: var(--text-secondary);
    white-space: pre-wrap;
}

.deep-summary p {
    margin-bottom: 16px;
}

.deep-summary p:last-child {
    margin-bottom: 0;
}

/* YouTube 링크 */
.youtube-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: #ff0000;
    color: white;
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: var(--transition);
    margin-top: 24px;
}

.youtube-link:hover {
    background: #cc0000;
    transform: translateY(-2px);
}

/* ====== PWA 설치 배너 ====== */
.install-banner {
    position: fixed;
    bottom: -120px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 500px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    transition: bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.install-banner.show {
    bottom: 24px;
}

.install-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.install-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
}

.install-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.install-text strong {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.install-text span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.install-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.install-btn {
    padding: 10px 20px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.install-btn:hover {
    transform: scale(1.05);
}

.install-dismiss {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    border-radius: 50%;
    transition: var(--transition);
}

.install-dismiss:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

@media (max-width: 480px) {
    .install-banner {
        flex-direction: column;
        align-items: stretch;
        padding: 14px;
    }

    .install-content {
        margin-bottom: 8px;
    }

    .install-actions {
        justify-content: flex-end;
    }

    .install-btn {
        flex: 1;
    }
}

/* ====== 에러 배너 및 재시도 버튼 ====== */
.error-section {
    margin-top: 0;
}

.error-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
}

.error-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.error-content {
    flex: 1;
}

.error-content strong {
    display: block;
    color: #ef4444;
    font-size: 1rem;
    margin-bottom: 4px;
}

.error-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
    word-break: break-word;
}

.retry-count {
    display: inline-block;
    margin-top: 8px;
    padding: 2px 8px;
    background: rgba(239, 68, 68, 0.2);
    border-radius: 4px;
    font-size: 0.75rem;
    color: #fca5a5;
}

.retry-btn {
    padding: 12px 20px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.retry-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.retry-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* 대기중 상태에서의 재시도 버튼 */
.empty-state .retry-btn {
    margin-top: 16px;
}

@media (max-width: 600px) {
    .error-banner {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }

    .retry-btn {
        width: 100%;
    }
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

/* 빈 상태 */
.empty-state {
    text-align: center;
    padding: 60px;
    color: var(--text-secondary);
}

.empty-state .icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.2rem;
    margin-bottom: 8px;
}

/* ====== 반응형 ====== */
@media (max-width: 1024px) {
    .detail-panel {
        width: 80%;
    }
}

@media (max-width: 768px) {

    /* 모바일 메뉴 버튼 */
    .mobile-menu-btn {
        display: flex;
        position: fixed;
        top: 16px;
        left: 16px;
        z-index: 150;
        width: 44px;
        height: 44px;
        align-items: center;
        justify-content: center;
        background: var(--accent-gradient);
        border: none;
        border-radius: var(--radius-md);
        color: white;
        font-size: 1.5rem;
        cursor: pointer;
        box-shadow: var(--shadow-lg);
    }

    .mobile-close-btn {
        display: flex;
        width: 36px;
        height: 36px;
        align-items: center;
        justify-content: center;
        background: var(--bg-hover);
        border: 1px solid var(--border-color);
        border-radius: 50%;
        color: var(--text-primary);
        font-size: 1rem;
        cursor: pointer;
    }

    .sidebar-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 200;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* 사이드바 배경 오버레이 */
    .sidebar.open::after {
        content: '';
        position: fixed;
        top: 0;
        left: var(--sidebar-width);
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
    }

    .main {
        margin-left: 0;
        padding: 80px 16px 16px;
    }

    .header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .search-box input {
        width: 100%;
    }

    .detail-panel {
        width: 100%;
        max-width: 100%;
    }

    .detail-content {
        padding: 20px;
    }

    .detail-thumbnail {
        border-radius: var(--radius-md);
    }

    .video-list {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .video-card {
        border-radius: var(--radius-md);
    }

    .quick-summary {
        font-size: 1rem;
        padding: 16px;
    }

    .insight-item {
        padding: 12px;
    }

    .youtube-link {
        width: 100%;
        justify-content: center;
    }
}

/* 데스크톱에서는 모바일 버튼 숨기기 */
@media (min-width: 769px) {

    .mobile-menu-btn,
    .mobile-close-btn {
        display: none;
    }
}

/* 매우 작은 화면 (아이폰 SE 등) */
@media (max-width: 375px) {
    :root {
        --sidebar-width: 260px;
    }

    .main {
        padding: 70px 12px 12px;
    }

    .page-title {
        font-size: 1.2rem;
    }

    .video-info {
        padding: 12px;
    }

    .video-title {
        font-size: 0.9rem;
    }

    .detail-title {
        font-size: 1.2rem;
    }

    .summary-section h3 {
        font-size: 1rem;
    }
}

/* Safe area 지원 (노치 있는 기기) */
@supports (padding: env(safe-area-inset-top)) {
    .mobile-menu-btn {
        top: calc(16px + env(safe-area-inset-top));
        left: calc(16px + env(safe-area-inset-left));
    }

    .main {
        padding-top: calc(80px + env(safe-area-inset-top));
        padding-left: calc(16px + env(safe-area-inset-left));
        padding-right: calc(16px + env(safe-area-inset-right));
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }

    .detail-content {
        padding-bottom: calc(32px + env(safe-area-inset-bottom));
    }
}