/* TensorBoard Blue Theme */
:root {
    --primary-blue: #1976D2;
    --dark-blue: #0D47A1;
    --light-blue: #42A5F5;
    --accent-blue: #64B5F6;
    --bg-primary: #FAFAFA;
    --bg-secondary: #FFFFFF;
    --bg-hover: #E3F2FD;
    --text-primary: #212121;
    --text-secondary: #757575;
    --border-color: #E0E0E0;
    --success: #4CAF50;
    --warning: #FF9800;
    --error: #F44336;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
}

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

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

/* 헤더 */
.header {
    background: var(--primary-blue);
    color: white;
    padding: 0 24px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1920px;
    margin: 0 auto;
    height: 64px;
}

.logo {
    font-size: 20px;
    font-weight: 500;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.status-indicator {
    font-size: 12px;
    animation: pulse 2s infinite;
}

.status-indicator.connected {
    color: var(--success);
}

.status-indicator.disconnected {
    color: var(--error);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* 메인 컨테이너 */
.main-container {
    display: flex;
    height: calc(100vh - 64px);
    max-width: 1920px;
    margin: 0 auto;
}

/* 사이드바 */
.sidebar {
    width: 240px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.nav-menu {
    padding: 16px 8px;
}

.nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 4px;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--bg-hover);
}

.nav-item.active {
    background: var(--light-blue);
    color: white;
}

.nav-icon {
    font-size: 20px;
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-secondary);
}

/* 콘텐츠 영역 */
.content {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-primary);
}

.view {
    display: none;
    padding: 14px;
}

.view.active {
    display: block;
}

.view-header {
    margin-bottom: 12px;
}

.view-header h2 {
    font-size: 28px;
    font-weight: 400;
    color: var(--dark-blue);
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

/* 그리드 레이아웃 */
.content-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 14px;
}

/* 카드 스타일 */
.upload-card, .video-card, .results-card, .control-card, .logs-card {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 12px;
    box-shadow: var(--shadow);
}

.upload-section {
    grid-column: 1 / -1;
}

/* 업로드 영역 */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 2px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 14px;
}

.upload-area:hover {
    border-color: var(--primary-blue);
    background: var(--bg-hover);
}

.upload-area.drag-over {
    border-color: var(--primary-blue);
    background: var(--bg-hover);
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 1px;
}

.upload-placeholder p {
    font-size: 15px;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.upload-placeholder small {
    color: var(--text-secondary);
}

.upload-options {
    display: flex;
    align-items: center;
    gap: 12px;
}

.upload-options label {
    font-size: 14px;
    color: var(--text-secondary);
}

.upload-options select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
}

/* 버튼 */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-blue);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--dark-blue);
    box-shadow: var(--shadow);
}

.btn-primary:disabled {
    background: var(--border-color);
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-hover);
}

/* 프로그레스 바 */
.progress-container {
    margin-top: 24px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.progress-bar {
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-blue), var(--light-blue));
    transition: width 0.3s;
    width: 0%;
}

/* 비디오 플레이어 */
.video-player-container {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 */
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

.video-player-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.video-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a1a;
    color: #888;
}

/* 결과 리스트 */
.results-card h3 {
    font-size: 18px;
    font-weight: 500;
    color: var(--dark-blue);
    margin-bottom: 16px;
}

.results-list {
    max-height: 600px;
    overflow-y: auto;
}

/*
.result-item {
    padding: 4px;
    margin-bottom: 8px;
    background: var(--bg-primary);
    border-left: 4px solid var(--primary-blue);
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
*/

.result-item {
    padding: 4px;
    margin-bottom: -1px;
    background: var(--bg-primary);
    border: 1px solid #eee;
    border-radius: 2px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-item div {
    line-height: 1.3;
}

.result-action {
    font-weight: 500;
    color: var(--text-primary);
}

.result-confidence {
    color: var(--primary-blue);
    font-weight: 600;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 48px 24px;
}

/* 로그 리스트 */
.logs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.logs-header h3 {
    font-size: 18px;
    font-weight: 500;
    color: var(--dark-blue);
}

.log-item {
    padding: 16px;
    margin-bottom: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 4px solid transparent;
}

.log-item:hover {
    background: var(--bg-hover);
    border-left-color: var(--primary-blue);
}

.log-item.selected {
    background: var(--bg-hover);
    border-left-color: var(--primary-blue);
}

.log-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.log-filename {
    font-weight: 500;
    color: var(--text-primary);
}

.log-timestamp {
    font-size: 12px;
    color: var(--text-secondary);
}

.log-item-info {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--text-secondary);
}

.log-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.log-badge.upload {
    background: #E3F2FD;
    color: var(--primary-blue);
}

.log-badge.webcam {
    background: #F3E5F5;
    color: #9C27B0;
}

/* 웹캠 컨트롤 */
.webcam-controls {
    grid-column: 1 / -1;
}

.control-card {
    display: flex;
    align-items: center;
    gap: 12px;
}

.control-card label {
    font-size: 14px;
    color: var(--text-secondary);
}

.control-card select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
}

