/*
* 파일명: style.css
* 위치: /p/spellchecker/assets/css/
* 기능: OpenAI 기반 맞춤법 검사기 통합 스타일시트
* 작성일: 2025-08-15
* 수정일: 2025-08-15 (최종 완전 버전)
*/

/* ===================================
* 전역 설정 및 변수
* ===================================
*/

/* CSS 변수 정의 */
:root {
    --primary-color: #0d6efd;
    --success-color: #198754;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #0dcaf0;
    --light-gray: #f8f9fa;
    --border-radius: 8px;
    --box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

/* 전역 스타일 */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f6fa;
    line-height: 1.6;
}

/* ===================================
* 레이아웃 및 카드 스타일
* ===================================
*/

/* 카드 컨테이너 */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* 카드 헤더 */
.card-header {
    border-bottom: 1px solid #e9ecef;
    border-radius: var(--border-radius) var(--border-radius) 0 0 !important;
    background-color: var(--light-gray) !important;
}

/* 카드 바디 */
.card-body {
    padding: 20px;
}

/* ===================================
* 폼 요소 스타일
* ===================================
*/

/* 텍스트 입력 영역 */
#inputText {
    border: 2px solid #e9ecef;
    border-radius: var(--border-radius);
    font-size: 16px;
    padding: 15px;
    resize: vertical;
    transition: border-color 0.3s ease;
}

#inputText:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* 버튼 스타일 */
.btn {
    border-radius: var(--border-radius);
    font-weight: 500;
    padding: 10px 20px;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    transform: none;
}

/* 주요 검사 버튼 */
#checkSpelling {
    font-size: 16px;
    font-weight: 600;
}

/* ===================================
* 진행률 및 통계 표시
* ===================================
*/

/* 진행률 바 */
.progress {
    border-radius: 10px;
    background-color: #e9ecef;
}

.progress-bar {
    border-radius: 10px;
    transition: width 0.3s ease;
}

/* 통계 영역 (하단 - 숨김 처리) */
#statsArea {
    display: none !important;
}

/* ===================================
* 결과 표시 영역 (최대 공간 활용)
* ===================================
*/

/* 결과 컨테이너 (화면 최대 활용) */
.result-content {
    min-height: 600px;
    max-height: 88vh;           /* 화면 높이의 88%로 최대 활용 */
    overflow-y: auto;
    border: 2px solid #e9ecef;
    border-radius: var(--border-radius);
    padding: 12px;              /* 패딩 축소로 공간 확보 */
    background-color: #fff;
    font-size: 16px;
    line-height: 1.8;
}

/* 좌측 입력 영역에 추가되는 하이라이트 결과 */
.highlight-result {
    animation: fadeIn 0.5s ease-out;
}

.highlight-result .original-text-display {
    line-height: 1.8;
    font-size: 16px;
    background-color: var(--light-gray);
    max-height: 80vh;           /* 좌측도 최대 활용 */
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* 원문 텍스트 표시 (좌측 영역: 스크롤 동기화 대상) */
.original-text-display {
    line-height: 1.8;
    font-size: 16px;
    background-color: var(--light-gray);
    max-height: 80vh;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* 교정된 텍스트 표시 */
.corrected-text-display {
    background-color: #ffffff;
    line-height: 1.8;
    font-size: 16px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* 결과 텍스트 박스 */
.result-text-box {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    font-size: 16px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}




/* ===================================
* OpenAI 맞춤법 오류 하이라이팅
* ===================================
*/

/* AI 오류 하이라이팅 */
.highlight-ai-error {
    background-color: #ffebee !important;
    color: #c62828 !important;
    padding: 3px 6px !important;
    border-radius: 4px !important;
    border: 2px solid #e57373 !important;
    font-weight: 600 !important;
    cursor: help !important;
    display: inline !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2) !important;
    transition: all 0.2s ease;
}

.highlight-ai-error:hover {
    background-color: #fff0f0;
    transform: scale(1.02);
}

/* 스크롤 동기화 시 포커스 효과 */
.highlight-focus {
    background-color: #fff3cd !important;
    border-color: #ffc107 !important;
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.3) !important;
    animation: focusPulse 1.5s ease-out;
}

@keyframes focusPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 6px rgba(255, 193, 7, 0.2);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.1);
    }
}

/* AI 적용된 수정사항 */
.highlight-ai-applied {
    background-color: #d4edda;
    color: #155724;
    padding: 2px 4px;
    border-radius: 3px;
    border-bottom: 2px solid #28a745;
    font-weight: 500;
    transition: all 0.2s ease;
}

/* 적용된 수정사항도 포커스 효과 적용 */
.highlight-ai-applied.highlight-focus {
    background-color: #c3e6cb !important;
    border-color: #28a745 !important;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.3) !important;
}

/* ===================================
* 수정사항 목록 스타일 (최대 공간 활용)
* ===================================
*/

/* OpenAI 수정사항 목록 (화면 최대 활용) */
.correction-list-openai {
    max-height: 85vh;           /* 화면 높이의 85%로 최대 활용 */
    overflow-y: auto;
    padding-right: 3px;         /* 스크롤바 여백 */
}

