:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --chat-user: #6366f1;
    --chat-bot: #f1f5f9;
    --chat-user-text: #ffffff;
    --chat-bot-text: #1e293b;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-primary);
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    background-color: var(--primary);
    border-color: var(--primary);
}

.card {
    transition: box-shadow 0.2s ease;
}

.chat-container {
    height: 500px;
    overflow-y: auto;
    padding: 1.5rem;
    background: var(--bg-main);
}

.chat-bubble {
    padding: 0.5rem 0.75rem;
    border-radius: 1rem;
    word-break: break-word;
    white-space: pre-line;
}

.chat-bot {
    background: var(--chat-bot);
    color: var(--chat-bot-text);
    border-bottom-left-radius: 0.25rem;
}

.chat-user {
    background: var(--chat-user);
    color: var(--chat-user-text);
    border-bottom-right-radius: 0.25rem;
}

.chat-input-area {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    background: white;
    border-top: 1px solid var(--border);
}

.navbar-brand {
    color: var(--primary) !important;
}

pre {
    margin-bottom: 0;
    font-size: 0.875rem;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(99, 102, 241, 0.25);
}

.alert-success {
    background-color: #ecfdf5;
    border-color: #a7f3d0;
    color: #065f46;
}

/* 스켈레톤 로딩 */
/* 스켈레톤 이미지는 JS 처리 전까지 완전히 숨김 */
img[data-skeleton]:not(.skeleton-loaded) {
    visibility: hidden !important;
    opacity: 0 !important;
}

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* 이미지 스켈레톤 래퍼 */
.img-skeleton-wrapper {
    position: relative;
    display: inline-block;
    overflow: hidden;
}

.img-skeleton-wrapper .skeleton-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.img-skeleton-wrapper img {
    visibility: visible !important;
    opacity: 0 !important;
    transition: opacity 0.3s ease;
}

.img-skeleton-wrapper.loaded .skeleton-placeholder {
    display: none;
}

.img-skeleton-wrapper.loaded img {
    opacity: 1 !important;
}

/* 스켈레톤 이미지 - 다양한 크기 */
.skeleton-circle {
    border-radius: 50%;
}

.skeleton-rounded {
    border-radius: 8px;
}

/* 콘텐츠 스켈레톤 */
.skeleton-text {
    height: 1em;
    border-radius: 4px;
    margin-bottom: 0.5em;
}

.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 70%; }
.skeleton-text.long { width: 100%; }

/* 카드 스켈레톤 */
.skeleton-card {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* 페이지 로딩 시 전체 콘텐츠 숨김 방지 */
.page-loading img:not(.loaded) {
    min-height: 50px;
}

/* 관계 유형별 색상 배지 */
.badge-relation-friend {
    background-color: #e8f5e9 !important;
    color: #2e7d32 !important;
}

.badge-relation-rival {
    background-color: #fff3e0 !important;
    color: #ef6c00 !important;
}

.badge-relation-lover {
    background-color: #fce4ec !important;
    color: #c2185b !important;
}

.badge-relation-family {
    background-color: #efebe9 !important;
    color: #5d4037 !important;
}

.badge-relation-enemy {
    background-color: #ffebee !important;
    color: #c62828 !important;
}

.badge-relation-mentor {
    background-color: #f3e5f5 !important;
    color: #7b1fa2 !important;
}

.badge-relation-student {
    background-color: #e0f7fa !important;
    color: #00838f !important;
}

.badge-relation-colleague {
    background-color: #e3f2fd !important;
    color: #1565c0 !important;
}

.badge-relation-stranger {
    background-color: #f5f5f5 !important;
    color: #616161 !important;
}

/* ============================================
   반응형 스타일
   ============================================ */

/* 사용자 아바타 (네비게이션) */
.user-avatar {
    width: 24px;
    height: 24px;
    object-fit: cover;
}

/* 채팅 아바타/아이콘 기본 스타일 */
.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

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

.chat-header-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

/* 카드 미리보기 */
.chat-link-preview {
    max-width: 280px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.chat-link-thumb {
    width: 60px;
    height: 75px;
    object-fit: cover;
    flex-shrink: 0;
}

/* 태블릿 (768px 이하) */
@media (max-width: 768px) {
    .chat-container {
        height: calc(100vh - 280px);
        min-height: 300px;
        padding: 1rem;
    }

    .chat-input-area {
        padding: 0.75rem;
    }

    .chat-bubble {
        padding: 0.5rem 0.75rem;
        font-size: 0.95rem;
    }

    .chat-link-preview {
        max-width: 100%;
    }

    /* 테이블 반응형 */
    .table-responsive-custom {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive-custom table {
        min-width: 600px;
    }

    /* 모달 반응형 */
    .modal-dialog {
        margin: 0.5rem;
    }

    /* 사이드바 영역 */
    .sidebar-section {
        margin-top: 1rem;
    }
}

/* 모바일 (480px 이하) */
@media (max-width: 480px) {
    .chat-container {
        height: calc(100vh - 240px);
        min-height: 250px;
        padding: 0.75rem;
    }

    .chat-input-area {
        padding: 0.5rem;
        gap: 0.25rem;
    }

    .chat-avatar {
        width: 28px;
        height: 28px;
    }

    .chat-icon {
        width: 28px;
        height: 28px;
    }

    .chat-header-icon {
        width: 32px;
        height: 32px;
    }

    .chat-bubble {
        padding: 0.4rem 0.6rem;
        font-size: 0.9rem;
        max-width: 85%;
    }

    .chat-link-thumb {
        width: 50px;
        height: 60px;
    }

    /* 버튼 크기 조정 */
    .btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.875rem;
    }

    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
    }

    /* 카드 패딩 축소 */
    .card-body {
        padding: 0.75rem;
    }

    .card-header {
        padding: 0.5rem 0.75rem;
    }

    /* 폼 요소 */
    .form-control, .form-select {
        font-size: 16px; /* iOS 확대 방지 */
    }

    /* 페이지 제목 */
    h1, .h1 { font-size: 1.5rem; }
    h2, .h2 { font-size: 1.25rem; }
    h3, .h3 { font-size: 1.1rem; }

    /* 배지 크기 */
    .badge {
        font-size: 0.7rem;
        padding: 0.25rem 0.4rem;
    }
}

/* 초소형 모바일 (360px 이하) */
@media (max-width: 360px) {
    .chat-container {
        height: calc(100vh - 220px);
        padding: 0.5rem;
    }

    .chat-avatar {
        width: 24px;
        height: 24px;
    }

    .chat-icon {
        width: 24px;
        height: 24px;
    }

    .chat-bubble {
        font-size: 0.85rem;
        max-width: 90%;
    }

    .navbar-brand {
        font-size: 1rem;
    }
}
