/* GoldenDict 웹 사전 - 스타일시트 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'HCRDotumTitle', 'Noto Sans KR', 'Noto Serif KR', 'HanaMin', 'DKHanja', 'Segoe UI', sans-serif;
}

body {
    font-family: 'HCRDotum', 'Noto Sans KR', 'Noto Serif KR', 'HanaMin', 'DKHanja', 'Segoe UI', sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f5f5f5;
    padding: 20px;
    padding-bottom: 100px;
    max-width: 1200px;
    margin: 0 auto;
    font-size: 1.2em;
}

/* 초기 로딩 중 본문 숨김 */
body:not(.loaded) .main-content {
    display: none;
}

/* 초기 로딩 화면 */
.initial-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    color: #5e35b1;
}

body.loaded .initial-loading {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease-out;
}

.initial-loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(94, 53, 177, 0.2);
    border-top: 4px solid #5e35b1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.initial-loading h2 {
    font-size: 1.8em;
    margin-bottom: 10px;
    font-weight: bold;
}

.initial-loading p {
    font-size: 1em;
    opacity: 0.8;
}

.initial-loading-progress {
    margin-top: 20px;
    font-size: 0.9em;
    opacity: 0.7;
    white-space: nowrap;
}

/* 로딩 텍스트 컨테이너 */
.loading-text-container {
    position: relative;
    text-align: center;
    min-height: 150px;
}

/* 로딩 메시지 fade 애니메이션 */
.loading-message {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    animation: fadeInOut 4s ease-in-out infinite;
    opacity: 0;
    text-align: center;
}

.loading-message h2 {
    margin: 0 0 10px 0;
    white-space: nowrap;
}

.loading-message p {
    margin: 10px 0;
    white-space: nowrap;
}

.loading-message.korean {
    animation-delay: 0s;
}

.loading-message.english {
    animation-delay: 2s;
}

@keyframes fadeInOut {
    0% { opacity: 0; }
    10% { opacity: 1; }
    40% { opacity: 1; }
    50% { opacity: 0; }
    100% { opacity: 0; }
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 10px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    text-align: center;
}

.header h1 {
    font-size: 2em;
    margin-bottom: 10px;
}

.header p {
    opacity: 0.9;
    margin-bottom: 5px;
}

.header-subtitle {
    font-size: 0.85em;
    opacity: 0.8;
    font-style: italic;
}

.search-container {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 30px;
    position: relative;
}

.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.input-wrapper {
    flex: 1;
    position: relative;
}

#searchInput {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 5px;
    transition: border-color 0.3s;
    font-family: 'HCRDotum', 'Noto Sans KR', 'Noto Serif KR', 'HanaMin', 'DKHanja', 'Segoe UI', sans-serif;
}

#searchInput:focus {
    outline: none;
    border-color: #667eea;
}

#searchButton {
    padding: 12px 30px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

#searchButton:hover {
    background: #5a67d8;
}

#searchButton:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.loading {
    text-align: center;
    padding: 50px;
    display: none;
}

.loading.active {
    display: block;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.results {
    display: none;
}

.results.active {
    display: block;
}

.no-results {
    background: white;
    padding: 50px;
    text-align: center;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    color: #666;
}

.dict-entry {
    background: white;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.dict-entry:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.dict-name {
    font-size: 0.9em;
    color: #667eea;
    font-weight: bold;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

.headword {
    font-size: 1.3em;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 15px;
}

.content {
    line-height: 1.8;
    color: #555;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.content a {
    color: #667eea;
    text-decoration: none;
    border-bottom: 1px dotted #667eea;
}

.content a:hover {
    color: #5a67d8;
    border-bottom-style: solid;
}

.content b {
    font-weight: bold;
    color: #333;
}

.content i {
    font-style: italic;
}

.content u {
    text-decoration: underline;
}

/* 한자 사전 특별 스타일 */
.content font[color="green"] {
    color: green !important;
    font-weight: 500;
}

.content font[color="indigo"] {
    color: indigo !important;
}

.content font[color="red"] {
    color: #d00 !important;
    font-size: 0.9em;
}

.content font[color="#664466"] {
    color: #664466 !important;
    background: #f9f9f9;
    padding: 2px 4px;
    border-left: 3px solid #ddd;
    display: inline-block;
    margin: 4px 0;
}

.error {
    background: #fee;
    color: #c33;
    padding: 20px;
    border-radius: 10px;
    margin-top: 20px;
    display: none;
}

.error.active {
    display: block;
}

.stats {
    font-size: 0.9em;
    color: #888;
    margin-top: 10px;
    text-align: right;
}

/* 자동완성 드롭다운 */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #667eea;
    border-top: none;
    border-radius: 0 0 5px 5px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: none;
}

.autocomplete-dropdown.active {
    display: block;
}

.autocomplete-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: #f0f0ff;
}

.autocomplete-loading {
    padding: 10px 12px;
    text-align: center;
    color: #888;
}

.autocomplete-no-results {
    padding: 10px 12px;
    text-align: center;
    color: #888;
}

/* 푸터 */
.footer {
    text-align: center;
    padding: 30px 20px;
    margin-top: 50px;
    border-top: 1px solid #e0e0e0;
    font-size: 0.9em;
    color: #666;
}

.footer a {
    color: #667eea;
    text-decoration: none;
    transition: color 0.3s;
}

.footer a:hover {
    color: #5a67d8;
    text-decoration: underline;
}

.footer-separator {
    margin: 0 15px;
    color: #ccc;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .header {
        padding: 20px;
    }

    .header h1 {
        font-size: 1.5em;
    }

    .search-box {
        flex-direction: column;
    }

    #searchButton {
        width: 100%;
    }

    .dict-entry {
        padding: 15px;
    }

    .footer {
        font-size: 0.85em;
        padding: 20px 10px;
    }

    .footer-separator {
        margin: 0 10px;
    }
}

/* 임베드 모드 (GoldenDict용) */
body.embed-mode .header,
body.embed-mode .search-container,
body.embed-mode .initial-loading,
body.embed-mode .footer {
    display: none;
}

body.embed-mode {
    padding: 20px;
    padding-bottom: 20px;
}

body.embed-mode .main-content {
    display: block !important;
}

body.embed-mode .results-container {
    margin-top: 0;
}