/* 반응형 */
@media (max-width: 1400px) {
    .content-grid {
        grid-template-columns: 2fr 1fr;
    }
}

@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        width: 200px;
    }
}

@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .nav-menu {
        display: flex;
        padding: 8px;
    }
    
    .nav-item {
        flex: 1;
        justify-content: center;
        margin-bottom: 0;
        margin-right: 4px;
    }
    
    .nav-text {
        display: none;
    }
}

/* 스크롤바 커스터마이징 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ============================================
   터미널 로그
   ============================================ */
.terminal-log {
    background: #1e1e1e;
    color: #d4d4d4;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    padding: 16px;
    border-radius: 8px;
    margin-top: 16px;
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

.terminal-log::-webkit-scrollbar {
    width: 8px;
}

.terminal-log::-webkit-scrollbar-track {
    background: #2d2d2d;
}

.terminal-log::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

/* 터미널 로그 색상 */
.log-info { color: #4ec9b0; }
.log-warning { color: #ce9178; }
.log-error { color: #f48771; }
.log-success { color: #89d185; }
.log-dim { color: #808080; }

/* ============================================
   모달
   ============================================ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    max-width: 1200px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 10;
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-video-section,
.modal-results-section {
    margin-bottom: 24px;
}

.info-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.info-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.info-value {
    color: var(--text-primary);
    font-weight: 600;
}

/* ============================================
   Stride 선택
   ============================================ */
.stride-select-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.stride-option {
    padding: 8px 16px;
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.stride-option:hover {
    border-color: var(--light-blue);
    color: var(--primary-blue);
}

.stride-option.active {
    border-color: var(--primary-blue);
    background: var(--primary-blue);
    color: white;
}

.stride-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-right: 8px;
}

/* ============================================
   동작명 표시 관련 추가 스타일
   ============================================ */

/* 웹캠 결과 표시 */
.webcam-detection {
    padding: 1rem;
    background: #f5f5f5;
    border-radius: 8px;
    margin-top: 1rem;
}

.detection-action {
    margin-bottom: 0.5rem;
}

.action-name {
    font-size: 1.5rem;
    font-weight: bold;
    color: #333;
    display: block;
    margin-bottom: 0.25rem;
}

.action-label {
    font-size: 0.875rem;
    color: #666;
    font-family: 'Courier New', monospace;
}

.detection-confidence {
    font-size: 1.125rem;
    font-weight: bold;
    padding: 0.5rem;
    border-radius: 4px;
    text-align: center;
}

.confidence-high {
    background: #d4edda;
    color: #155724;
}

.confidence-medium {
    background: #fff3cd;
    color: #856404;
}

.confidence-low {
    background: #f8d7da;
    color: #721c24;
}

/* 로그 카드 상태별 스타일 */
.log-card {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    padding: 16px;
    margin-bottom: 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

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

.status-completed {
    border-left: 4px solid var(--success);
}

.status-processing {
    border-left: 4px solid var(--warning);
}

.status-failed {
    border-left: 4px solid var(--error);
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.log-status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: bold;
}

.status-completed .log-status {
    background: #d4edda;
    color: #155724;
}

.status-processing .log-status {
    background: #fff3cd;
    color: #856404;
}

.status-failed .log-status {
    background: #f8d7da;
    color: #721c24;
}

.log-info {
    display: flex;
    gap: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* 동작 테이블 */
.actions-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
}

.actions-table th,
.actions-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.actions-table th {
    background: var(--bg-primary);
    font-weight: bold;
    color: var(--text-primary);
}

.actions-table tbody tr:hover {
    background: var(--bg-hover);
}

.actions-table code {
    font-family: 'Courier New', monospace;
    background: #f0f0f0;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-size: 0.875rem;
}

.actions-table .confidence-high {
    color: #155724;
    font-weight: bold;
}

.actions-table .confidence-medium {
    color: #856404;
    font-weight: bold;
}

.actions-table .confidence-low {
    color: #721c24;
    font-weight: bold;
}

/* 모달 섹션 */
.modal-section {
    margin-bottom: 2rem;
}

.modal-section h3 {
    margin-bottom: 1rem;
    color: var(--dark-blue);
    font-size: 1.25rem;
    border-bottom: 2px solid var(--primary-blue);
    padding-bottom: 0.5rem;
}

.modal-section:last-child {
    margin-bottom: 0;
}

/* 검출된 동작 목록 스크롤 */
.detected-actions-list {
    max-height: 400px;
    overflow-y: auto;
}

/* 업로드 결과 */
.result-success {
    padding: 1.5rem;
    background: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 8px;
    margin-top: 1rem;
}

.result-success h3 {
    color: #155724;
    margin-bottom: 1rem;
}

.result-info {
    margin-bottom: 1rem;
}

.result-info p {
    margin: 0.5rem 0;
    color: #155724;
}

.result-info strong {
    font-weight: bold;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .actions-table {
        font-size: 0.875rem;
    }
    
    .actions-table th,
    .actions-table td {
        padding: 0.5rem;
    }
    
    .action-name {
        font-size: 1.25rem;
    }
    
    .info-item {
        flex-direction: column;
        gap: 0.25rem;
    }
}