@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;700;900&display=swap');

:root {
    /* 라이트 모드: 따뜻하고 친근한 동물 테마 */
    --bg-primary: #FFF9F5;
    --bg-secondary: #FFF5EE;
    --bg-gradient: linear-gradient(135deg, #FFF9F5 0%, #FFE8D6 50%, #FFDDC1 100%);
    --card-bg: rgba(255, 255, 255, 0.85);
    --card-bg-solid: #FFFFFF;
    --text-color: #2D2A26;
    --text-secondary: #6B6560;
    --text-muted: #9A9590;
    --primary-color: #FF7B54;
    --primary-light: #FF9A76;
    --primary-gradient: linear-gradient(135deg, #FF7B54 0%, #FFB26B 100%);
    --secondary-color: #95CDAB;
    --secondary-gradient: linear-gradient(135deg, #95CDAB 0%, #7EC8A3 100%);
    --accent-color: #FFD93D;
    --border-color: rgba(255, 123, 84, 0.15);
    --border-strong: rgba(255, 123, 84, 0.3);
    --shadow-sm: 0 2px 8px rgba(255, 123, 84, 0.08);
    --shadow-md: 0 8px 30px rgba(255, 123, 84, 0.12);
    --shadow-lg: 0 20px 60px rgba(255, 123, 84, 0.15);
    --shadow-glow: 0 0 40px rgba(255, 123, 84, 0.2);
    --hover-lift: translateY(-4px);
    --navbar-bg: rgba(255, 255, 255, 0.8);
    --input-bg: #FFFFFF;
    --badge-bg: rgba(255, 123, 84, 0.1);
}

[data-bs-theme="dark"] {
    /* 다크 모드: 세련된 다크 with 따뜻한 골드 포인트 */
    --bg-primary: #1A1814;
    --bg-secondary: #242019;
    --bg-gradient: linear-gradient(135deg, #1A1814 0%, #2D2720 50%, #1A1814 100%);
    --card-bg: rgba(45, 39, 32, 0.7);
    --card-bg-solid: #2D2720;
    --text-color: #F5F0EB;
    --text-secondary: #C4BDB5;
    --text-muted: #8A847D;
    --primary-color: #FFB26B;
    --primary-light: #FFCC8F;
    --primary-gradient: linear-gradient(135deg, #FFB26B 0%, #FFD93D 100%);
    --secondary-color: #7EC8A3;
    --secondary-gradient: linear-gradient(135deg, #7EC8A3 0%, #95CDAB 100%);
    --accent-color: #FFD93D;
    --border-color: rgba(255, 178, 107, 0.1);
    --border-strong: rgba(255, 178, 107, 0.25);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 60px rgba(255, 178, 107, 0.15);
    --hover-lift: translateY(-4px);
    --navbar-bg: rgba(26, 24, 20, 0.9);
    --input-bg: rgba(45, 39, 32, 0.8);
    --badge-bg: rgba(255, 178, 107, 0.15);
}

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

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-color);
    min-height: 100vh;
    transition: background 0.5s ease, color 0.3s ease;
    overflow-x: hidden;
}

/* 배경 장식 요소 */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    right: -30%;
    width: 80%;
    height: 80%;
    background: radial-gradient(circle, var(--primary-color) 0%, transparent 70%);
    opacity: 0.03;
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    bottom: -30%;
    left: -20%;
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, var(--secondary-color) 0%, transparent 70%);
    opacity: 0.05;
    pointer-events: none;
    z-index: 0;
}

/* ========== Navbar ========== */
.navbar {
    background: var(--navbar-bg) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    transition: all 0.3s ease;
}

.navbar.scrolled {
    padding: 0.6rem 0;
    box-shadow: var(--shadow-sm);
}

.navbar-brand {
    font-weight: 800;
    font-size: 1.4rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-brand::before {
    content: '🐾';
    -webkit-text-fill-color: initial;
}

.nav-link {
    color: var(--text-color) !important;
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.nav-link:hover {
    background: var(--badge-bg);
    color: var(--primary-color) !important;
}

#theme-btn {
    padding: 0.5rem 1.2rem;
    border-radius: 50px;
    font-weight: 500;
    font-size: 0.9rem;
    border: 1.5px solid var(--border-strong);
    background: var(--card-bg);
    color: var(--text-color);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

#theme-btn:hover {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
    transform: scale(1.02);
    box-shadow: var(--shadow-md);
}

/* ========== Hero Section ========== */
.hero-section {
    padding-top: 140px;
    padding-bottom: 40px;
    text-align: center;
    position: relative;
    z-index: 1;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--badge-bg);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    animation: fadeInDown 0.6s ease;
}

.hero-badge::before {
    content: '✨';
}

.title {
    font-size: clamp(2.2rem, 6vw, 3.5rem);
    font-weight: 900;
    line-height: 1.2;
    margin-bottom: 1rem;
    animation: fadeInUp 0.6s ease 0.1s both;
}

.title-gradient {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    color: var(--text-secondary);
    font-weight: 400;
    max-width: 500px;
    margin: 0 auto;
    line-height: 1.6;
    animation: fadeInUp 0.6s ease 0.2s both;
}

/* ========== Main Card ========== */
.main-container {
    max-width: 520px;
    margin: 0 auto;
    padding: 0 1.25rem;
    position: relative;
    z-index: 1;
}

.file-upload {
    background: var(--card-bg);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-radius: 28px;
    border: 1px solid var(--border-color);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    animation: fadeInUp 0.6s ease 0.3s both;
    position: relative;
    overflow: hidden;
}

.file-upload::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-gradient);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.file-upload:hover {
    transform: var(--hover-lift);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.file-upload:hover::before {
    opacity: 1;
}

/* ========== Upload Area ========== */
.image-upload-wrap {
    position: relative;
    border: 2px dashed var(--border-strong);
    border-radius: 20px;
    background: var(--input-bg);
    transition: all 0.3s ease;
    overflow: hidden;
}

.image-upload-wrap::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--primary-gradient);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 0;
}

