/* The Text Works - Dashboard Style */
:root {
    --bg-color: #f8f9fa;
    --surface-color: #ffffff;
    --border-color: #e2e2e2;
    --primary-color: #2563eb;
    --text-main: #1f2937;
    --text-sub: #6b7280;
    --sidebar-width: 280px;
}

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

body {
    background-color: var(--bg-color);
    background-image: radial-gradient(#d1d5db 1px, transparent 1px);
    background-size: 24px 24px;
    color: var(--text-main);
    font-family: 'Noto Sans KR', sans-serif;
    height: 100vh;
    display: flex;
    overflow: hidden;
}

/* 사이드바 */
#sidebar {
    width: var(--sidebar-width);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--border-color);
    padding: 2.5rem 2rem;
    display: flex;
    flex-direction: column;
    z-index: 10;
    flex-shrink: 0;
    font-family: 'Noto Sans KR', sans-serif;
}

#sidebar .brand,
#sidebar .brand a {
    font-family: 'Noto Serif KR', serif !important;
    font-size: 1.25rem !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    letter-spacing: normal !important;
    color: #111 !important;
    text-decoration: none !important;
    white-space: nowrap !important;
}

#sidebar .brand {
    margin-bottom: 3rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

#sidebar .nav-item {
    display: block;
    padding: 0.5rem 1rem;
    margin-bottom: 0.2rem;
    text-decoration: none;
    color: var(--text-sub);
    border-radius: 8px;
    font-family: 'Noto Sans KR', sans-serif !important;
    font-size: 1rem !important;
    font-weight: 500;
    line-height: 1.5 !important;
    letter-spacing: normal !important;
    transition: all 0.2s ease;
}

#sidebar .nav-item:hover,
#sidebar .nav-item.active {
    background-color: #eff6ff;
    color: var(--primary-color);
    transform: translateX(4px);
}

#sidebar .nav-label {
    font-family: 'Noto Sans KR', sans-serif !important;
    font-size: 0.75rem !important;
    font-weight: 700;
    line-height: 1.5 !important;
    letter-spacing: 0.05em !important;
    text-transform: uppercase;
    color: #9ca3af;
    margin: 2rem 0 0.5rem 1rem;
}

/* 메인 영역 */
main {
    flex: 1;
    padding: 2rem 4rem 0.5rem;
    overflow-y: auto;
    position: relative;
}

/* 진입 애니메이션 */
.fade-up {
    animation: fadeUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
    transform: translateY(20px);
}

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

header.page-header {
    margin-bottom: 3rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

.header-title h1 {
    font-family: 'Noto Serif KR', serif;
    font-size: 2.2rem;
    font-weight: 300;
    margin-bottom: 0.5rem;
    color: #111;
}

.header-title p {
    color: var(--text-sub);
}

.header-title p.subtitle-en {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.15rem;
    font-style: italic;
    font-weight: 400;
    letter-spacing: 0.02em;
    color: #4b5563;
}

/* 그리드 카드 시스템 */
.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.grid .card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.8rem;
    min-height: 280px;
    position: relative;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    cursor: pointer;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
}

.card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.06);
    border-color: var(--primary-color);
}

.card-arrow {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    font-size: 1.2rem;
    color: #d1d5db;
    transition: all 0.3s ease;
}

.card:hover .card-arrow {
    color: var(--primary-color);
    transform: translate(4px, -4px);
}

.card-content {
    margin-top: 1rem;
}

.card-category {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-color);
    background: #eff6ff;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 1rem;
}

.card h3 {
    font-family: 'Noto Serif KR', serif;
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 0.8rem;
    line-height: 1.3;
}

.card p {
    font-size: 0.95rem;
    color: var(--text-sub);
    line-height: 1.6;
    word-break: keep-all;
}

.card-footer {
    margin-top: auto;
    padding-top: 1rem;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tech-pill {
    font-size: 0.75rem;
    border: 1px solid #e5e7eb;
    padding: 2px 8px;
    border-radius: 20px;
    color: #666;
}

/* Featured 카드 */
.card.featured {
    grid-column: span 2;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
}

.card.featured h3 {
    font-size: 1.8rem;
}

/* 순차적 등장 딜레이 */
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }
.delay-5 { animation-delay: 0.5s; }

/* 반응형 */
@media (max-width: 1200px) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .card.featured {
        grid-column: span 2;
    }
}

