@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css');

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

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #ffffff;
    min-height: 100vh;
    color: #09090b;
}

.container {
    width: 100%;
    margin: 0;
    padding: 24px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.header {
    background: #ffffff;
    padding: 24px 32px;
    border: 1px solid #e4e4e7;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.header h1 {
    font-size: 24px;
    font-weight: 600;
    color: #09090b;
    flex: 1;
}

.header-title {
    cursor: pointer;
    transition: color 0.2s;
}

.header-title:hover {
    color: #18181b;
}

.header-logo {
    height: 48px;
    width: auto;
    object-fit: contain;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    flex: 1;
    overflow: hidden;
}

/* 좌측 섹션 */
.left-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-height: 0;
}

.video-container {
    flex: 1;
    background: #ffffff;
    border: 1px solid #e4e4e7;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#video-player {
    width: 100%;
    height: 100%;
    display: block;
    background: #000;
    object-fit: contain;
}

.empty-space {
    flex: 1;
    background: #ffffff;
    border: 1px solid #e4e4e7;
    border-radius: 12px;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

#ply-viewer-container canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* PLY 로딩 인디케이터 */
.ply-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    z-index: 10;
    transition: opacity 0.3s ease-out;
}

.ply-loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.ply-loading-content {
    text-align: center;
    padding: 24px;
}

.ply-loading-icon {
    font-size: 48px;
    margin-bottom: 16px;
    animation: plyBounce 1s infinite ease-in-out;
}

@keyframes plyBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.ply-loading-text {
    font-size: 14px;
    font-weight: 600;
    color: #09090b;
    margin-bottom: 16px;
}

.ply-loading-bar {
    width: 200px;
    height: 8px;
    background: #e4e4e7;
    border-radius: 4px;
    overflow: hidden;
    margin: 0 auto 8px;
}

.ply-loading-progress {
    height: 100%;
    background: linear-gradient(90deg, #0055ff, #0088ff);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease-out;
}

.ply-loading-percent {
    font-size: 12px;
    color: #71717a;
    font-weight: 500;
}

/* 3D 뷰어 컨트롤 */
.viewer-controls {
    position: absolute;
    bottom: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 5;
}

.viewer-control-group {
    display: flex;
    gap: 8px;
    background: rgba(255, 255, 255, 0.95);
    padding: 8px;
    border-radius: 12px;
    box-shadow: 0 2px 8px 0 rgb(0 0 0 / 0.15);
}

.viewer-btn {
    width: 40px;
    height: 40px;
    background: #ffffff;
    border: 1px solid #e4e4e7;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.viewer-btn:hover {
    background: #f4f4f5;
    border-color: #09090b;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px 0 rgb(0 0 0 / 0.15);
}

.viewer-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px 0 rgb(0 0 0 / 0.1);
}

/* 우측 섹션 - 채팅 */
.right-section {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    background: #ffffff;
    border: 1px solid #e4e4e7;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    min-height: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #fafafa;
    min-height: 0;
}

