/* ===== CSS Variables ===== */
:root {
    --color-bg: #fef6e8;
    --color-bg-warm: #fff4e0;
    --color-surface: #ffffff;
    --color-primary: #e07b39;
    --color-primary-dark: #c86a2d;
    --color-primary-light: #f5a66a;
    --color-secondary: #8b6914;
    --color-accent: #d4a574;
    --color-text: #3d3425;
    --color-text-light: #7a7062;
    --color-heart: #e74c7a;
    --color-heart-bg: #ffeef3;
    --color-success: #4caf7a;
    --color-border: #e8dcc8;
    
    --font-primary: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    --shadow-sm: 0 2px 8px rgba(61, 52, 37, 0.08);
    --shadow-md: 0 4px 20px rgba(61, 52, 37, 0.12);
    --shadow-lg: 0 8px 40px rgba(61, 52, 37, 0.16);
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
}

/* ===== App Wrapper ===== */
.app-wrapper {
    min-height: 100vh;
}

/* ===== Floating Background Cubes ===== */
.floating-cubes {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.floating-cube {
    position: absolute;
    width: 80px;
    height: auto;
    opacity: 0.12;
    animation: float 20s ease-in-out infinite;
}

.cube-1 { top: 20%; left: 5%; animation-delay: 0s; width: 100px; }
.cube-2 { top: 70%; left: 80%; animation-delay: -7s; width: 60px; }
.cube-3 { top: 45%; right: 5%; animation-delay: -14s; width: 90px; }

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(-5deg); }
    25% { transform: translateY(-30px) rotate(5deg); }
    50% { transform: translateY(0) rotate(-5deg); }
    75% { transform: translateY(30px) rotate(5deg); }
}

/* ===== Navigation ===== */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--color-border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-text);
    text-decoration: none;
    transition: var(--transition);
}

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

