/* Simply. U+ 텍스트 분석기 스타일시트 */

/* CSS 리셋 및 기본 설정 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 브라우저 호환성을 위한 기본 폰트 설정 */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
        sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 컨테이너 레이아웃 */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 헤더 스타일 */
header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 0;
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 10px;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 300;
}

/* 메인 콘텐츠 */
main {
    flex: 1;
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

/* 입력 섹션 */
.input-section {
    margin-bottom: 30px;
}

.input-wrapper {
    position: relative;
    margin-bottom: 20px;
}

#textInput {
    width: 100%;
    padding: 20px;
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    min-height: 150px;
    transition: all 0.3s ease;
    background: #fafbfc;
}

#textInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background: white;
}

#textInput::placeholder {
    color: #8b95a1;
}

#textInput:disabled {
    background: #f7fafc;
    color: #8b95a1;
    cursor: not-allowed;
    opacity: 0.7;
}

/* 글자 수 카운터 */
.char-counter {
    position: absolute;
    bottom: 10px;
    right: 15px;
    font-size: 14px;
    color: #8b95a1;
    background: rgba(255, 255, 255, 0.9);
    padding: 4px 8px;
    border-radius: 6px;
    backdrop-filter: blur(4px);
    transition: all 0.3s ease;
}

.char-counter.near-limit {
    color: #ed8936;
    background: rgba(255, 235, 204, 0.9);
}

.char-counter.limit-reached {
    color: #e53e3e;
    background: rgba(255, 235, 235, 0.9);
    font-weight: 600;
}

/* 300자 초과 경고 메시지 */
.char-limit-warning {
    position: absolute;
    top: -40px;
    right: 0;
    background: #e53e3e;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    z-index: 10;
    animation: slideInWarning 0.3s ease-out;
}

.char-limit-warning::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #e53e3e;
}

@keyframes slideInWarning {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 분석 버튼 */
.analyze-btn {
    width: 100%;
    padding: 18px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.analyze-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}

.analyze-btn:active:not(:disabled) {
    transform: translateY(0);
}

.analyze-btn:disabled,
.analyze-btn.disabled {
    background: #e1e5e9;
    color: #8b95a1;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.7;
}

/* 로딩 중인 버튼 스타일 */
.analyze-btn.loading {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: not-allowed;
    position: relative;
    opacity: 0.8;
}

.analyze-btn.loading::after {
    content: '';
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* 로딩 섹션 */
.loading-section {
    text-align: center;
    padding: 40px 20px;
}

/* 로딩 스피너 애니메이션 */
.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e1e5e9;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading-text {
    font-size: 18px;
    color: #667eea;
    font-weight: 500;
}

/* 결과 섹션 */
.result-section {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid #e1e5e9;
}

.result-section h2 {
    color: #333;
    margin-bottom: 25px;
    font-size: 24px;
    font-weight: 600;
}

.original-text {
    margin-bottom: 25px;
    padding: 20px;
    background: #fafbfc;
    border-radius: 12px;
    border-left: 4px solid #667eea;
}

.original-text h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: 600;
}

#originalText {
    line-height: 1.7;
    color: #333;
}

/* AI 분석 결과 카드 스타일 */
.analysis-result {
    margin-bottom: 25px;
    padding: 0;
    background: white;
    border: none;
    border-radius: 0;
}

.analysis-result h3 {
    color: #333;
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 600;
    background: white;
    padding: 0;
    margin: 0 0 20px 0;
}

/* 감정 분석 결과 카드 */
.emotion-card {
    background: linear-gradient(135deg, #e91e63 0%, #f06292 50%, #f8bbd9 100%);
    border-radius: 20px;
    padding: 60px 40px;
    text-align: center;
    box-shadow: 0 15px 35px rgba(233, 30, 99, 0.3);
    margin: 20px 0;
    position: relative;
    overflow: hidden;
}

.emotion-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    pointer-events: none;
}

.emotion-text {
    font-size: 2rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    letter-spacing: 0.05em;
    position: relative;
    z-index: 1;
    margin: 0;
    line-height: 1.2;
}

#analysisResult {
    line-height: 1.7;
    color: #333;
}

/* 오류 섹션 */
.error-section {
    text-align: center;
    padding: 40px 20px;
    background: #fff5f5;
    border-radius: 12px;
    border: 2px solid #fed7d7;
    margin-top: 30px;
}

.error-section h2 {
    color: #e53e3e;
    margin-bottom: 15px;
    font-size: 20px;
}

#errorMessage {
    color: #c53030;
    margin-bottom: 20px;
    font-size: 16px;
}