@media (max-width: 768px) {
    body {
        flex-direction: column;
        overflow: auto;
        height: auto;
    }

    #sidebar,
    #sidebar.collapsed {
        width: 100% !important;
        height: 56px !important;
        padding: 1rem 1.5rem !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border-color) !important;
        overflow: hidden !important;
    }

    #sidebar.mobile-open {
        height: auto !important;
        overflow: visible !important;
    }

    /* 모바일에서 collapsed 상태 무시 */
    #sidebar.collapsed .sidebar-header {
        justify-content: space-between !important;
    }

    #sidebar.collapsed .brand {
        width: auto !important;
        overflow: visible !important;
    }

    #sidebar.collapsed .brand a,
    #sidebar.collapsed .status-dot {
        opacity: 1 !important;
        visibility: visible !important;
        width: auto !important;
        display: inline-block !important;
    }

    #sidebar.collapsed .toggle-btn {
        margin: 0 !important;
    }

    #sidebar nav {
        display: none !important;
    }

    #sidebar.mobile-open nav {
        display: block !important;
        margin-top: 0.5rem !important;
    }

    #sidebar.mobile-open .nav-item {
        font-size: 0.9rem !important;
        padding: 0.4rem 0.8rem !important;
    }

    #sidebar.mobile-open .nav-label {
        font-size: 0.65rem !important;
    }

    #sidebar .sidebar-header {
        margin-bottom: 0 !important;
    }

    #sidebar .sidebar-header .brand {
        margin-bottom: 0 !important;
    }

    #sidebar .brand {
        margin-bottom: 0 !important;
    }

    #sidebar .toggle-btn {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    #sidebar .nav-label {
        margin: 1rem 0 0.5rem 0 !important;
    }

    #sidebar .nav-item {
        padding: 0.6rem 0.8rem !important;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .card.featured {
        grid-column: span 1;
    }

    .card.featured h3 {
        font-size: 1.4rem;
    }

    main {
        padding: 1.5rem;
    }

    .header-title h1 {
        font-size: 1.8rem;
    }

    .tools-section {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* 모바일 카드 상하 여백 축소 */
    .grid .card {
        padding: 1.2rem 1.5rem;
        min-height: 220px;
    }

    .card-content {
        margin-top: 0.5rem;
    }

    .card h3 {
        font-size: 1.2rem;
        margin-bottom: 0.5rem;
    }

    .card p {
        font-size: 0.9rem;
    }

    .card-footer {
        padding-top: 0.8rem;
    }
}

/* 페이지 푸터 */
.page-footer {
    text-align: center;
    padding: 2rem 0;
    margin-top: 1rem;
    color: #9ca3af;
    font-size: 0.8rem;
    line-height: 1.6;
}

.page-footer .footer-site {
    font-size: 0.75rem;
    color: #b0b5bb;
}

/* 유틸리티 */
.hidden {
    display: none;
}

/* 텍스트영역 (개별 도구 페이지용) */
textarea {
    line-height: 1.6;
    font-family: 'Noto Sans KR', sans-serif;
}

/* 사이드바 헤더 */
#sidebar .sidebar-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    margin: 0 0 2rem 0 !important;
    padding: 0 !important;
}

#sidebar .sidebar-header .brand {
    margin-bottom: 0 !important;
}

/* 토글 버튼 */
#sidebar .toggle-btn {
    background: none !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 6px !important;
    padding: 4px 8px !important;
    cursor: pointer !important;
    color: var(--text-sub) !important;
    font-family: 'Noto Sans KR', sans-serif !important;
    font-size: 0.75rem !important;
    line-height: 1.5 !important;
    transition: all 0.2s ease !important;
    flex-shrink: 0 !important;
}

#sidebar .toggle-btn:hover {
    background: #eff6ff !important;
    color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

/* 사이드바 접힘 상태 */
#sidebar.collapsed {
    width: 60px !important;
    padding: 1.5rem 0.8rem !important;
}

#sidebar.collapsed .brand a,
#sidebar.collapsed .nav-label,
#sidebar.collapsed .nav-item {
    opacity: 0 !important;
    visibility: hidden !important;
    width: 0 !important;
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
}

#sidebar.collapsed .sidebar-header {
    justify-content: center !important;
}

#sidebar.collapsed .brand {
    width: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
}

#sidebar.collapsed .toggle-btn {
    margin: 0 auto !important;
}

#sidebar.collapsed .status-dot {
    display: none !important;
}

