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

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --background: #f8fafc;
    --card-background: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
}

.container {
    flex: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    padding-top: 20px;
    width: 100%;
}

/* 섹션 관리 */
.section {
    display: none;
    animation: fadeIn 0.5s ease-in;
}

.section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 헤더 */
.header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
    position: relative;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 800;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

/* 언어 선택기 */
.language-selector-container {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 100;
}

.language-selector {
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
}

.language-selector:hover {
    background: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.language-selector:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* 네비게이션 바 */
.navbar {
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    margin-bottom: 0;
}

.navbar-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
}

.navbar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 1.3rem;
    font-weight: 700;
}

.navbar-logo span {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.navbar-menu {
    display: flex;
    gap: 10px;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
}

.navbar-menu li {
    margin: 0;
}

.nav-link {
    padding: 10px 20px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 8px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
}

.nav-link.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.navbar .language-selector-container {
    position: static;
}

.navbar .language-selector {
    padding: 8px 12px;
    font-size: 0.85rem;
}

/* 햄버거 메뉴 버튼 */
.navbar-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
}

.navbar-toggle span {
    width: 25px;
    height: 3px;
    background: var(--text-primary);
    border-radius: 3px;
    transition: all 0.3s;
}

.navbar-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.navbar-toggle.active span:nth-child(2) {
    opacity: 0;
}