.retry-btn {
    padding: 12px 24px;
    background: #e53e3e;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

/* 푸터 */
footer {
    text-align: center;
    padding: 20px 0;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
}

/* JavaScript 비활성화 메시지 */
.noscript-message {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    text-align: center;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
}

.noscript-message h2 {
    font-size: 28px;
    margin-bottom: 20px;
    color: #fed7d7;
    font-weight: 600;
}

.noscript-message p {
    font-size: 18px;
    max-width: 600px;
    line-height: 1.7;
    margin-bottom: 15px;
}

.noscript-message .instructions {
    font-size: 16px;
    color: #e2e8f0;
    max-width: 500px;
    margin-top: 20px;
}

.noscript-message .browser-list {
    list-style: none;
    padding: 0;
    margin: 20px 0;
    font-size: 14px;
    color: #cbd5e0;
}

.noscript-message .browser-list li {
    margin: 5px 0;
}

/* 반
응형 디자인 - 태블릿 */
@media screen and (max-width: 768px) {
    .container {
        padding: 15px;
    }

    header h1 {
        font-size: 2.5rem;
    }

    .subtitle {
        font-size: 1.1rem;
    }

    main {
        padding: 30px 25px;
        border-radius: 15px;
    }

    #textInput {
        padding: 18px;
        font-size: 16px;
        min-height: 130px;
    }

    .analyze-btn {
        padding: 16px 20px;
        font-size: 17px;
    }

    .result-section h2 {
        font-size: 22px;
    }

    .original-text,
    .analysis-result {
        padding: 18px;
    }
}

/* 반응형 디자인 - 모바일 */
@media screen and (max-width: 480px) {
    .container {
        padding: 10px;
    }

    header {
        margin-bottom: 30px;
        padding: 20px 0;
    }

    header h1 {
        font-size: 2rem;
        margin-bottom: 8px;
    }

    .subtitle {
        font-size: 1rem;
    }

    main {
        padding: 25px 20px;
        border-radius: 12px;
    }

    #textInput {
        padding: 15px;
        font-size: 16px;
        min-height: 120px;
        border-radius: 10px;
    }

    .char-counter {
        font-size: 13px;
        bottom: 8px;
        right: 12px;
    }

    .analyze-btn {
        padding: 15px 18px;
        font-size: 16px;
        border-radius: 10px;
    }

    .loading-section {
        padding: 30px 15px;
    }

    .loading-spinner {
        width: 40px;
        height: 40px;
        border-width: 3px;
    }

    .loading-text {
        font-size: 16px;
    }

    .result-section h2 {
        font-size: 20px;
        margin-bottom: 20px;
    }

    .original-text {
        padding: 15px;
        margin-bottom: 20px;
        border-radius: 10px;
    }
    
    .analysis-result {
        padding: 0;
        margin-bottom: 20px;
    }
    
    .emotion-card {
        padding: 40px 20px;
        border-radius: 15px;
    }
    
    .emotion-text {
        font-size: 2.5rem;
    }

    .original-text h3,
    .analysis-result h3 {
        font-size: 16px;
        margin-bottom: 12px;
    }

    .error-section {
        padding: 30px 15px;
        border-radius: 10px;
    }

    .error-section h2 {
        font-size: 18px;
    }

    #errorMessage {
        font-size: 15px;
    }

    .retry-btn {
        padding: 10px 20px;
        font-size: 15px;
        border-radius: 6px;
    }

    footer {
        font-size: 13px;
    }

    .noscript-message h2 {
        font-size: 20px;
    }

    .noscript-message p {
        font-size: 15px;
    }
}

/* 초소형 모바일 디바이스 */
@media screen and (max-width: 320px) {
    header h1 {
        font-size: 1.8rem;
    }

    main {
        padding: 20px 15px;
    }

    #textInput {
        padding: 12px;
        min-height: 100px;
    }

    .analyze-btn {
        padding: 12px 15px;
        font-size: 15px;
    }
    
    .emotion-card {
        padding: 30px 15px;
        border-radius: 12px;
    }
    
    .emotion-text {
        font-size: 2rem;
    }
}

/* 고해상도 디스플레이 최적화 */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
    .loading-spinner {
        border-width: 3px;
    }
}

/* 다크 모드 지원 (시스템 설정 기반) */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
    }

    main {
        background: #1a202c;
        color: #e2e8f0;
    }

    #textInput {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }

    #textInput:focus {
        border-color: #667eea;
        background: #2d3748;
    }

    #textInput::placeholder {
        color: #a0aec0;
    }

    .char-counter {
        background: rgba(26, 32, 44, 0.9);
        color: #a0aec0;
    }

    .result-section h2 {
        color: #e2e8f0;
    }

    .original-text {
        background: #2d3748;
        border-left-color: #667eea;
    }
    
    .analysis-result {
        background: #1a202c;
    }
    
    .analysis-result h3 {
        background: #1a202c;
        color: #e2e8f0;
    }

    #originalText,
    #analysisResult {
        color: #e2e8f0;
    }
}