.openai-correction-item {
    transition: all 0.2s ease;
    cursor: pointer;
    margin-bottom: 5px;         /* 간격 최소화 */
}

.openai-correction-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 수정사항 행 (최대 컴팩트) */
.correction-row {
    border: 1px solid #e9ecef;
    background-color: #ffffff !important;
    transition: all 0.2s ease;
    padding: 5px 8px !important;    /* 패딩 최소화 */
}

.correction-row:hover {
    border-color: #007bff;
}

/* 컴팩트 배지 스타일 */
.compact-badge {
    font-size: 0.6rem;          /* 더 작게 */
    padding: 1px 4px;           /* 더 작게 */
    min-width: 25px;
    border-radius: 2px;
}

/* 컴팩트 텍스트 */
.compact-text {
    font-size: 0.85rem;         /* 더 작게 */
    line-height: 1.1;
}

/* 컴팩트 이유 설명 */
.compact-reason {
    font-size: 0.7rem !important;   /* 더 작게 */
    line-height: 1.2;
    margin-top: 2px;
}

/* 적용 버튼 (최대 컴팩트) */
.correction-apply-btn {
    font-size: 0.7rem;          /* 더 작게 */
    padding: 2px 6px;           /* 더 작게 */
    border-radius: 3px;
    font-weight: 500;
    transition: all 0.2s ease;
    min-width: 40px;
}

.correction-apply-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 1px 4px rgba(0, 123, 255, 0.3);
}

/* 적용된 수정사항 */
.correction-applied {
    opacity: 0.7;
    background-color: #f8f9fa !important;
}

.correction-applied .correction-row {
    border-color: #28a745;
    background-color: #f8fff9 !important;
}

.correction-applied .correction-apply-btn {
    cursor: not-allowed;
    background-color: #28a745;
    border-color: #28a745;
}




/* ===================================
* 컴팩트 통계 영역 (더욱 압축)
* ===================================
*/

.compact-stats {
    font-size: 0.75rem;         /* 더 작게 */
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    margin-bottom: 10px !important;  /* 간격 최소화 */
    padding: 8px !important;    /* 패딩 축소 */
}

.compact-stats .stat-item {
    padding: 3px 5px;           /* 더 작게 */
}

.compact-stats .stat-number {
    font-size: 0.95rem;         /* 더 작게 */
    line-height: 1.1;
    margin-bottom: 1px;
}

.compact-stats .stat-label {
    font-size: 0.6rem;          /* 더 작게 */
    line-height: 1;
    font-weight: 500;
}

.compact-stats .service-info {
    font-size: 0.6rem;          /* 더 작게 */
    padding-top: 4px;           /* 간격 축소 */
    margin-top: 4px;
}

/* 컴팩트 통계 호버 효과 */
.compact-stats .stat-item:hover {
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 3px;
    transition: all 0.2s ease;
}


/* ===================================
* 전체복사/전체수정 버튼 스타일
* ===================================
*/

/* 좌측 전체복사 버튼 */
#copyResult {
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    min-width: 90px;
}

#copyResult:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* 우측 전체수정 버튼 */
#applyAllButton {
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    min-width: 90px;
}

#applyAllButton:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

#applyAllButton:disabled {
    transform: none;
    opacity: 0.7;
    cursor: not-allowed;
}

/* 로딩 중 애니메이션 */
#applyAllButton .bi-hourglass-split {
    animation: rotate 1s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* 전체수정 버튼 색상 (노란색) */
#applyAllButton.btn-warning {
    background-color: #ffc107;
    border-color: #ffc107;
    color: #000;
}

#applyAllButton.btn-warning:hover {
    background-color: #ffca2c;
    border-color: #ffc720;
    color: #000;
}

/* 완료된 전체수정 버튼 (초록색) */
#applyAllButton.btn-success {
    background-color: #198754;
    border-color: #198754;
    color: #fff;
}

#applyAllButton.btn-success:hover {
    background-color: #157347;
    border-color: #146c43;
}

/* ===================================
* 스크롤바 스타일
* ===================================
*/

/* 모든 스크롤 영역 스크롤바 통일 */
.result-content::-webkit-scrollbar,
.correction-list-openai::-webkit-scrollbar,
.original-text-display::-webkit-scrollbar {
    width: 8px;
}

.result-content::-webkit-scrollbar-track,
.correction-list-openai::-webkit-scrollbar-track,
.original-text-display::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.result-content::-webkit-scrollbar-thumb,
.correction-list-openai::-webkit-scrollbar-thumb,
.original-text-display::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.result-content::-webkit-scrollbar-thumb:hover,
.correction-list-openai::-webkit-scrollbar-thumb:hover,
.original-text-display::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* ===================================
* 애니메이션 효과
* ===================================
*/

/* 페이드인 애니메이션 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* 로딩 스피너 */
.spinner-border {
    animation: spinner-border 0.75s linear infinite;
}

@keyframes spinner-border {
    to { transform: rotate(360deg); }
}

/* 성공 아이콘 애니메이션 */
.check-circle-fill {
    animation: bounceIn 0.6s ease-out;
}

