/* 기본 스타일 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #87CEEB 0%, #B0E0E6 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 헤더 */
header {
    text-align: center;
    margin-bottom: 30px;
    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;
}

/* 탭 네비게이션 */
.tabs {
    display: flex;
    background: white;
    border-radius: 10px;
    padding: 5px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.tab-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: #E6F3FF;
    color: #4A90E2;
}

.tab-btn.active {
    background: #4A90E2;
    color: white;
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3);
}

/* 탭 콘텐츠 */
.tab-content {
    display: none;
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    min-height: 70vh;
}

.tab-content.active {
    display: block;
}

/* 홈 탭 */
.welcome h2 {
    color: #4A90E2;
    margin-bottom: 20px;
    font-size: 1.8rem;
}

.status-card {
    background: #F0F8FF;
    border: 2px solid #B0E0E6;
    border-radius: 10px;
    padding: 20px;
    margin-top: 20px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-indicator .loading {
    color: #ffa500;
    font-weight: 500;
}

.status-indicator .online {
    color: #28a745;
    font-weight: 500;
}

.status-indicator .offline {
    color: #dc3545;
    font-weight: 500;
}

/* 채팅 탭 */
.chat-container {
    height: 78vh;
    display: flex;
    flex-direction: column;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: 2px solid #B0E0E6;
    margin-bottom: 20px;
}

.chat-header h3 {
    color: #4A90E2;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.online {
    background: #28a745;
}

.status-dot.offline {
    background: #dc3545;
}

.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px;
    background: #F0F8FF;
    border-radius: 12px;
    margin-bottom: 20px;
}

/* 채팅 본문 레이아웃 (메시지 + 우측 패널) */
.chat-body {
    display: flex;
    gap: 16px;
    height: 100%;
}

.chat-main {
    flex: 2;
    display: flex;
    flex-direction: column;
}

.product-panel {
    flex: 1.15;
    background: #FFFFFF;
    border: 2px solid #B0E0E6;
    border-radius: 12px;
    padding: 12px;
    min-width: 320px;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: calc(100% - 0px);
}

.product-panel-header {
    font-weight: 700;
    color: #357ABD;
    border-bottom: 2px solid #E6F3FF;
    padding-bottom: 8px;
}

.product-panel-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
}

.product-preview-img {
    width: 100%;
    height: auto;
    border-radius: 10px;
    border: 1px solid #B0E0E6;
}

.product-info .info-row {
    display: flex;
    gap: 8px;
    margin: 6px 0;
    align-items: flex-start;
}

.product-info .info-label {
    min-width: 58px;
    color: #495057;
    font-weight: 600;
}

.product-info .info-value {
    color: #2C5F8B;
}

.product-info .info-value.multi {
    white-space: pre-wrap;
    line-height: 1.5;
}

.product-link-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    text-decoration: none;
    text-align: center;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(135deg, #4A90E2 0%, #6BB4FF 100%);
    box-shadow: 0 6px 14px rgba(74, 144, 226, 0.25);
    border: 1px solid rgba(74, 144, 226, 0.35);
    transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
    width: 100%;
}

.product-link-btn::before {
    content: '🛒';
    font-size: 18px;
}

.product-link-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 18px rgba(74, 144, 226, 0.3);
}

.product-link-btn:active {
    transform: translateY(0);
    box-shadow: 0 6px 12px rgba(74, 144, 226, 0.25);
}

.message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.message.user {
    align-items: flex-end;
}

.message.bot {
    align-items: flex-start;
}

.message-content {
    max-width: 80%;
    padding: 14px 18px;
    border-radius: 18px;
    word-wrap: break-word;
    font-size: 1.02rem;
    line-height: 1.6;
}

.message.user .message-content {
    background: #4A90E2;
    color: white;
}

.message.bot .message-content {
    background: white;
    border: 1px solid #B0E0E6;
}

/* 전문가 말풍선 */
.expert-bubble {
    width: 100%;
}
.expert-header {
    font-size: 0.85rem;
    font-weight: 600;
    color: #495057;
    margin: 4px 6px 6px 6px;
}
.expert-bubble.style_analyst .message-content {
    border-left: 4px solid #4A90E2;
}
.expert-bubble.color_expert .message-content {
    border-left: 4px solid #87CEEB;
}
.expert-bubble.fitting_coordinator .message-content {
    border-left: 4px solid #B0E0E6;
}
.expert-bubble.complete .message-content {
    background: #F0F8FF;
}
.expert-products {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.product-thumb {
    width: 160px;
    height: 160px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid #B0E0E6;
}

.product-thumb { cursor: pointer; transition: transform 0.15s ease; }
.product-thumb:hover { transform: scale(1.03); }

@media (max-width: 992px) {
    .chat-body { flex-direction: column; }
    .product-panel { max-width: none; min-width: 100%; }
}

.message-time {
    font-size: 0.8rem;
    color: #666;
    margin-top: 5px;
    padding: 0 10px;
}

.chat-input-container {
    display: flex;
    gap: 10px;
}

#chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #B0E0E6;
    border-radius: 25px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s ease;
}