/* 접근성 개선 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .loading-spinner {
        animation: none;
        border: 4px solid #667eea;
    }
}

/* 접근성 개선 */
/* 스크린 리더 전용 텍스트 */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* 포커스 접근성 개선 */
button:focus,
textarea:focus {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* 고대비 모드 지원 */
@media (prefers-contrast: high) {

    button:focus,
    textarea:focus {
        outline: 4px solid #000;
        outline-offset: 2px;
    }

    .analyze-btn {
        border: 2px solid #333;
    }

    #textInput {
        border: 2px solid #333;
    }
}

/* 키보드 네비게이션 개선 */
button:focus-visible,
textarea:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 2px;
    box-shadow: 0 0 0 1px #fff, 0 0 0 4px #667eea;
}

/* 터치 디바이스를 위한 최소 터치 영역 */
@media (pointer: coarse) {

    .analyze-btn,
    .retry-btn {
        min-height: 44px;
        min-width: 44px;
    }
}

/* 스킵 링크 (키보드 사용자를 위한) */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #667eea;
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 10000;
    font-weight: 600;
}

.skip-link:focus {
    top: 6px;
}

/* 브라우저별 호환성 */
/* Firefox */
@-moz-document url-prefix() {
    #textInput {
        scrollbar-width: thin;
        scrollbar-color: #667eea #e1e5e9;
    }

    /* Firefox에서 outline 스타일 개선 */
    button:focus,
    textarea:focus {
        -moz-outline-radius: 4px;
    }
}

/* Webkit 브라우저 (Chrome, Safari, Edge) */
#textInput::-webkit-scrollbar {
    width: 8px;
}

#textInput::-webkit-scrollbar-track {
    background: #e1e5e9;
    border-radius: 4px;
}

#textInput::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

#textInput::-webkit-scrollbar-thumb:hover {
    background: #5a67d8;
}

/* Safari 특정 스타일 */
@supports (-webkit-appearance: none) {
    .analyze-btn {
        -webkit-appearance: none;
        appearance: none;
        -webkit-border-radius: 12px;
        border-radius: 12px;
    }

    #textInput {
        -webkit-appearance: none;
        appearance: none;
        -webkit-border-radius: 12px;
        border-radius: 12px;
    }
}

/* Internet Explorer 11 호환성 */
@media screen and (-ms-high-contrast: active),
(-ms-high-contrast: none) {
    .analyze-btn {
        background: #667eea;
        border: none;
    }

    .loading-spinner {
        border: 4px solid #e1e5e9;
        border-top-color: #667eea;
    }

    /* IE에서 flexbox 지원 */
    .container {
        display: -ms-flexbox;
        display: flex;
        -ms-flex-direction: column;
        flex-direction: column;
    }

    .noscript-message {
        display: -ms-flexbox;
        display: flex;
        -ms-flex-direction: column;
        flex-direction: column;
        -ms-flex-pack: center;
        -ms-flex-align: center;
    }
}

/* Edge Legacy 지원 */
@supports (-ms-ime-align: auto) {
    .analyze-btn:focus {
        outline: 2px solid #667eea;
    }
}

/* 구형 브라우저를 위한 폴백 */
.no-js .analyze-btn {
    background: #ccc;
    cursor: not-allowed;
}

.no-js #textInput {
    background: #f5f5f5;
}

/* CSS Grid 미지원 브라우저를 위한 폴백 */
@supports not (display: grid) {
    .container {
        display: block;
        max-width: 800px;
        margin: 0 auto;
    }
}

/* 인쇄 스타일 */
@media print {
    body {
        background: white !important;
        color: black !important;
    }

    .container {
        max-width: none;
        padding: 0;
    }

    main {
        box-shadow: none;
        border: 1px solid #ccc;
    }

    .loading-section,
    .error-section,
    button {
        display: none !important;
    }

    .result-section {
        border-top: 2px solid #333;
    }
}

/* 추가 애니메이션 효과 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-section,
.error-section {
    animation: fadeIn 0.5s ease-out;
}

/* 버튼 클릭 효과 */
@keyframes buttonPress {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(0.98);
    }

    100% {
        transform: scale(1);
    }
}

.analyze-btn:active:not(:disabled),
.retry-btn:active {
    animation: buttonPress 0.1s ease-out;
}