@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Open+Sans:wght@400;600&display=swap');

:root {
    --primary-color: #ff9d00;
    --secondary-color: #ff5e00;
    --bg-color: #fff9f0;
    --text-color: #444;
    --card-bg: #fff;
    --shadow: rgba(255, 157, 0, 0.2);
    --dog-color: #3a7bd5;
    --cat-color: #f77062;
    --font-heading: 'Fredoka One', cursive;
    --font-body: 'Open Sans', sans-serif;
}

body.dark-mode {
    --primary-color: #ffb74d;
    --secondary-color: #ff8a65;
    --bg-color: #1a1a1a;
    --text-color: #f5f5f5;
    --card-bg: #2d2d2d;
    --shadow: rgba(0, 0, 0, 0.5);
    --dog-color: #4facfe;
    --cat-color: #fe5196;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
}

header {
    padding: 1.5rem 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--card-bg);
    box-shadow: 0 2px 15px var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo h1 a {
    text-decoration: none;
    color: var(--primary-color);
    font-family: var(--font-heading);
    font-size: 1.8rem;
}

.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-color);
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background-color: rgba(0,0,0,0.05);
}

body.dark-mode .theme-toggle:hover {
    background-color: rgba(255,255,255,0.05);
}

.sun-icon { display: none; }
body.dark-mode .sun-icon { display: block; }
body.dark-mode .moon-icon { display: none; }

main {
    max-width: 900px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

.hero {
    text-align: center;
    margin-bottom: 3rem;
}

.hero h2 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

.hero p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.upload-section {
    margin-bottom: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.upload-card {
    background-color: var(--card-bg);
    border: 3px dashed var(--primary-color);
    border-radius: 24px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    box-shadow: 0 10px 25px var(--shadow);
    width: 100%;
}

.divider {
    display: flex;
    align-items: center;
    width: 100%;
    color: var(--text-color);
    opacity: 0.5;
    margin: 0.5rem 0;
}

.divider::before, .divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: currentColor;
    margin: 0 1rem;
}

.webcam-btn {
    background-color: var(--card-bg);
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    padding: 1rem 2rem;
    border-radius: 12px;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    transition: all 0.3s ease;
}

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

.webcam-container {
    background-color: var(--card-bg);
    padding: 1rem;
    border-radius: 24px;
    box-shadow: 0 10px 30px var(--shadow);
    text-align: center;
    width: 100%;
    max-width: 400px;
}

#webcam-wrapper {
    width: 100%;
    margin-bottom: 1rem;
    border-radius: 12px;
    overflow: hidden;
    line-height: 0;
}

#webcam-wrapper canvas {
    width: 100% !important;
    height: auto !important;
}

.capture-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.capture-btn:hover {
    transform: scale(1.05);
}

.upload-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px var(--shadow);
    border-color: var(--secondary-color);
}

.upload-icon {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
}

.upload-card h3 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.upload-card p {
    opacity: 0.7;
}

.hidden {
    display: none !important;
}

.result-section {
    animation: fadeInUp 0.5s ease-out;
}

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

.result-card {
    background-color: var(--card-bg);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 20px 40px var(--shadow);
    display: grid;
    grid-template-columns: 1fr 1fr;
}

@media (max-width: 768px) {
    .result-card {
        grid-template-columns: 1fr;
    }
}

.preview-container {
    position: relative;
    height: 400px;
}

#image-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

body.dark-mode .loading-overlay {
    background-color: rgba(0, 0, 0, 0.8);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--primary-color);
    border-top: 5px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

.analysis-results {
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.analysis-results h2 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    margin-bottom: 2rem;
    color: var(--primary-color);
}

.label-container {
    margin-bottom: 2rem;
}

.label-row {
    margin-bottom: 1.5rem;
}

.label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.progress-bar {
    height: 12px;
    background-color: rgba(0,0,0,0.05);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

body.dark-mode .progress-bar {
    background-color: rgba(255,255,255,0.05);
}

.progress-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 1s cubic-bezier(0.17, 0.67, 0.83, 0.67);
}

.progress-fill.dog { background-color: var(--dog-color); }
.progress-fill.cat { background-color: var(--cat-color); }

.percent {
    float: right;
    font-weight: 700;
    font-size: 0.9rem;
}

.fun-fact {
    background-color: rgba(255, 157, 0, 0.1);
    padding: 1rem;
    border-radius: 12px;
    font-style: italic;
    margin-bottom: 2rem;
    border-left: 4px solid var(--primary-color);
}

.retry-btn {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.retry-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px var(--shadow);
}

.comments-section {
    margin-top: 5rem;
}

.comments-section .card {
    background-color: var(--card-bg);
    padding: 2rem;
    border-radius: 24px;
    box-shadow: 0 10px 25px var(--shadow);
}

.comments-section h2 {
    font-family: var(--font-heading);
    margin-bottom: 1.5rem;
}

footer {
    text-align: center;
    padding: 3rem;
    opacity: 0.7;
    font-size: 0.9rem;
}