#chat-input:focus {
    border-color: #4A90E2;
}

.send-btn {
    padding: 12px 24px;
    background: #4A90E2;
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.3s ease;
}

.send-btn:hover {
    background: #357ABD;
}

.send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* 쿠키 테스트 탭 */
.cookie-test-container h3,
.api-test-container h3 {
    color: #4A90E2;
    margin-bottom: 25px;
    font-size: 1.5rem;
}

.cookie-section,
.api-section {
    margin-bottom: 30px;
    padding: 20px;
    background: #F0F8FF;
    border-radius: 10px;
    border: 1px solid #B0E0E6;
}

.cookie-section h4,
.api-section h4 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.input-group input,
.input-group select {
    padding: 10px 12px;
    border: 2px solid #B0E0E6;
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.3s ease;
}

.input-group input:focus,
.input-group select:focus {
    border-color: #4A90E2;
}

.btn {
    padding: 10px 20px;
    background: #4A90E2;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.3s ease;
    white-space: nowrap;
}

.btn:hover {
    background: #357ABD;
}

.result-box {
    background: white;
    border: 1px solid #B0E0E6;
    border-radius: 8px;
    padding: 15px;
    margin-top: 10px;
    min-height: 50px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    white-space: pre-wrap;
    word-break: break-all;
}

#api-body {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #B0E0E6;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    outline: none;
    resize: vertical;
    margin-bottom: 15px;
}

#api-body:focus {
    border-color: #4A90E2;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .tabs {
        flex-direction: column;
    }
    
    .tab-btn {
        margin-bottom: 5px;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .input-group input,
    .input-group select,
    .btn {
        width: 100%;
    }
    
    .chat-input-container {
        flex-direction: column;
    }
    
    .message-content {
        max-width: 85%;
    }
}

/* 로딩 애니메이션 */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #ffa500;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 8px;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

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

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

/* 카카오 로그인 관련 스타일 */
.user-status-card {
    background: #F0F8FF;
    border: 2px solid #87CEEB;
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 4px 8px rgba(135, 206, 235, 0.2);
}

.login-prompt {
    text-align: center;
}

.login-prompt p {
    margin-bottom: 15px;
    color: #357ABD;
    font-size: 16px;
    font-weight: 500;
}

.kakao-login-btn {
    background: #FEE500;
    color: #000;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(254, 229, 0, 0.3);
}

.kakao-login-btn:hover {
    background: #FFE55C;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(254, 229, 0, 0.4);
}

.kakao-icon {
    font-size: 18px;
}

.user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #E6F3FF;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #87CEEB;
}

.user-details h3 {
    margin: 0 0 5px 0;
    color: #357ABD;
    font-size: 18px;
}

.user-details p {
    margin: 2px 0;
    color: #4A90E2;
    font-size: 14px;
}

.user-id {
    font-size: 12px !important;
    color: #666 !important;
}

.logout-btn {
    background: #FF6B6B;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background: #FF5252;
    transform: translateY(-1px);
}

/* 로그인 탭 스타일 */
.login-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

.login-section {
    background: #F0F8FF;
    border: 2px solid #87CEEB;
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 4px 8px rgba(135, 206, 235, 0.2);
}

.login-section h4 {
    color: #357ABD;
    margin: 0 0 15px 0;
    font-size: 18px;
    border-bottom: 2px solid #87CEEB;
    padding-bottom: 8px;
}

.login-section p {
    color: #4A90E2;
    margin: 10px 0;
    line-height: 1.5;
}

.login-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    background: #E6F3FF;
    border-radius: 8px;
    border: 1px solid #87CEEB;
}

.status-loading {
    color: #4A90E2;
    font-style: italic;
}

.status-logged-in {
    color: #2E7D32;
    font-weight: 600;
}

.status-logged-out {
    color: #D32F2F;
    font-weight: 600;
}

.status-icon {
    font-size: 18px;
}

.user-details {
    background: #E6F3FF;
    border-radius: 8px;
    padding: 15px;
    border: 1px solid #87CEEB;
}

.details-loading {
    color: #4A90E2;
    font-style: italic;
    text-align: center;
}

.details-content p {
    margin: 8px 0;
    color: #357ABD;
}

.details-content strong {
    color: #2C5F8B;
}

.details-error {
    color: #D32F2F;
    text-align: center;
    font-style: italic;
}
