/* 크롤러 진행 상황 패널 스타일 - Dynamic Island (iPhone Notch) Style */
.crawler-progress-panel {
    display: none;
    /* 기본 숨김 */
}

.crawler-progress-panel.fading-out {
    opacity: 0 !important;
}

.crawler-progress-panel.active {
    display: flex;
}

/* --- Dynamic Island Base Style --- */
.crawler-progress-panel.compact {
    /* 위치 및 레이아웃 */
    /* 위치 및 레이아웃 */
    /* position: fixed; -> Removed, container handles this */
    /* top: 20px; */
    /* left: 50%; */
    /* transform: translateX(-50%); */
    position: relative;
    /* 컨테이너 내부에서 흐름에 따름 */
    /* z-index: 10100; Keep z-index? Container has 9999. */

    /* Dynamic Island 모양 */
    background: #000000;
    color: white;
    padding: 10px 90px 10px 18px;
    border-radius: 30px;
    /* 알약 모양 */
    width: 340px;
    /* Fixed unified width to match theme buttons */
    height: 40px;
    /* 기본 높이 */

    /* Flex 설정 */
    display: none;
    /* active 시 flex */
    /* Flex 설정 */
    display: none;
    /* active 시 flex */
    flex-direction: column;
    /* Always column to prevent wobble */
    align-items: stretch;
    justify-content: flex-start;
    gap: 0;
    /* Gap handled by margin in expanded content */

    /* 효과 */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);

    /* 애니메이션 */
    /* 애니메이션 */
    transition: height 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), border-radius 0.4s ease, opacity 0.4s ease;
    /* Removed padding transition */
    overflow: hidden;
}

/* Minimize Button Style */
/* Minimize Button Style */
/* Minimize Button Style */
/* Minimize Button Style */
.minimize-btn {
    /* position: absolute; REMOVED - Inside flex container */
    /* top, right REMOVED */
    /* transform REMOVED */
    /* top: 20px; right: 48px; transform: translateY(-55%); */
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    opacity: 0.7;
    z-index: 10001;

    /* Flex centering for icon */
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    /* Optional: circular touch target */
}

.minimize-btn:hover {
    opacity: 1;
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

/* Close Button Style */
.close-panel-btn {
    /* position: absolute; REMOVED - Inside flex container */
    /* top, right REMOVED */
    /* transform REMOVED */
    /* top: 20px; right: 18px; transform: translateY(-55%); */
    font-size: 1.4em;
    font-weight: 500;
    cursor: pointer;
    opacity: 0.5;
    z-index: 10001;

    /* Flex centering */
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    color: #ff6b6b;
}

.close-panel-btn:hover {
    opacity: 1;
    background: rgba(255, 107, 107, 0.1);
}

/* Minimized State */
.crawler-progress-panel.compact.minimized {
    height: 12px !important;
    padding: 0 !important;
    width: 60px !important;
    /* Small Pill */
    min-width: 60px !important;
    opacity: 0.6;
    border-radius: 6px;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* When minimized, hide everything except maybe a tiny bar or nothing (just the pill) */
.crawler-progress-panel.compact.minimized * {
    display: none !important;
}

/* Secondary Details Grid Layout */
.crawler-progress-panel .secondary-details {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.15) !important;
    margin-top: 10px !important;
    padding-top: 10px !important;
}

.crawler-progress-panel .secondary-details .progress-item {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
}

.crawler-progress-panel .secondary-details .progress-item:first-child {
    flex: 1 1 100%;
    /* Keyword takes full width */
    margin-bottom: 3px;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
    padding-bottom: 3px;
}

.crawler-progress-panel .secondary-details .label {
    font-size: 0.75em;
    color: #888;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.crawler-progress-panel .secondary-details .value {
    font-size: 0.95em;
    color: #eee;
    font-family: 'Consolas', monospace;
    /* Monospace for numbers */
}

/* Specific tweaks for keyword to handle long text */
#currentKeyword {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 100%;
    /* Let container control width */
    font-family: sans-serif;
    /* Keep keyword readable */
}

.crawler-progress-panel.compact.active {
    display: flex;
}