.logo-img {
    width: 36px;
    height: auto;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.nav-link {
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text-light);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.nav-link:hover, .nav-link.active {
    color: var(--color-primary);
    background: var(--color-bg-warm);
}

/* ===== Container ===== */
.container {
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ===== Hero Section ===== */
.hero {
    text-align: center;
    margin-bottom: 1.5rem;
}

.hero h1 {
    font-size: clamp(1.75rem, 6vw, 2.5rem);
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.02em;
}

/* ===== Upload Section ===== */
.upload-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.upload-zone {
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1/1;
    border: 3px dashed var(--color-border);
    border-radius: var(--radius-xl);
    background: var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--color-primary);
    background: var(--color-bg-warm);
    transform: scale(1.02);
}

.upload-zone.drag-over {
    border-style: solid;
}

.upload-content {
    text-align: center;
    padding: 2rem;
}

.upload-icon-img {
    width: 100px;
    height: auto;
    margin-bottom: 1rem;
    animation: bounce-soft 2s ease-in-out infinite;
}

@keyframes bounce-soft {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.upload-content h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.upload-content p {
    color: var(--color-text-light);
}

.upload-hint {
    font-size: 0.875rem;
    margin-top: 0.5rem;
    opacity: 0.7;
}

/* ===== Preview Container ===== */
.preview-container {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.preview-container img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    font-family: var(--font-primary);
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: white;
    box-shadow: 0 4px 15px rgba(224, 123, 57, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(224, 123, 57, 0.5);
}

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

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

.btn-secondary:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.btn-text {
    background: transparent;
    color: var(--color-text-light);
    padding: 0.5rem 1rem;
}

.btn-text:hover {
    color: var(--color-primary);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ===== Loading Section ===== */
.loading-section {
    text-align: center;
    padding: 3rem 1rem;
}

.loading-animation {
    margin-bottom: 2rem;
}

/* ===== Spinning Cube ===== */
.spinning-cube {
    width: 120px;
    height: auto;
    animation: spin-cube 2s ease-in-out infinite;
}

@keyframes spin-cube {
    0% { transform: rotateY(0deg) scale(1); }
    25% { transform: rotateY(90deg) scale(1.05); }
    50% { transform: rotateY(180deg) scale(1); }
    75% { transform: rotateY(270deg) scale(1.05); }
    100% { transform: rotateY(360deg) scale(1); }
}

.loading-section h2 {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
}

.loading-text {
    color: var(--color-text-light);
    margin-bottom: 1.5rem;
}

.progress-bar {
    width: 100%;
    max-width: 300px;
    height: 8px;
    background: var(--color-border);
    border-radius: 4px;
    margin: 0 auto;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
    border-radius: 4px;
    animation: progress 25s ease-out forwards;
}

@keyframes progress {
    0% { width: 0%; }
    50% { width: 70%; }
    90% { width: 90%; }
    100% { width: 95%; }
}

/* ===== Spinner ===== */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner.large {
    width: 40px;
    height: 40px;
    border-width: 4px;
    border-color: var(--color-border);
    border-top-color: var(--color-primary);
}

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

/* ===== Result Section ===== */
.result-section {
    text-align: center;
}

.result-section h2 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.result-image-container {
    width: 100%;
    max-width: 400px;
    margin: 0 auto 1rem;
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: reveal 0.5s ease-out;
}

@keyframes reveal {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.result-image-container img {
    width: 100%;
    display: block;
}

.result-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

/* ===== Shared Message ===== */
.shared-message {
    text-align: center;
    padding: 2rem;
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    animation: pop-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes pop-in {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.success-icon {
    width: 60px;
    height: 60px;
    background: var(--color-success);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 1rem;
}

.shared-message p {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* ===== Gallery ===== */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.gallery-loading {
    text-align: center;
    padding: 4rem 1rem;
}

.gallery-loading p {
    margin-top: 1rem;
    color: var(--color-text-light);
}

.empty-state {
    text-align: center;
    padding: 4rem 1rem;
}

.empty-cube-icon {
    width: 100px;
    height: auto;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h2 {
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--color-text-light);
    margin-bottom: 1.5rem;
}

/* ===== Pet Card ===== */
.pet-card {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    animation: card-in 0.5s ease-out both;
}

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

.pet-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.pet-image-container {
    aspect-ratio: 1;
    overflow: hidden;
}

.pet-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.pet-card:hover .pet-image-container img {
    transform: scale(1.05);
}

.pet-card-footer {
    display: block;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--color-border);
}

.pet-card-footer-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    margin-bottom: 0.25rem;
}

.pet-card-footer-top .time-ago {
    margin-left: auto;
}

.heart-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--color-heart-bg);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font-primary);
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-heart);
    transition: var(--transition);
}

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

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

.heart-btn.bounce {
    animation: heart-bounce 0.3s ease;
}

@keyframes heart-bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.heart-icon {
    font-size: 1.2rem;
}

.time-ago {
    font-size: 0.875rem;
    color: var(--color-text-light);
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 1.5rem 1rem;
    margin-top: 2rem;
}

.footer-email {
    font-size: 0.8rem;
    color: #999;
    text-decoration: none;
    transition: var(--transition);
}

.footer-email:hover {
    color: var(--color-primary);
}

/* ===== Community Feed (on homepage) ===== */
.community-feed {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.feed-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--color-text);
    text-align: center;
}

.feed-gallery {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.feed-loading {
    text-align: center;
    padding: 2rem;
}

.feed-empty {
    text-align: center;
    padding: 2rem;
    color: var(--color-text-light);
}

.spinning-cube.small {
    width: 60px;
}

/* Button SVG icons */
.btn svg {
    flex-shrink: 0;
}

/* ===== Share Modal ===== */
.share-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.share-modal-content {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    max-width: 400px;
    width: 100%;
    animation: pop-in 0.3s ease-out;
}

.share-modal h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    text-align: center;
}

.share-modal input[type="text"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: var(--font-primary);
    font-size: 1rem;
    margin-bottom: 1rem;
    transition: var(--transition);
}

.share-modal input[type="text"]:focus {
    outline: none;
    border-color: var(--color-primary);
}

.share-modal-actions {
    display: flex;
    gap: 0.75rem;
}

.share-modal-actions .btn {
    flex: 1;
}

/* ===== Comments Section ===== */
.comments-section {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg-warm);
}

.comments-list {
    margin-bottom: 0.75rem;
    max-height: 150px;
    overflow-y: auto;
}

.comment-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.9rem;
}

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

.comment-author {
    font-weight: 600;
    color: var(--color-primary);
    margin-right: 0.5rem;
}

.comment-text {
    color: var(--color-text);
}

.comment-time {
    font-size: 0.75rem;
    color: var(--color-text-light);
    margin-top: 0.25rem;
}

.comment-form {
    display: flex;
    gap: 0.5rem;
}

