/**
 * 병원 서류 전문 분석 시스템 스타일
 * 기본 배경: 흰색
 * 레이아웃: 좌측 업로드, 우측 검색결과
 */

/* 🎨 타이포그래피 강화 - 최신 웹 디자인 트렌드 적용 */
body.hospital-document-ai-page {
    font-family: 'Pretendard Variable', 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
    font-size: 16px;
    line-height: 1.75; /* 가독성 향상 */
    color: #1a202c;
    background-color: #ffffff;
    font-weight: 400;
    letter-spacing: -0.01em; /* 한글 최적화 자간 */
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "liga" 1, "kern" 1; /* 리거처, 커닝 활성화 */
}

html {
    background-color: #ffffff;
}

/* 메인 래퍼 */
.hospital-document-ai-wrapper {
    min-height: calc(100vh - 200px);
    padding-top: 72px; /* 헤더 높이만큼 여백 (살짝 축소) */
    padding-bottom: 32px;
    background-color: #ffffff; /* 흰색 배경 */
}

/* 페이지 타이틀 */
.hospital-page-title {
    background: linear-gradient(180deg, #f9fafb 0%, #ffffff 70%);
    color: #111827;
    padding: 10px 0 10px;
    margin-bottom: 18px;
    border-bottom: 1px solid #e5e7eb;
}

.hospital-title-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: flex-start;
}

.hospital-title-icon {
    width: 50px;
    height: 50px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.12), rgba(118, 75, 162, 0.12));
    color: #4c51bf;
    font-size: 32px;
    margin-top: 40px;
}

.hospital-title-text {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hospital-title-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem; /* 13px */
    font-weight: 650; /* 세밀한 weight 조정 */
    color: #374151;
    padding: 6px 14px;
    border-radius: 999px;
    background: #eef2ff;
    width: fit-content;
    letter-spacing: 0.01em; /* 뱃지용 살짝 넓은 자간 */
    text-transform: uppercase;
    font-feature-settings: "smcp" 1; /* Small Caps */
}

.hospital-title-badge i {
    color: #4c51bf;
}

.hospital-title-heading {
    display: flex;
    align-items: center;
    gap: 1px;
    flex-wrap: wrap;
}

.hospital-title-heading h1 {
    font-size: 1.45rem;
    font-weight: 800; /* 더 강한 weight */
    margin: 0;
    color: #0f172a;
    letter-spacing: -0.03em; /* 타이틀용 타이트한 자간 */
    line-height: 1.2;
    font-feature-settings: "ss01" 1; /* Stylistic Set 활성화 */
}

.hospital-title-subtext {
    font-size: 0.9375rem; /* 15px */
    font-weight: 450; /* 세밀한 조정 */
    color: #64748b;
    margin: 0;
    line-height: 1.65;
    letter-spacing: -0.005em;
}

/* ========= 반응형 튜닝: 히어로(타이틀) 영역 컴팩트화 ========= */

@media (max-width: 991.98px) {
    .hospital-document-ai-wrapper {
        padding-top: 64px;
        padding-bottom: 28px;
    }

    .hospital-title-inner {
        gap: 18px;
    }

    .hospital-title-heading h1 {
        font-size: 1.9rem;
    }
}

@media (max-width: 767.98px) {
    .hospital-page-title {
        padding: 10px 0 12px;
        margin-bottom: 0px;
    }

    .hospital-title-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .hospital-title-icon {
        width: 56px;
        height: 56px;
        font-size: 26px;
        border-radius: 16px;
    }

    .hospital-title-badge {
        font-size: 0.8rem;
        padding: 4px 10px;
    }

    .hospital-title-heading h1 {
        font-size: 1.3rem;
    }

    .hospital-title-subtext {
        font-size: 0.875rem;
        max-width: 100%;
    }

    .welcome-message {
        margin-top: 50px;
        margin-left: 20px;
    }
}