.message {
    padding: 16px 20px;
    border-radius: 8px;
    max-width: 85%;
    word-wrap: break-word;
    animation: slideIn 0.2s ease-out;
    font-size: 14px;
    line-height: 1.6;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.system-message {
    background: #ffffff;
    border: 1px solid #e4e4e7;
    align-self: center;
    text-align: center;
    max-width: 100%;
    color: #09090b;
}

.user-message {
    background: #09090b;
    color: #fafafa;
    align-self: flex-end;
    border: 1px solid #09090b;
    max-width: 80%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-message .message-content {
    color: #fafafa;
}

.user-message .message-timestamp {
    font-size: 11px;
    color: #d4d4d8;
    text-align: right;
}

.ai-message {
    align-self: flex-start;
    padding: 0;
    max-width: 85%;
    background: transparent;
    border: none;
}

.message-with-icon {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.message-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #ffffff;
    border: 1px solid #e4e4e7;
    border-radius: 8px;
    padding: 16px 20px;
}

.message-content {
    color: #09090b;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message-timestamp {
    font-size: 11px;
    color: #a1a1aa;
    margin-top: 4px;
    text-align: right;
}

.gemini-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

.gemini-icon-emoji {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: #f4f4f5;
}

.ai-message pre {
    background: #fafafa;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 10px 0;
    border: 1px solid #e4e4e7;
    font-size: 13px;
}

/* 마크다운 스타일링 */
.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4,
.message-text h5,
.message-text h6 {
    margin-top: 20px;
    margin-bottom: 10px;
    font-weight: 700;
    color: #09090b;
    line-height: 1.3;
}

.message-text h1:first-child,
.message-text h2:first-child,
.message-text h3:first-child {
    margin-top: 0;
}

.message-text h1 { font-size: 22px; border-bottom: 2px solid #e4e4e7; padding-bottom: 8px; }
.message-text h2 { font-size: 20px; border-bottom: 1px solid #e4e4e7; padding-bottom: 6px; }
.message-text h3 { font-size: 18px; }
.message-text h4 { font-size: 16px; }
.message-text h5 { font-size: 15px; }
.message-text h6 { font-size: 14px; color: #71717a; }

.message-text p {
    margin: 12px 0;
    line-height: 1.7;
    color: #09090b;
}

.message-text p:first-child {
    margin-top: 0;
}

.message-text p:last-child {
    margin-bottom: 0;
}

.message-text ul,
.message-text ol {
    margin: 12px 0;
    padding-left: 28px;
    line-height: 1.7;
}

.message-text ul {
    list-style-type: disc;
}

.message-text ol {
    list-style-type: decimal;
}

.message-text li {
    margin: 6px 0;
    padding-left: 4px;
}

.message-text li > ul,
.message-text li > ol {
    margin: 8px 0;
}

.message-text code {
    background: #f4f4f5;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'Courier New', 'Consolas', monospace;
    border: 1px solid #e4e4e7;
    color: #dc2626;
}

.message-text pre {
    background: #fafafa;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 16px 0;
    border: 1px solid #e4e4e7;
}

.message-text pre code {
    background: transparent;
    padding: 0;
    border: none;
    color: #09090b;
    font-size: 14px;
    display: block;
    line-height: 1.6;
}

.message-text blockquote {
    border-left: 4px solid #09090b;
    padding: 12px 16px;
    margin: 16px 0;
    background: #fafafa;
    color: #52525b;
    font-style: italic;
}

.message-text blockquote p {
    margin: 0;
}

.message-text hr {
    border: none;
    border-top: 2px solid #e4e4e7;
    margin: 24px 0;
}

.message-text table {
    border-collapse: collapse;
    width: 100%;
    margin: 16px 0;
    font-size: 14px;
}

.message-text table th,
.message-text table td {
    border: 1px solid #e4e4e7;
    padding: 10px 12px;
    text-align: left;
}

.message-text table th {
    background: #fafafa;
    font-weight: 600;
    color: #09090b;
}

.message-text table tr:nth-child(even) {
    background: #fafafa;
}

.message-text strong,
.message-text b {
    font-weight: 700;
    color: #09090b;
}

.message-text em,
.message-text i {
    font-style: italic;
}

.message-text a {
    color: #2563eb;
    text-decoration: underline;
}

.message-text a:hover {
    color: #1d4ed8;
}

.message-text img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 12px 0;
}

/* 체크박스 리스트 */
.message-text input[type="checkbox"] {
    margin-right: 8px;
}

/* 인라인 코드 강조 */
.message-text p code,
.message-text li code {
    font-weight: 600;
}

.loading-message {
    align-self: flex-start;
    padding: 0;
    background: transparent;
    border: none;
}

.loading-message .message-text {
    background: #ffffff;
    border: 1px solid #e4e4e7;
    color: #71717a;
}

.loading-dots {
    display: flex;
    gap: 4px;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    background: #09090b;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.chat-input-container {
    padding: 16px;
    background: #ffffff;
    border-top: 1px solid #e4e4e7;
    display: flex;
    gap: 8px;
}

#question-input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid #e4e4e7;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    background: #ffffff;
    color: #09090b;
    font-family: 'Pretendard', sans-serif;
}

#question-input:focus {
    border-color: #09090b;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

#question-input:disabled {
    background: #fafafa;
    cursor: not-allowed;
    color: #a1a1aa;
}

#question-input::placeholder {
    color: #a1a1aa;
}

#send-btn {
    padding: 10px 24px;
    background: #09090b;
    color: #fafafa;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Pretendard', sans-serif;
}

#send-btn:hover:not(:disabled) {
    background: #18181b;
}

#send-btn:disabled {
    background: #e4e4e7;
    color: #a1a1aa;
    cursor: not-allowed;
}

.btn-primary {
    padding: 10px 24px;
    background: #09090b;
    color: #fafafa;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 12px;
    font-family: 'Pretendard', sans-serif;
}

.btn-primary:hover:not(:disabled) {
    background: #18181b;
}

.btn-primary:disabled {
    background: #e4e4e7;
    color: #a1a1aa;
    cursor: not-allowed;
}

/* 스크롤바 스타일 */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #fafafa;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #e4e4e7;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #d4d4d8;
}

/* 추천 카드 스타일 */
.suggestion-cards {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.suggestion-card {
    background: #ffffff;
    border: 1px solid #e4e4e7;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.2s;
}

.suggestion-card:hover {
    border-color: #09090b;
    box-shadow: 0 2px 4px 0 rgb(0 0 0 / 0.1);
}

.card-icon {
    font-size: 24px;
    line-height: 1;
}

.card-title {
    font-weight: 600;
    font-size: 14px;
    color: #09090b;
}

.card-description {
    font-size: 13px;
    color: #71717a;
    line-height: 1.5;
}

.card-btn {
    padding: 8px 16px;
    background: #09090b;
    color: #fafafa;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Pretendard', sans-serif;
    margin-top: 4px;
}

.card-btn:hover {
    background: #18181b;
}

.card-btn:disabled {
    background: #e4e4e7;
    color: #a1a1aa;
    cursor: not-allowed;
}


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

    .left-section {
        max-height: 400px;
    }
}