.comment-form input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-primary);
    font-size: 0.85rem;
}

.comment-form input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.comment-form button {
    padding: 0.5rem 1rem;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-primary);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.comment-form button:hover {
    background: var(--color-primary-dark);
}

/* ===== Pet Info (in footer) ===== */
.pet-info-line {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.pet-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
    display: inline;
    word-break: break-word;
}

.pet-author {
    font-size: 0.8rem;
    color: var(--color-text-light);
    display: inline;
    margin-left: 0.5rem;
}

.pet-author strong {
    color: var(--color-primary);
    font-weight: 500;
}

/* ===== Comment Button (next to heart) ===== */
.comment-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    background: var(--color-bg-warm);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font-primary);
    color: var(--color-text-light);
    transition: var(--transition);
}

.comment-btn:hover {
    background: var(--color-border);
    color: var(--color-primary);
}

.comment-btn svg {
    width: 18px;
    height: 18px;
}

/* Comments section - always visible */
.comments-section {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg-warm);
    display: block;
}

/* Comment form - hidden by default, shown when toggled */
.comment-form {
    display: none;
}

.comment-form.open {
    display: flex;
}

/* ===== Admin Page ===== */
.admin-login {
    max-width: 400px;
    margin: 2rem auto;
    padding: 2rem;
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
}

.admin-login h2 {
    text-align: center;
    margin-bottom: 1.5rem;
}

.admin-login input[type="password"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: var(--font-primary);
    font-size: 1rem;
    margin-bottom: 1rem;
}

.admin-login input[type="password"]:focus {
    outline: none;
    border-color: var(--color-primary);
}

.admin-panel {
    max-width: 800px;
    margin: 0 auto;
}

.admin-item {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.admin-item-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
}

.admin-item-header img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius-md);
}

.admin-item-info {
    flex: 1;
}

.admin-item-info p {
    margin: 0.25rem 0;
    font-size: 0.9rem;
}

.btn-delete {
    background: #e74c4c;
    color: white;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

.btn-delete:hover {
    background: #c73c3c;
}

.admin-comments {
    padding: 0 1rem 1rem;
}

.admin-comment {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.admin-comment-text {
    font-size: 0.85rem;
}

/* ===== Utility Classes ===== */
.hidden {
    display: none !important;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
    .navbar {
        padding: 0.75rem 1rem;
    }
    
    .logo {
        font-size: 1rem;
    }
    
    .logo-img {
        width: 28px;
    }
    
    .container {
        padding: 1rem 1rem;
    }
    
    .hero {
        margin-bottom: 1rem;
    }
    
    .hero h1 {
        font-size: 1.4rem;
    }
    
    .upload-zone {
        aspect-ratio: 1/1;
        max-height: 280px;
    }
    
    .upload-icon-img {
        width: 60px;
    }
    
    .upload-content h2 {
        font-size: 1.1rem;
    }
    
    .upload-content p {
        font-size: 0.9rem;
    }
    
    .btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.9rem;
    }
    
    .result-section h2 {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }
    
    .result-image-container {
        max-width: 280px;
        margin-bottom: 0.75rem;
    }
    
    .result-actions {
        flex-direction: row;
        gap: 0.5rem;
    }
    
    .result-actions .btn {
        flex: 1;
        padding: 0.7rem 0.75rem;
        font-size: 0.85rem;
    }
    
    .gallery {
        grid-template-columns: 1fr;
    }
    
    .spinning-cube {
        width: 80px;
    }
    
    .community-feed {
        margin-top: 1rem;
        padding-top: 1rem;
    }
    
    .feed-title {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }
    
    .loading-section {
        padding: 2rem 1rem;
    }
    
    .loading-section h2 {
        font-size: 1.2rem;
    }
    
    /* Move floating cubes further down on mobile */
    .cube-1 { top: 35%; width: 70px; }
    .cube-2 { top: 75%; width: 50px; }
    .cube-3 { top: 55%; width: 60px; }
    
    /* Fix comment form on mobile */
    .comment-form {
        flex-wrap: wrap;
    }
    
    .comment-form input[name="name"] {
        max-width: 70px !important;
        min-width: 70px;
    }
    
    .comment-form input[name="comment"] {
        flex: 1;
        min-width: 100px;
    }
    
    .comment-form button {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        white-space: nowrap;
    }
}