@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ===================================
* 반응형 디자인
* ===================================
*/

/* 태블릿 */
@media (max-width: 768px) {
    .container-fluid {
        padding: 0;
    }
    
    .container {
        padding: 0 15px;
    }
    
    header h1 {
        font-size: 1.5rem !important;
    }
    
    #inputText {
        font-size: 16px; /* iOS zoom 방지 */
    }
    
    .result-content {
        max-height: 60vh;       /* 태블릿에서 조정 */
    }

    /* 좌우 스크롤 영역 높이 동일화 */
    .original-text-display,
    .correction-list-openai {
        max-height: 50vh;       /* 태블릿에서 조정 */
    }

    /* 모바일에서는 좌우 배치를 세로 배치로 변경 */
    .row .col-md-6 {
        margin-bottom: 20px;
    }

    .row .col-md-6:last-child {
        margin-bottom: 0;
    }
    
    .btn {
        padding: 8px 16px;
        font-size: 14px;
    }

    /* 컴팩트 통계 모바일 최적화 */
    .compact-stats .stat-number {
        font-size: 1rem !important;
    }

    .compact-stats .stat-label {
        font-size: 0.65rem !important;
    }

    /* 수정사항 세로 배치 */
    .correction-row {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 8px;
    }
    
    .correction-action {
        width: 100%;
        display: flex;
        justify-content: flex-end;
    }
}

/* 모바일 */
@media (max-width: 576px) {
    .card-body {
        padding: 15px;
    }
    
    /* 좌우 스크롤 영역 높이 추가 조정 */
    .result-content {
        max-height: 50vh;       /* 모바일에서 조정 */
    }
    
    .original-text-display,
    .correction-list-openai {
        max-height: 40vh;       /* 모바일에서 조정 */
    }

    /* 수정사항 아이템 간격 조정 */
    .openai-correction-item {
        margin-bottom: 6px !important;
    }

    /* 컴팩트 요소들 모바일 최적화 */
    .compact-badge {
        font-size: 0.6rem;
        min-width: 25px;
        padding: 1px 4px;
    }

    .compact-text {
        font-size: 0.85rem;
    }

    .compact-reason {
        font-size: 0.7rem !important;
    }

    .correction-apply-btn {
        font-size: 0.7rem;
        padding: 3px 8px;
        min-width: 45px;
    }

    /* 전체복사 버튼 모바일 최적화 */
    #copyResult {
        font-size: 0.8rem !important;
        padding: 4px 8px !important;
    }
    
    /* 버튼 세로 배치 */
    .d-flex.gap-2 {
        flex-direction: column;
    }
    
    .d-flex.gap-2 .btn {
        margin-bottom: 10px;
    }
    
    .d-flex.gap-2 .btn:last-child {
        margin-bottom: 0;
    }
}


/* ===================================
* 유틸리티 및 접근성
* ===================================
*/

/* 포커스 스타일 */
.btn:focus,
.form-control:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* 스크린 리더 전용 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===================================
* 프린트 스타일
* ===================================
*/
@media print {
    .btn,
    .modal,
    header,
    footer {
        display: none !important;
    }
    
    .card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
    }
    
    .highlight-ai-error,
    .highlight-ai-applied {
        background: none !important;
        color: #000 !important;
        border-bottom: 1px solid #000 !important;
    }
}


/* ===================================
* 구글 애드센스 광고 영역
* ===================================
*/

/* 광고 컨테이너 */
.adsense-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 15px;
    background-color: #fafafa;
    border: 1px solid #e9ecef;
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
}

/* 광고 단위 스타일 */
.adsense-ad-unit {
    min-height: 280px;          /* 광고 최소 높이 (레이아웃 시프트 방지) */
    max-height: 400px;          /* 광고 최대 높이 */
    overflow: hidden;
    background-color: #ffffff;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* AdSense 광고 스타일 */
.adsbygoogle {
    display: block !important;
    width: 100%;
    min-height: 250px;
}

/* 광고 라벨 */
.adsense-container .text-muted {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.7;
}

/* 데모 광고 (테스트용) */
.demo-ad {
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 광고 로딩 애니메이션 */
.adsense-ad-unit::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0d6efd;
    border-radius: 50%;
    animation: adsense-spin 1s linear infinite;
    opacity: 0.5;
    z-index: 1;
}

/* 광고 로딩 완료 시 애니메이션 제거 */
.adsense-ad-unit.loaded::before {
    display: none;
}

@keyframes adsense-spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* 반응형 광고 스타일 */
@media (max-width: 768px) {
    .adsense-container {
        padding: 12px;
        margin-top: 15px;
    }
    
    .adsense-ad-unit {
        min-height: 250px;
        max-height: 300px;
    }
    
    .adsbygoogle {
        min-height: 200px;
    }
}

@media (max-width: 576px) {
    .adsense-container {
        padding: 10px;
        margin-top: 10px;
    }
    
    .adsense-ad-unit {
        min-height: 200px;
        max-height: 250px;
    }
    
    .adsbygoogle {
        min-height: 150px;
    }
}

/* 광고 호버 효과 */
.adsense-container:hover {
    border-color: #dee2e6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