/* 사이드바 트랜지션 */
#sidebar {
    transition: width 0.3s ease, padding 0.3s ease !important;
}

#sidebar .brand,
#sidebar .brand a,
#sidebar .nav-label,
#sidebar .nav-item {
    transition: opacity 0.2s ease, visibility 0.2s ease, width 0.2s ease !important;
}

/* 공통 버튼 스타일 */
.btn-use-tool {
    display: inline-block;
    padding: 14px 28px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    text-decoration: none;
}

.btn-use-tool:hover {
    background: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-use-tool:active {
    transform: translateY(0);
}

/* 도구 페이지 공통 스타일 */
.section-title {
    font-family: 'Noto Serif KR', serif;
    font-size: 2rem;
    font-weight: 600;
    color: #111;
    margin-bottom: 0.5rem;
}

.section-subtitle {
    color: var(--text-sub);
    font-size: 1rem;
    margin-bottom: 2rem;
}

/* 버튼 가운데 정렬 */
.btn-center {
    text-align: center;
}

.form-group:has(.btn-use-tool) {
    text-align: center;
    margin-top: 2rem;
}

/* 언어 전환 링크 */
.language-switcher {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 1rem;
    font-size: 0.75rem;
}

.lang-link {
    color: var(--text-sub);
    text-decoration: none;
    transition: color 0.2s ease;
}

.lang-link:hover {
    color: var(--primary-color);
}

.lang-link.lang-current {
    color: var(--primary-color);
    font-weight: 600;
    pointer-events: none;
}

.lang-sep {
    color: #d1d5db;
}

#sidebar.collapsed .language-switcher {
    display: none;
}

/* 모바일 언어 전환 */
.header-right {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.mobile-lang-switcher {
    display: none;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
}

.mobile-lang-switcher .lang-link {
    color: #9ca3af;
    padding: 2px 4px;
}

.mobile-lang-switcher .lang-link.lang-current {
    color: #6b7280;
}

.mobile-lang-switcher .lang-sep {
    color: #d1d5db;
}

@media (max-width: 768px) {
    .mobile-lang-switcher {
        display: flex;
    }
}

/* 일본어 폰트 */
html:lang(ja) body,
html:lang(ja) p,
html:lang(ja) span,
html:lang(ja) div,
html:lang(ja) #sidebar,
html:lang(ja) #sidebar .nav-item,
html:lang(ja) textarea,
html:lang(ja) input,
html:lang(ja) select,
html:lang(ja) button,
html:lang(ja) label,
html:lang(ja) .tab-btn,
html:lang(ja) .btn-use-tool,
html:lang(ja) .era-info-box,
html:lang(ja) .feature-badge,
html:lang(ja) .section-subtitle {
    font-family: 'Noto Sans JP', sans-serif;
}

html:lang(ja) #sidebar .brand,
html:lang(ja) #sidebar .brand a,
html:lang(ja) .header-title h1,
html:lang(ja) .section-title,
html:lang(ja) .card h3 {
    font-family: 'Noto Serif JP', serif;
}

/* 영어 폰트 */
html:lang(en) body,
html:lang(en) p,
html:lang(en) span,
html:lang(en) div,
html:lang(en) #sidebar,
html:lang(en) #sidebar .nav-item,
html:lang(en) textarea,
html:lang(en) input,
html:lang(en) select,
html:lang(en) button,
html:lang(en) label,
html:lang(en) .tab-btn,
html:lang(en) .btn-use-tool,
html:lang(en) .section-subtitle {
    font-family: 'Inter', sans-serif;
}

html:lang(en) #sidebar .brand,
html:lang(en) #sidebar .brand a,
html:lang(en) .header-title h1,
html:lang(en) .section-title,
html:lang(en) .card h3 {
    font-family: 'Libre Baskerville', serif;
}

/* 영어 텍스트는 모든 언어에서 동일한 폰트 */
.header-title h1,
.subtitle-en {
    font-family: 'Libre Baskerville', serif !important;
}

.header-title .subtitle-en {
    font-family: 'Cormorant Garamond', serif !important;
}

/* iOS Safari 드롭다운(select) 스타일 수정 */
select,
select option {
    color: #333;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

select:focus {
    color: #333;
}

/* iOS Safari에서 선택된 옵션 색상 */
select option:checked {
    color: #333;
}

/* input, select 공통 색상 */
input,
select,
textarea {
    color: #333;
    -webkit-text-fill-color: #333;
}
