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

:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #1e1e36;
    --bg-card-hover: #252545;
    --text-primary: #f0f0f5;
    --text-secondary: #9898b8;
    --text-muted: #6b6b8a;
    --accent: #7c6cf0;
    --accent-light: #9d8ff5;
    --accent-glow: rgba(124, 108, 240, 0.3);
    --gradient-1: linear-gradient(135deg, #7c6cf0, #e07be0);
    --gradient-2: linear-gradient(135deg, #6c8cf0, #7c6cf0);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 40px rgba(124, 108, 240, 0.15);
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* ===== Background Decoration ===== */
.bg-decoration {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.bg-circle {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.15;
}

.bg-circle-1 {
    width: 600px;
    height: 600px;
    background: #7c6cf0;
    top: -200px;
    right: -200px;
    animation: float 20s ease-in-out infinite;
}

.bg-circle-2 {
    width: 400px;
    height: 400px;
    background: #e07be0;
    bottom: -100px;
    left: -100px;
    animation: float 25s ease-in-out infinite reverse;
}

.bg-circle-3 {
    width: 300px;
    height: 300px;
    background: #6c8cf0;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: float 15s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -30px) scale(1.05); }
    66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* ===== App Layout ===== */
.app {
    position: relative;
    z-index: 1;
    max-width: 720px;
    margin: 0 auto;
    padding: 0 24px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Header ===== */
.header {
    text-align: center;
    padding: 40px 0 28px;
}

.logo {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -1px;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.logo-accent {
    background: var(--gradient-2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 8px;
    font-weight: 400;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

.subtitle-sep {
    color: var(--text-muted);
    opacity: 0.4;
}

/* ===== AI Badge ===== */
.ai-badge-header {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--gradient-1);
    color: white;
    line-height: 1.4;
}

/* ===== Drop Zone ===== */
.upload-section {
    margin-bottom: 24px;
}

.drop-zone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 240px;
    border: 2px dashed rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-xl);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: var(--transition);
    overflow: hidden;
}

.drop-zone:hover {
    border-color: var(--accent);
    background: rgba(124, 108, 240, 0.04);
}

.drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(124, 108, 240, 0.08);
    box-shadow: var(--shadow-glow);
}

.drop-zone.has-image {
    border-style: solid;
    border-color: rgba(124, 108, 240, 0.3);
    padding: 8px;
}

.upload-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 40px 20px;
}

.upload-prompt.hidden {
    display: none;
}

.upload-icon {
    color: var(--text-muted);
    opacity: 0.6;
    margin-bottom: 4px;
}

.upload-text {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
}

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

.upload-types {
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.4;
    margin-top: 4px;
}

.image-preview {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    border-radius: var(--radius-md);
}

.image-preview.hidden {
    display: none;
}

.remove-image-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    cursor: pointer;
    transition: var(--transition);
    backdrop-filter: blur(8px);
}

.remove-image-btn:hover {
    background: rgba(239, 68, 68, 0.7);
    transform: scale(1.1);
}

.remove-image-btn.hidden {
    display: none;
}

/* ===== Generate Button ===== */
.generate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 16px 28px;
    margin-top: 16px;
    background: var(--gradient-1);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1.05rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.generate-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px var(--accent-glow);
}

.generate-btn:active:not(:disabled) {
    transform: translateY(0);
}

.generate-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-sparkle {
    transition: transform var(--transition);
}

.generate-btn:hover:not(:disabled) .btn-sparkle {
    transform: rotate(20deg) scale(1.1);
}

/* ===== API Status ===== */
.api-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.api-status.hidden {
    display: none;
}

.api-status.warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

.api-status.info {
    background: rgba(124, 108, 240, 0.08);
    border: 1px solid rgba(124, 108, 240, 0.15);
    color: var(--accent-light);
}

/* ===== Loading / Paw Loader ===== */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 40px 0;
    color: var(--text-secondary);
}

.loading.hidden {
    display: none;
}

.loading-text {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
}

.loading-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
    opacity: 0.7;
}

/* Paw loader animation */
.paw-loader {
    position: relative;
    width: 120px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.paw {
    color: var(--accent);
    opacity: 0.3;
    animation: paw-bounce 1.5s ease-in-out infinite;
}

.paw-1 {
    animation-delay: 0s;
    width: 36px;
    height: 36px;
}

.paw-2 {
    animation-delay: 0.3s;
    width: 28px;
    height: 28px;
}

.paw-3 {
    animation-delay: 0.6s;
    width: 22px;
    height: 22px;
}

@keyframes paw-bounce {
    0%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.3;
    }
    50% {
        transform: translateY(-16px) scale(1.1);
        opacity: 1;
    }
}