/* Hover 시 또는 클릭 시 확장 (Expanded State) */
.crawler-progress-panel.compact:hover,
.crawler-progress-panel.compact.expanded {
    width: 340px;
    /* Fixed width to match theme buttons */
    height: auto;
    padding: 10px 18px 10px 18px;
    /* Fixed padding */
    border-radius: 24px;
    /* 조금 더 둥근 사각형 느낌으로 변형 */
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
}

/* --- 내부 요소 스타일 --- */

/* 1. 기본 상태 (Compact): 아이콘 + 심플 텍스트 */
/* Panel Header Style - Stable container for title */
.panel-header {
    height: 20px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.crawler-progress-panel.compact h3 {
    margin: 0;
    font-size: 0.9em;
    font-weight: 600;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: -2px;
    /* Adjusted from -3px to -2px for better baseline match */
}

.crawler-progress-panel.compact h3::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #4caf50;
    /* 녹색 점 */
    border-radius: 50%;
    box-shadow: 0 0 8px #4caf50;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(76, 175, 80, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
    }
}

/* 완료 시 점 숨기기 */
.crawler-progress-panel.compact.completed h3::before {
    display: none;
}

/* 확장 시에만 보이는 요소들 처리 */
.crawler-progress-panel.compact .progress-bar-container,
.crawler-progress-panel.compact .progress-details {
    opacity: 0;
    height: 0;
    margin: 0;
    pointer-events: none;
    transition: all 0.2s ease;
}

/* 확장 상태에서는 보임 */
.crawler-progress-panel.compact:hover .progress-bar-container,
.crawler-progress-panel.compact:hover .progress-details,
.crawler-progress-panel.compact.expanded .progress-bar-container,
.crawler-progress-panel.compact.expanded .progress-details {
    opacity: 1;
    height: auto;
    pointer-events: auto;
    margin-top: 15px;
}

/* 프로그레스 바 */
.progress-bar-container {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    height: 6px;
    width: 100%;
    overflow: hidden;
}

.progress-bar {
    background: linear-gradient(90deg, #4caf50, #81c784);
    height: 100%;
    border-radius: 10px;
}

/* 상세 정보 */
.progress-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.8);
}

.progress-item .value {
    font-weight: 500;
}

/* 우측 상단 미니 인디케이터 (Compact 모드에서 진행률 표시) */
/* Old Pseudo-element Percentage - REMOVED */
/* .crawler-progress-panel.compact::after ... */

/* New Panel Controls Container */
.panel-controls {
    position: absolute;
    right: 10px;
    /* Right padding of panel */
    top: 0;
    transform: none;
    display: flex;
    align-items: center;
    gap: 12px;
    /* Space between Pct, Min, Close */
    height: 40px !important;

    /* Pin to header height */
    z-index: 10001;
}

/* New Progress Indicator Text */
.progress-indicator {
    font-size: 0.8em;
    font-weight: bold;
    color: #4caf50;
    white-space: nowrap;
}



/* 확장 시에는 미니 인디케이터 숨김 (중복 방지 - 요소 기반으로 변경되었으므로 삭제) */
.crawler-progress-panel.compact:hover::after,
.crawler-progress-panel.compact.expanded::after {
    content: none !important;
    display: none !important;
}

/* --- Recheck Mode Styles (Blue/Purple Theme) --- */
.crawler-progress-panel.recheck-mode::after {
    color: #64b5f6;
    /* Light Blue Text */
    text-shadow: 0 0 10px rgba(33, 150, 243, 0.5);
    /* Text Glow */
}

.crawler-progress-panel.recheck-mode h3::before {
    background-color: #2196f3;
    /* Blue Dot */
    box-shadow: 0 0 8px #2196f3;
}

.crawler-progress-panel.recheck-mode .progress-bar {
    background: linear-gradient(90deg, #2196f3, #9c27b0);
    /* Blue to Purple Gradient */
    box-shadow: 0 0 10px rgba(156, 39, 176, 0.4);
    /* Bar Glow */
}

/* Recheck Pulse Animation Override */
.crawler-progress-panel.recheck-mode h3::before {
    animation: pulse-blue 2s infinite;
}

@keyframes pulse-blue {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(33, 150, 243, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(33, 150, 243, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(33, 150, 243, 0);
    }
}

/* --- Stacked Layout Support --- */
#crawlerProgressPanelContainer .crawler-progress-panel {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    margin-bottom: 0;
}