.image-upload-wrap:hover {
    border-color: var(--primary-color);
    transform: scale(1.01);
}

.image-upload-wrap:hover::before {
    opacity: 0.03;
}

.image-upload-wrap.drag-over {
    border-color: var(--primary-color);
    background: var(--badge-bg);
    transform: scale(1.02);
}

.file-upload-input {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 10;
}

.drag-text {
    text-align: center;
    padding: 3rem 1.5rem;
    position: relative;
    z-index: 1;
}

.upload-icon-wrapper {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    background: var(--badge-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.image-upload-wrap:hover .upload-icon-wrapper {
    transform: scale(1.1);
    background: var(--primary-gradient);
}

.upload-icon {
    width: 36px;
    height: 36px;
    opacity: 0.7;
    transition: all 0.3s ease;
}

[data-bs-theme="dark"] .upload-icon {
    filter: invert(1);
}

.image-upload-wrap:hover .upload-icon {
    opacity: 1;
    transform: translateY(-2px);
}

[data-bs-theme="light"] .image-upload-wrap:hover .upload-icon {
    filter: brightness(0) invert(1);
}

.upload-text {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

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

/* ========== Result Area ========== */
.file-upload-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

.image-preview-wrapper {
    position: relative;
    display: inline-block;
    margin-bottom: 1.5rem;
}

.file-upload-image {
    max-height: 280px;
    max-width: 100%;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    object-fit: cover;
}

.result-message {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 1.5rem 0;
    padding: 1rem;
    background: var(--badge-bg);
    border-radius: 12px;
    color: var(--primary-color);
    animation: bounceIn 0.5s ease;
}

/* ========== Progress Bars ========== */
#label-container {
    margin: 1.5rem 0;
}

.animal-box {
    width: 100%;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
    animation: slideInLeft 0.4s ease backwards;
}

.animal-box:nth-child(1) { animation-delay: 0.1s; }
.animal-box:nth-child(2) { animation-delay: 0.15s; }
.animal-box:nth-child(3) { animation-delay: 0.2s; }
.animal-box:nth-child(4) { animation-delay: 0.25s; }
.animal-box:nth-child(5) { animation-delay: 0.3s; }

.animal-box:first-child {
    background: var(--primary-gradient);
    border-color: transparent;
    box-shadow: var(--shadow-md);
}

.animal-box:first-child .animal-label,
.animal-box:first-child .percent-text {
    color: white;
}

.animal-box:first-child .progress {
    background: rgba(255, 255, 255, 0.3);
}

.animal-box:first-child .progress-bar {
    background: white !important;
}

.animal-box:hover {
    transform: translateX(4px);
}

.animal-emoji {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--badge-bg);
    border-radius: 10px;
    flex-shrink: 0;
}

.animal-box:first-child .animal-emoji {
    background: rgba(255, 255, 255, 0.2);
}

.animal-label {
    font-weight: 600;
    color: var(--text-color);
    min-width: 70px;
    font-size: 0.95rem;
}

.bar-container {
    flex: 1;
    min-width: 0;
}

.progress {
    height: 8px;
    border-radius: 10px;
    background: var(--border-color);
    overflow: hidden;
}

.progress-bar {
    border-radius: 10px;
    background: var(--primary-gradient) !important;
    transition: width 0.8s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

/* ========== Button ========== */
.remove-image {
    width: 100%;
    padding: 1rem 1.5rem;
    margin-top: 1.5rem;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 123, 84, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.remove-image::before {
    content: '🔄';
}

.remove-image:hover {
    transform: var(--hover-lift);
    box-shadow: 0 8px 25px rgba(255, 123, 84, 0.4);
}

.remove-image:active {
    transform: translateY(0);
}

/* ========== Loading ========== */
#loading {
    display: none;
    padding: 2rem;
    text-align: center;
}

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

.loading-text {
    color: var(--text-secondary);
    font-weight: 500;
    animation: pulse 1.5s ease infinite;
}

.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

/* ========== Footer ========== */
.footer {
    text-align: center;
    padding: 2rem;
    margin-top: 3rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ========== Animations ========== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

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

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes dots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

/* ========== Responsive Design ========== */

/* 태블릿 */
@media screen and (max-width: 768px) {
    .navbar {
        padding: 0.8rem 0;
    }

    .navbar-brand {
        font-size: 1.2rem;
    }

    .hero-section {
        padding-top: 120px;
        padding-bottom: 30px;
    }

    .hero-badge {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }

    .file-upload {
        padding: 2rem;
        border-radius: 24px;
    }

    .drag-text {
        padding: 2.5rem 1rem;
    }

    .upload-icon-wrapper {
        width: 70px;
        height: 70px;
    }

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

    .result-message {
        font-size: 1.3rem;
        padding: 0.8rem;
    }

    .animal-box {
        padding: 0.9rem 1rem;
    }

    .animal-emoji {
        width: 36px;
        height: 36px;
        font-size: 1.3rem;
    }

    .animal-label {
        font-size: 0.9rem;
        min-width: 60px;
    }
}

/* 모바일 */
@media screen and (max-width: 480px) {
    .main-container {
        padding: 0 1rem;
    }

    .hero-section {
        padding-top: 100px;
        padding-bottom: 24px;
    }

    .hero-badge {
        font-size: 0.75rem;
        margin-bottom: 1rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    .file-upload {
        padding: 1.5rem;
        border-radius: 20px;
        margin-bottom: 2rem;
    }

    .file-upload:hover {
        transform: none;
    }

    .image-upload-wrap {
        border-radius: 16px;
    }

    .drag-text {
        padding: 2rem 1rem;
    }

    .upload-icon-wrapper {
        width: 64px;
        height: 64px;
        margin-bottom: 1rem;
    }

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

    .upload-text {
        font-size: 0.9rem;
    }

    .upload-hint {
        font-size: 0.8rem;
    }

    .file-upload-image {
        max-height: 220px;
        border-radius: 12px;
    }

    .result-message {
        font-size: 1.15rem;
        padding: 0.75rem;
        margin: 1rem 0;
    }

    .animal-box {
        padding: 0.8rem;
        gap: 0.6rem;
        border-radius: 12px;
        margin-bottom: 0.6rem;
    }

    .animal-emoji {
        width: 32px;
        height: 32px;
        font-size: 1.1rem;
        border-radius: 8px;
    }

    .animal-label {
        font-size: 0.85rem;
        min-width: 55px;
    }

    .progress {
        height: 6px;
    }

    .percent-text {
        font-size: 0.8rem;
        min-width: 42px;
    }

    .remove-image {
        padding: 0.9rem 1rem;
        font-size: 0.95rem;
        border-radius: 12px;
        margin-top: 1rem;
    }

    #theme-btn {
        padding: 0.4rem 1rem;
        font-size: 0.85rem;
    }
}

/* 매우 작은 화면 */
@media screen and (max-width: 360px) {
    .title {
        font-size: 1.8rem;
    }

    .file-upload {
        padding: 1.25rem;
    }

    .animal-label {
        min-width: 50px;
        font-size: 0.8rem;
    }

    .percent-text {
        min-width: 38px;
        font-size: 0.75rem;
    }
}

/* 가로 모드 모바일 */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .hero-section {
        padding-top: 80px;
        padding-bottom: 16px;
    }

    .hero-badge {
        display: none;
    }

    .subtitle {
        display: none;
    }

    .drag-text {
        padding: 1.5rem 1rem;
    }

    .upload-icon-wrapper {
        width: 50px;
        height: 50px;
        margin-bottom: 0.8rem;
    }
}

/* 고해상도 디스플레이 */
@media screen and (min-width: 1200px) {
    .main-container {
        max-width: 560px;
    }

    .file-upload {
        padding: 3rem;
    }
}

/* 다크모드 전환 애니메이션 */
body, .navbar, .file-upload, .animal-box, #theme-btn {
    transition: background 0.4s ease,
                border-color 0.4s ease,
                box-shadow 0.4s ease,
                color 0.3s ease;
}

/* 접근성 - 모션 감소 선호 사용자 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