/* ===== Error ===== */
.error-message {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 18px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-md);
    color: #f87171;
    font-size: 0.9rem;
    margin-bottom: 16px;
    line-height: 1.5;
}

.error-message.hidden {
    display: none;
}

.error-message svg {
    flex-shrink: 0;
    margin-top: 2px;
}

/* ===== Results ===== */
.results {
    animation: fadeInUp 0.5s ease-out;
}

.results.hidden {
    display: none;
}

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

.results-header {
    text-align: center;
    margin-bottom: 24px;
}

.results-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-secondary);
}

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

.results-label {
    opacity: 0.8;
}

.pet-description {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 6px;
    font-style: italic;
    opacity: 0.7;
}

.pet-description.hidden {
    display: none;
}

/* ===== Cards ===== */
.cards-container {
    display: grid;
    gap: 16px;
}

.name-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-lg);
    padding: 28px 32px 24px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.name-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(124, 108, 240, 0.05), transparent 60%);
    opacity: 0;
    transition: var(--transition);
    pointer-events: none;
}

.name-card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(124, 108, 240, 0.2);
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
}

.name-card:hover::before {
    opacity: 1;
}

/* Top section: name + badge */
.card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
    z-index: 1;
    position: relative;
}

.pet-name {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 1px;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.3;
}

.card-badges {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    align-items: center;
}

.card-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 10px;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.card-badge.recommended {
    background: var(--gradient-1);
    color: white;
}

.card-badge.ai-badge {
    background: rgba(124, 108, 240, 0.15);
    color: var(--accent-light);
    border: 1px solid rgba(124, 108, 240, 0.2);
}

/* Meaning */
.card-meaning {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 10px;
    z-index: 1;
    position: relative;
}

.meaning-label {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--accent-light);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 4px;
    opacity: 0.7;
}

/* Reason */
.card-reason {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.7;
    z-index: 1;
    position: relative;
}

.reason-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 4px;
    opacity: 0.6;
}

/* Divider */
.card-divider {
    height: 1px;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05),
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05)
    );
    margin-bottom: 14px;
    z-index: 1;
    position: relative;
}

/* Copy button */
.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-family: inherit;
    padding: 5px 12px;
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
    margin-top: 14px;
}

.copy-btn:hover {
    background: rgba(124, 108, 240, 0.12);
    border-color: rgba(124, 108, 240, 0.3);
    color: var(--accent-light);
}

.copy-btn.copied {
    background: rgba(52, 211, 153, 0.15);
    border-color: rgba(52, 211, 153, 0.3);
    color: #34d399;
}

.copy-btn svg {
    flex-shrink: 0;
}

.copy-label {
    line-height: 1;
}

/* ===== Download Bar ===== */
.download-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 24px;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    animation: fadeInUp 0.4s ease-out;
}

.download-bar.hidden {
    display: none;
}

.download-bar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.download-bar-left svg {
    flex-shrink: 0;
    color: var(--accent);
}

.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    background: var(--gradient-1);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.download-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

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

.download-btn svg {
    flex-shrink: 0;
}

/* ===== Payment Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-out;
    padding: 24px;
}

.modal-overlay.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.25s ease-out;
}

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

.modal-header {
    padding: 24px 24px 0;
}

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-body {
    padding: 16px 24px;
}

.modal-body p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

.modal-body p strong {
    color: var(--accent-light);
    font-weight: 600;
}

.modal-hint {
    font-size: 0.82rem !important;
    color: var(--text-muted) !important;
    margin-top: 8px;
    opacity: 0.7;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 16px 24px 24px;
}

.modal-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

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

.modal-btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
}

.modal-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

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

.modal-btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

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

/* ===== Footer ===== */
.footer {
    margin-top: auto;
    text-align: center;
    padding: 32px 0;
    color: var(--text-secondary);
    font-size: 0.8rem;
    opacity: 0.5;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
    .header {
        padding: 28px 0 20px;
    }

    .logo {
        font-size: 2rem;
    }

    .drop-zone {
        min-height: 200px;
    }

    .name-card {
        padding: 22px 20px 20px;
    }

    .pet-name {
        font-size: 1.6rem;
    }

    .download-bar {
        flex-direction: column;
        text-align: center;
    }

    .download-bar-left {
        justify-content: center;
    }

    .download-btn {
        width: 100%;
        justify-content: center;
    }

    .modal-footer {
        flex-direction: column-reverse;
    }

    .modal-btn {
        justify-content: center;
    }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}