@media (max-width: 575.98px) {
    .hospital-document-ai-wrapper {
        padding-top: 56px;
        padding-bottom: 20px;
    }

    .hospital-title-heading {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .hospital-title-subtext {
        margin-top: 4px;
    }
}

/* 메인 컨테이너 */
.hospital-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 기본적으로 모바일 도구바는 숨김 (부트스트랩 유무와 관계없이 PC에서 노출 방지) */
.mobile-doc-toolbar {
    display: none;
}

.hospital-container .row {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
}

/* Bootstrap 그리드 시스템 정상 작동 보장 */
.hospital-container .row [class*="col-"] {
    padding-left: 15px;
    padding-right: 15px;
    position: relative;
    width: 100%;
}

/* Bootstrap 그리드 시스템 강제 적용 */
.hospital-container .row .col-lg-3 {
    flex: 0 0 25%;
    max-width: 25%;
}

.hospital-container .row .col-lg-9 {
    flex: 0 0 75%;
    max-width: 75%;
}

@media (min-width: 992px) {
    .hospital-container .row .col-lg-3 {
        flex: 0 0 25%;
        max-width: 25%;
    }
    
    .hospital-container .row .col-lg-9 {
        flex: 0 0 75%;
        max-width: 75%;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    .hospital-container .row .col-md-4 {
        flex: 0 0 33.333333%;
        max-width: 33.333333%;
    }
    
    .hospital-container .row .col-md-8 {
        flex: 0 0 66.666667%;
        max-width: 66.666667%;
    }
}

/* 왼쪽 사이드바 (업로드 영역) */
.hospital-sidebar {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    padding: 25px;
    height: fit-content;
    max-height: calc(100vh - 250px);
    overflow-y: auto;
    /* Bootstrap 그리드 시스템 사용 - width는 col-lg-3에서 자동 설정됨 */
}

.sidebar-title {
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-title i {
    color: #667eea;
}

/* 서비스 버튼 */
.service-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 25px;
}

@media (max-width: 575.98px) {
    .service-buttons {
        grid-template-columns: minmax(0, 1fr);
    }
}

.service-btn {
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px 18px;
    text-align: left;
    font-size: 0.9375rem; /* 15px */
    font-weight: 550; /* 세밀한 weight */
    color: #334155;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 12px;
    letter-spacing: -0.01em;
    line-height: 1.5;
}

.service-btn:hover {
    border-color: #f8ab1b;
    background: #f9fafb;
    transform: translateX(4px);
}

.service-btn.active {
    background: linear-gradient(135deg, #6ea80f 0%, #49a80a 100%);
    color: white;
    border-color: #a1a1a1;
}

.service-btn i {
    font-size: 1.1rem;
}

/* 업로드 영역 */
.upload-section {
    margin-bottom: 25px;
}

.upload-zone {
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f9fafb;
    position: relative;
    overflow: hidden;
}

.upload-zone::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.upload-zone:hover::before {
    opacity: 1;
}

.upload-zone:hover {
    border-color: #667eea;
    background: #f3f4f6;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.upload-zone.dragover {
    border-color: #667eea;
    background: #eef2ff;
    border-style: solid;
    transform: scale(1.02);
}

.upload-zone.dragover::before {
    opacity: 1;
}

.upload-zone i {
    color: #667eea;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
    transition: transform 0.3s ease;
}

.upload-zone:hover i {
    transform: scale(1.1);
}

.upload-zone p {
    margin: 6px 0;
    color: #6b7280;
    position: relative;
    z-index: 1;
    font-size: 0.9rem;
}

.upload-zone p:first-of-type {
    font-weight: 500;
    color: #374151;
}

.upload-zone .text-muted {
    font-size: 0.85rem;
    color: #9ca3af;
}

/* 파일 입력 숨김 */
#fileInput {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    /* pointer-events: none 제거 - JavaScript에서 click() 호출 시 필요 */
}

/* 문서 목록 */
.document-list {
    margin-top: 25px;
}

.document-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.document-item {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    cursor: default;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.document-item:hover {
    background: #f3f4f6;
    border-color: #667eea;
}

.document-item.active {
    background: #eef2ff;
    border-color: #667eea;
}

.document-icon {
    font-size: 1.5rem;
    color: #667eea;
}

.document-info {
    flex: 1;
}

.document-name {
    font-size: 0.9375rem; /* 15px */
    font-weight: 600; /* 더 강한 weight */
    color: #1e293b;
    margin-bottom: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: -0.015em;
    line-height: 1.4;
}

.document-meta {
    font-size: 0.8125rem; /* 13px */
    font-weight: 450;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    letter-spacing: 0;
    line-height: 1.5;
}

.document-meta-left {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.document-meta .badge {
    font-size: 0.75rem;
    padding: 4px 8px;
}

.document-time {
    font-size: 0.78rem;
    color: #94a3b8;
}

.document-delete-btn {
    border: none;
    background: transparent;
    color: #9ca3af;
    font-size: 0.85rem;
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.document-delete-btn:hover {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.1);
}

.document-delete-btn:active {
    transform: scale(0.95);
}

.document-actions {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-extract {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 10px;
    border: 1px solid #3b82f6;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #ffffff;
    font-size: 0.9375rem; /* 15px */
    font-weight: 650; /* 더 강한 weight */
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 6px 14px rgba(59, 130, 246, 0.25);
    letter-spacing: -0.01em;
    line-height: 1.4;
}

.btn-extract:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.28);
}

.btn-extract:disabled {
    cursor: not-allowed;
    background: #e2e8f0;
    border-color: #cbd5f5;
    color: #94a3b8;
    box-shadow: none;
    transform: none;
}

.btn-reset {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid #64748b;
    background: #ffffff;
    color: #64748b;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 2px 6px rgba(100, 116, 139, 0.15);
}

.btn-reset:hover {
    transform: translateY(-1px);
    background: #f8fafc;
    border-color: #475569;
    color: #475569;
    box-shadow: 0 4px 10px rgba(100, 116, 139, 0.2);
}

.btn-reset:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(100, 116, 139, 0.15);
}

.btn-reset:disabled {
    cursor: not-allowed;
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #cbd5e1;
    box-shadow: none;
    transform: none;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge i {
    font-size: 0.7rem;
}

.status-pending {
    background: #fef3c7;
    color: #d97706;
}

.status-completed {
    background: #dcfce7;
    color: #15803d;
}

.status-failed {
    background: #fee2e2;
    color: #b91c1c;
}

.document-retention-hint {
    margin-top: 12px;
    font-size: 0.82rem;
    color: #6b7280;
}

/* 우측 AI 분석 및 질문 입력 영역 */
.hospital-chat {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    padding: 0;
    display: flex;
    flex-direction: column;
    /* Bootstrap 그리드 시스템 사용 - width는 col-lg-9에서 자동 설정됨 */
}

.chat-header {
    padding: 20px 25px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    border-radius: 12px 12px 0 0;
}

.chat-header h5 {
    margin: 0;
    font-weight: 600;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-header h5 i {
    color: #16a34a; /* 녹색 계열로 변경 */
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-header-icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: #4b5563;
}

.chat-header-icon-btn i {
    font-size: 0.9rem;
}

.chat-header-icon-btn:hover {
    border-color: #667eea;
    background: #eef2ff;
    color: #3730a3;
}

.chat-header .btn {
    border-color: #e5e7eb;
    color: #6b7280;
    font-size: 0.85rem;
}

.chat-header .btn:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.chat-messages {
    flex: 0 0 auto;
    overflow-y: auto;
    padding: 25px 20px 25px 5px; /* 상, 우, 하, 좌 (좌측 5px / 우측 20px) */
    background: #ffffff;
    min-height: 260px;
}

.welcome-message {
    text-align: center;
    color: #6b7280;
}

.welcome-message i {
    color: #16a34a;
    margin-bottom: 20px;
}

.welcome-message h4 {
    color: #374151;
    font-weight: 600;
    margin-bottom: 15px;
}

.usage-guide {
    margin: 5px auto 5px;
    max-width: 840px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    text-align: left;
}

.usage-step {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    min-height: 112px;
}

.usage-step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981 0%, #22c55e 100%); /* 청록-그린 계열 */
    color: #ffffff;
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.22);
}

.usage-step-body strong {
    display: block;
    font-size: 1rem;
    font-weight: 650; /* 더 강한 weight */
    color: #0f172a;
    margin-bottom: 6px;
    letter-spacing: -0.015em;
    line-height: 1.4;
}

.usage-step-body p {
    margin: 0;
    color: #475569;
    font-size: 0.9rem;
    font-weight: 450;
    line-height: 1.65;
    letter-spacing: -0.005em;
}

/* 개인정보 처리 안내 */
.privacy-notice {
    margin-top: 10px;
    padding: 24px 26px;
    background: #f8fafc;
    border: 1px solid #dbeafe;
    border-radius: 14px;
    text-align: left;
    max-width: 840px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 6px 18px rgba(191, 219, 254, 0.25);
}

.privacy-notice-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 18px;
    color: #0f172a;
    font-size: 1.05rem;
}

.privacy-notice-header > div p {
    margin: 6px 0 0;
    font-size: 0.9rem;
    color: #475569;
}

.privacy-lock {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(37, 99, 235, 0.12));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1d4ed8;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.18);
}