.navbar-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* 모바일 반응형 */
@media (max-width: 768px) {
    .navbar-container {
        padding: 12px 15px;
    }

    .navbar-logo {
        font-size: 1.1rem;
    }

    .navbar-toggle {
        display: flex;
    }

    .navbar-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        flex-direction: column;
        gap: 0;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .navbar-menu.active {
        max-height: 500px;
        padding: 10px 0;
    }

    .navbar-menu li {
        width: 100%;
    }

    .nav-link {
        padding: 15px 20px;
        width: 100%;
        border-radius: 0;
    }

    .navbar-right {
        gap: 10px;
    }

    .navbar .language-selector {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
}

/* 콘텐츠 카드 */
.content {
    background: var(--card-background);
    border-radius: 20px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

/* 정보 박스 */
.info-box {
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
    text-align: center;
}

.info-box p {
    margin: 8px 0;
    font-size: 1rem;
    color: var(--text-primary);
}

/* 업로드 영역 */
.upload-area {
    border: 3px dashed var(--border-color);
    border-radius: 16px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--background);
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: #f1f5f9;
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background: #e0e7ff;
    transform: scale(1.02);
}

.upload-content {
    pointer-events: none;
}

.upload-icon {
    width: 64px;
    height: 64px;
    color: var(--primary-color);
    margin: 0 auto 20px;
}

.upload-text {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.upload-hint {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* 이미지 프리뷰 */
.preview-container {
    text-align: center;
    margin-bottom: 30px;
}

#preview-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

/* 성별 선택 */
.gender-selection {
    text-align: center;
    margin: 30px 0;
}

.gender-selection h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 1.3rem;
}

.gender-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.btn-gender {
    flex: 1;
    max-width: 200px;
    padding: 30px 20px;
    border: 2px solid var(--border-color);
    border-radius: 16px;
    background: var(--background);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.btn-gender:hover {
    border-color: var(--primary-color);
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.btn-gender.selected {
    border-color: var(--primary-color);
    background: #e0e7ff;
    box-shadow: var(--shadow);
}

.gender-icon {
    font-size: 3rem;
}

/* 버튼 스타일 */
.btn-primary, .btn-secondary {
    padding: 16px 32px;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    margin-top: 20px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--background);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--secondary-color);
    transform: translateY(-2px);
}

/* 분석 중 섹션 */
.analyzing-content {
    background: var(--card-background);
    border-radius: 20px;
    padding: 60px 40px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.spinner {
    width: 80px;
    height: 80px;
    border: 8px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 30px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.analyzing-content h2 {
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 2rem;
}

.analyzing-text {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* 결과 섹션 */
.result-content {
    background: var(--card-background);
    border-radius: 20px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.result-content h2 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 2rem;
    color: var(--text-primary);
}

.result-card {
    background: var(--background);
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 20px;
}

.result-animal {
    text-align: center;
    margin-bottom: 30px;
}

.animal-emoji {
    font-size: 6rem;
    margin-bottom: 15px;
}

#result-animal-name {
    font-size: 2rem;
    color: var(--primary-color);
    font-weight: 700;
    margin-bottom: 15px;
}

.result-percentage {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    margin: 15px 0 5px 0;
}

.percentage-number {
    font-size: 4rem;
    font-weight: 800;
    color: var(--primary-color);
    line-height: 1;
}

.percentage-symbol {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.percentage-label {
    font-size: 1rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 5px;
}

.result-description {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: white;
    border-radius: 12px;
}

.result-description p {
    font-size: 1.2rem;
    color: var(--text-primary);
    line-height: 1.6;
}

.result-traits, .result-compatibility {
    margin-bottom: 25px;
}

.result-traits h4, .result-compatibility h4 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.result-traits ul {
    list-style: none;
    padding: 0;
}

.result-traits li {
    padding: 10px;
    margin: 8px 0;
    background: white;
    border-radius: 8px;
    padding-left: 15px;
}

.result-traits li:before {
    content: "✓ ";
    color: var(--success-color);
    font-weight: bold;
    margin-right: 8px;
}

.result-compatibility p {
    font-size: 1.3rem;
    text-align: center;
    padding: 15px;
    background: white;
    border-radius: 8px;
}

/* 동물상 순위 차트 */
.result-ranking {
    margin: 30px 0;
}

.result-ranking h4 {
    font-size: 1.2rem;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.ranking-item:hover {
    transform: translateX(5px);
    box-shadow: var(--shadow);
}

.ranking-item.top-rank {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 2px solid #f59e0b;
}

.ranking-rank {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 30px;
}

.ranking-item.top-rank .ranking-rank {
    color: #f59e0b;
}

.ranking-emoji {
    font-size: 1.8rem;
}

.ranking-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ranking-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.ranking-bar-container {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.ranking-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color) 0%, #a78bfa 100%);
    border-radius: 4px;
    transition: width 0.8s ease;
}

.ranking-item.top-rank .ranking-bar {
    background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%);
}

.ranking-percentage {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
    min-width: 50px;
    text-align: right;
}

.ranking-item.top-rank .ranking-percentage {
    color: #f59e0b;
}

/* 통계 정보 */
.result-statistics {
    margin-top: 25px;
    padding: 20px;
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.stat-icon {
    font-size: 1.3rem;
}

.stat-text strong {
    color: var(--primary-color);
    font-weight: 700;
}

.result-actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.result-actions button {
    flex: 1;
    min-width: 180px;
    margin-top: 0;
}

#download-btn {
    background: var(--success-color);
}

#download-btn:hover {
    background: #059669;
}

/* 광고 컨테이너 */
.ad-container {
    margin: 12px auto;
    text-align: center;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    padding: 10px;
    transition: all 0.3s ease;
}

.ad-top {
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.8);
}

.ad-content {
    margin: 20px 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
}

.ad-result-top {
    margin-bottom: 25px;
}

.ad-result-bottom {
    margin-top: 25px;
}

/* AdSense 반응형 설정 */
.ad-container ins {
    display: block;
    width: 100%;
    max-width: 100%;
}

/* 데모 광고 스타일 */
.demo-ad {
    width: 100%;
    position: relative;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border: 2px dashed #94a3b8;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.demo-ad:hover {
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    border-color: #6366f1;
    transform: translateY(-2px);
}

.demo-ad-label {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #64748b;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.demo-ad-content {
    text-align: center;
}

.demo-ad-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 5px;
}

.demo-ad-subtitle {
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 500;
}

/* 광고 크기 변형 */
.demo-ad-banner {
    min-height: 90px;
    max-height: 120px;
}

.demo-ad-square {
    min-height: 250px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-color: #f59e0b;
}

.demo-ad-square:hover {
    background: linear-gradient(135deg, #fef08a 0%, #fde047 100%);
    border-color: #f59e0b;
}

.demo-ad-square .demo-ad-label {
    background: #f59e0b;
}

.demo-ad-large {
    min-height: 280px;
    background: linear-gradient(135deg, #ddd6fe 0%, #c4b5fd 100%);
    border-color: #8b5cf6;
}

.demo-ad-large:hover {
    background: linear-gradient(135deg, #c4b5fd 0%, #a78bfa 100%);
    border-color: #7c3aed;
}

.demo-ad-large .demo-ad-label {
    background: #8b5cf6;
}

/* 푸터 */
.footer {
    text-align: center;
    padding: 20px;
    color: white;
    font-size: 0.9rem;
}

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

    .header h1 {
        font-size: 2rem;
    }

    .content {
        padding: 25px;
    }

    .gender-buttons {
        flex-direction: column;
        gap: 15px;
    }

    .btn-gender {
        max-width: 100%;
    }

    .animal-emoji {
        font-size: 4rem;
    }

    #result-animal-name {
        font-size: 1.5rem;
    }

    .result-actions {
        flex-direction: column;
    }

    .result-actions button {
        width: 100%;
    }

    /* 모바일 광고 조정 */
    .ad-container {
        margin: 10px auto;
        min-height: 40px;
    }

    .demo-ad-banner {
        min-height: 70px;
        padding: 15px;
    }

    .demo-ad-square {
        min-height: 200px;
    }

    .demo-ad-large {
        min-height: 220px;
    }

    .demo-ad-title {
        font-size: 1rem;
    }

    .demo-ad-subtitle {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.6rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    .content {
        padding: 20px;
    }

    .upload-area {
        padding: 40px 15px;
    }

    .upload-icon {
        width: 48px;
        height: 48px;
    }

    /* 소형 모바일 광고 조정 */
    .ad-container {
        margin: 8px auto;
        padding: 4px;
    }

    .demo-ad {
        padding: 15px 10px;
    }

    .demo-ad-banner {
        min-height: 60px;
    }

    .demo-ad-square {
        min-height: 180px;
    }

    .demo-ad-large {
        min-height: 200px;
    }

    .demo-ad-title {
        font-size: 0.9rem;
    }

    .demo-ad-subtitle {
        font-size: 0.7rem;
    }

    .demo-ad-label {
        font-size: 0.6rem;
        padding: 3px 6px;
    }
}