.privacy-list {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.privacy-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0px 0px 0px 20px;
}

.privacy-step {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
    color: #ffffff;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.25);
    flex-shrink: 0;
}

.privacy-list li strong {
    display: block;
    color: #1f2937;
    font-size: 1rem;
    margin-bottom: 4px;
}

.privacy-list li p {
    margin: 0;
    font-size: 0.92rem;
    color: #4b5563;
    line-height: 1.6;
}

.analysis-prompt {
    margin: 20px 0;
    padding: 18px 20px;
    border: 1px solid #c7d2fe;
    border-radius: 12px;
    background: #eef2ff;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.analysis-prompt.active {
    display: flex;
}

.analysis-prompt .analysis-text {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #312e81;
    font-size: 0.95rem;
}

.analysis-prompt .analysis-text i {
    font-size: 1.1rem;
}

.analysis-prompt-actions {
    display: flex;
    gap: 10px;
}

.analysis-prompt-actions button {
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}

.analysis-prompt-actions button.analysis-yes {
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.analysis-prompt-actions button.analysis-yes:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(67, 56, 202, 0.3);
}

.analysis-prompt-actions button.analysis-no {
    background: #ffffff;
    color: #4b5563;
    border-color: #cbd5f5;
}

.analysis-prompt-actions button.analysis-no:hover {
    background: #f8fafc;
}

.document-preview-card {
    margin-bottom: 20px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
    overflow: hidden;
}

.document-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
    gap: 12px;
}

.document-preview-body {
    padding: 16px 18px;
    max-height: 260px;
    overflow-y: auto;
    font-family: 'D2Coding', 'Pretendard', monospace;
    font-size: 0.92rem;
    line-height: 1.6;
    color: #334155;
    white-space: pre-wrap;
    word-break: break-word;
}

.document-preview-body .highlight {
    background: #fef3c7;
    color: #92400e;
    padding: 2px 4px;
    border-radius: 4px;
}

.message {
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message.ai .message-avatar {
    background: #f3f4f6;
    color: #667eea;
}

.message-content {
    flex: 1;
    background: #f9fafb;
    padding: 16px 20px;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    max-width: 75%;
    border: 1px solid #e5e7eb;
    font-size: 0.9375rem; /* 15px */
    font-weight: 450;
    line-height: 1.75;
    letter-spacing: -0.01em;
    word-wrap: break-word;
    white-space: normal; /* 줄바꿈 허용 */
}

/* AI 메시지에서는 아이콘(아바타)을 숨겨 공간 확보 */
.message.ai .message-avatar {
    display: none;
}

/* 마크다운 요소 스타일링 */
.message-content h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 24px 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #e5e7eb;
    color: #111827;
    line-height: 1.4;
}

.message-content h2:first-child {
    margin-top: 0;
}

.message-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 20px 0 12px 0;
    color: #1f2937;
    line-height: 1.4;
}

.message-content h4 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 16px 0 10px 0;
    color: #374151;
    line-height: 1.4;
}

.message-content p {
    margin: 12px 0;
    line-height: 1.8;
    text-align: justify;
}

.message-content p:first-child {
    margin-top: 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul,
.message-content ol {
    margin: 12px 0;
    padding-left: 24px;
    line-height: 1.8;
}

.message-content li {
    margin: 8px 0;
    line-height: 1.8;
    text-align: left;
}

.message-content li::marker {
    color: #667eea;
    font-weight: 600;
}

.message-content strong {
    font-weight: 600;
    color: #111827;
}

.message-content em {
    font-style: italic;
    color: #4b5563;
}

.message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
}

.message-text {
    margin: 0;
    line-height: 1.75; /* 향상된 줄간격 */
    font-size: 0.9375rem; /* 15px */
    font-weight: 450;
    color: #1e293b;
    letter-spacing: -0.01em;
    word-wrap: break-word;
}

.message-time {
    display: none; /* 휘발성 세션 환경에서는 시간 텍스트를 숨겨 공간 확보 */
}

/* 입력 영역 */
.chat-input-area {
    padding: 14px 16px 18px;
    border-top: none;
    background: #ffffff;
    border-radius: 0 0 12px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chat-input-wrapper {
    position: relative;
    display: flex;
    align-items: flex-end;
    background: #f9fafb;
    border-radius: 999px;
    padding: 12px 64px 12px 18px;
    border: 2px solid #cbd5e1;
    transition: all 0.25s ease;
    width: 100%;
    max-width: 720px;
}

.chat-input-wrapper:focus-within {
    border-color: #16a34a;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.18);
    background: #ffffff;
}

.chat-input-textarea {
    width: 100%;
    resize: none;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.9rem;
    line-height: 1.6;
    max-height: 120px;
    color: #111827;
    font-family: 'Pretendard', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.chat-input-textarea::placeholder {
    color: #9ca3af;
    font-size: 0.85rem;
    font-weight: 400;
    letter-spacing: -0.01em;
}

/* 병원 서류 AI 페이지에서 텍스트 영역 포커스 아웃라인 제거 (헤더 전역 CSS 오버라이드) */
body.hospital-document-ai-page textarea:focus,
body.hospital-document-ai-page textarea:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

.chat-send-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, #16a34a 0%, #22c55e 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(22, 163, 74, 0.30);
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.chat-send-btn i {
    font-size: 0.9rem;
}

.chat-send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(22, 163, 74, 0.45);
}

.chat-send-btn:active {
    transform: translateY(0);
    box-shadow: 0 3px 8px rgba(22, 163, 74, 0.3);
}

.input-hints {
    margin-top: 8px;
    text-align: left;
    width: 100%;
    max-width: 720px;
}

.input-hints small {
    color: #9ca3af;
    font-size: 0.85rem;
    letter-spacing: -0.01em;
}

/* 개인정보 안내 버튼 (좌측 하단 가이드) */
.privacy-guide-btn {
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    font-size: 0.85rem;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.2s ease;
}

.privacy-guide-btn i {
    color: #4c51bf;
    font-size: 0.9rem;
}

.privacy-guide-btn:hover {
    border-color: #667eea;
    background: #eef2ff;
    color: #111827;
}

.privacy-modal-body {
    padding-top: 10px;
}

/* ===================== 모바일 전용 하단 도구바 ===================== */
@media (max-width: 768px) {
    .hospital-sidebar {
        display: none;
    }

    .hospital-chat {
        margin-bottom: 82px; /* 하단 도구바 공간 확보 */
        border: none;
        border-radius: 0;
        box-shadow: none;
    }

    .mobile-doc-toolbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        height: 72px;
        background: #ffffff;
        border-top: 1px solid #e5e7eb;
        display: flex;
        align-items: center;
        padding: 8px 10px;
        gap: 8px;
        z-index: 1001;
    }

    .mobile-service-scroll {
        display: flex;
        flex: 1.5;
        overflow-x: auto;
        gap: 6px;
        padding-right: 4px;
        scrollbar-width: none; /* Firefox: hide scrollbar */
    }

    .mobile-service-scroll::-webkit-scrollbar {
        height: 0; /* Chrome/Safari: hide scrollbar */
    }
    .mobile-service-scroll::-webkit-scrollbar-thumb {
        background: transparent;
        border-radius: 999px;
    }

    .mobile-service-btn {
        border: 1px solid #e5e7eb;
        background: #f9fafb;
        border-radius: 999px;
        padding: 6px 10px;
        font-size: 0.78rem;
        color: #4b5563;
        display: inline-flex;
        align-items: center;
        gap: 4px;
        white-space: nowrap;
    }

    .mobile-service-btn i {
        font-size: 0.85rem;
    }

    .mobile-service-btn.active {
        border-color: #4f46e5;
        background: #eef2ff;
        color: #3730a3;
    }

    .mobile-doc-actions {
        display: flex;
        gap: 6px;
    }

    .mobile-upload-btn,
    .mobile-reset-btn,
    .mobile-extract-btn {
        width: 32px;
        height: 32px;
        border-radius: 999px;
        border: 1px solid #e5e7eb;
        background: #f9fafb;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        color: #4b5563;
    }

    .mobile-upload-btn i,
    .mobile-reset-btn i,
    .mobile-extract-btn i {
        font-size: 0.9rem;
    }

    .mobile-upload-btn:hover,
    .mobile-reset-btn:hover,
    .mobile-extract-btn:hover {
        border-color: #16a34a;
        background: #ecfdf3;
        color: #166534;
    }

    /* 하단 도구바와 겹치지 않도록 입력 영역 하단 여백 보정 */
    .chat-input-area {
        padding-bottom: 90px;
    }
}

/* 로딩 스피너 */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(102, 126, 234, 0.3);
    border-radius: 50%;
    border-top-color: #667eea;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 반응형 디자인 */
@media (max-width: 992px) {
    .hospital-chat {
        height: auto;
        min-height: 500px;
    }
    
    .hospital-sidebar {
        max-height: none;
        margin-bottom: 20px;
    }
}

@media (max-width: 768px) {
    .hospital-document-ai-wrapper {
        padding-top: 50px;
    }
    
    .hospital-container {
        padding: 0;
    }

    .hospital-container .row.g-4 > main.hospital-chat {
        padding-left: 0;
        padding-right: 0;
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    .hospital-title-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .hospital-title-subtext {
        display: none;
    }
    
    .usage-guide {
        grid-template-columns: 1fr;
        gap: 8px;
        margin: 8px 0 12px;
        text-align: left;
        justify-items: flex-start;
        margin-left: 70px;
    }
    
    .usage-step {
        padding: 2px 0;
        min-height: auto;
        background: transparent;
        border: none;
        box-shadow: none;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 6px;
    }

    .usage-step-number {
        width: 26px;
        height: 26px;
        font-size: 0.85rem;
    }

    .usage-step-body strong {
        text-align: center;
        display: inline-block;
        margin-bottom: 0;
        color: #6b6b6b;
    }
    
    .usage-step-number {
        width: 28px;
        height: 28px;
        font-size: 0.85rem;
    }

    .privacy-notice {
        padding: 22px 20px;
    }

    .privacy-notice-header {
        gap: 12px;
        font-size: 1rem;
    }

    .privacy-notice-header > div p {
        font-size: 0.85rem;
    }
    
    .privacy-lock {
        width: 40px;
        height: 40px;
        font-size: 1.05rem;
    }
    
    .privacy-list {
        flex-direction: column;
        gap: 10px;
    }
    
    .privacy-list li {
        border-radius: 12px;
        align-items: flex-start;
    }
    
    .privacy-step {
        width: 26px;
        height: 26px;
        font-size: 0.82rem;
    }
    
    .privacy-list li strong {
        font-size: 0.95rem;
    }
    
    .privacy-list li p {
        font-size: 0.88rem;
    }
    
    .analysis-prompt {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .analysis-prompt-actions {
        width: 100%;
        justify-content: flex-start;
    }
    
    .hospital-title-heading {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .hospital-title-icon {
        width: 56px;
        height: 56px;
        font-size: 24px;
    }
    
    .hospital-title-text {
        align-items: flex-start;
    }

    .hospital-sidebar {
        margin-bottom: 15px;
    }
    
    .chat-header {
        padding: 12px 16px;
        border-bottom: none;
        border-radius: 0;
        background: transparent;
    }

    .chat-messages {
        padding: 5px 5px 5px;
        background: transparent;
    }

    .message-content {
        max-width: 100%;
        border: none;
        box-shadow: none;
        background: transparent;
        padding: 5px;
    }

    .message-content h2 {
        border-bottom: none;
        padding-bottom: 0;
    }


    .chat-header {
        background-color: #88c11d;
    }

    .chat-header h5 i {
        color: #ffffff;
    }

    .chat-header h5 {
        font-size: 1rem;
    }

}

/* 스크롤바 스타일링 */
.hospital-sidebar::-webkit-scrollbar,
.hospital-chat .chat-messages::-webkit-scrollbar {
    width: 6px;
}

.hospital-sidebar::-webkit-scrollbar-track,
.hospital-chat .chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.hospital-sidebar::-webkit-scrollbar-thumb,
.hospital-chat .chat-messages::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.hospital-sidebar::-webkit-scrollbar-thumb:hover,
.hospital-chat .chat-messages::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}
