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

/* Ensure the HTML `hidden` attribute always wins over component display rules */
[hidden] {
    display: none !important;
}

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a25;
    --accent-gold: #d4af37;
    --accent-gold-light: #f0d060;
    --accent-gold-dark: #b8962e;
    --text-primary: #f5f5f7;
    --text-secondary: #a0a0a8;
    --text-muted: #6a6a72;
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.15);
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.15);
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --radius: 16px;
    --radius-sm: 8px;
    --radius-lg: 24px;
}

html {
    font-size: 16px;
}

body {
    font-family: 'Outfit', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Background Pattern */
.background-pattern {
    position: fixed;
    inset: 0;
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(212, 175, 55, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(212, 175, 55, 0.03) 0%, transparent 50%),
        linear-gradient(135deg, transparent 40%, rgba(212, 175, 55, 0.02) 50%, transparent 60%);
    pointer-events: none;
    z-index: -1;
}

.background-pattern::before {
    content: '';
    position: absolute;
    inset: 0;
    background: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 100px,
            rgba(255, 255, 255, 0.01) 100px,
            rgba(255, 255, 255, 0.01) 101px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 100px,
            rgba(255, 255, 255, 0.01) 100px,
            rgba(255, 255, 255, 0.01) 101px
        );
}

/* Container */
.container {
    width: 100%;
    max-width: 480px;
    padding: 2rem 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Header */
.header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.logo {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 
        0 0 0 4px var(--bg-primary),
        0 0 0 6px rgba(212, 175, 55, 0.3),
        0 20px 40px rgba(212, 175, 55, 0.2);
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 
        0 0 0 4px var(--bg-primary),
        0 0 0 6px rgba(212, 175, 55, 0.3),
        0 20px 40px rgba(212, 175, 55, 0.2);
    }
    50% { box-shadow: 
        0 0 0 4px var(--bg-primary),
        0 0 0 10px rgba(212, 175, 55, 0.15),
        0 20px 40px rgba(212, 175, 55, 0.3);
    }
}

.logo-letter {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--bg-primary);
    letter-spacing: -2px;
}

.title {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 300;
}

/* Upload Zone */
.upload-zone {
    background: var(--bg-secondary);
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    min-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.upload-zone:hover {
    border-color: var(--accent-gold);
    background: var(--bg-tertiary);
}

.upload-zone.dragover {
    border-color: var(--accent-gold);
    background: rgba(212, 175, 55, 0.05);
    transform: scale(1.02);
}

.upload-content {
    text-align: center;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.upload-icon {
    width: 72px;
    height: 72px;
    background: rgba(212, 175, 55, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-gold);
}

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

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

/* Preview */
.preview-container {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

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

.remove-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.remove-btn:hover {
    background: var(--error);
    border-color: var(--error);
    transform: scale(1.1);
}

/* Analyze Button */
.analyze-btn {
    width: 100%;
    padding: 1rem 2rem;
    font-family: inherit;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--bg-primary);
    background: linear-gradient(135deg, var(--accent-gold-light), var(--accent-gold));
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 20px rgba(212, 175, 55, 0.3);
}

.analyze-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(212, 175, 55, 0.4);
}

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

.analyze-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-loader {
    display: none;
    align-items: center;
    gap: 0.75rem;
}

.btn-loader:not([hidden]) {
    display: flex;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-top-color: var(--bg-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Result Container */
.result-container {
    animation: slideUp 0.5s ease-out;
}

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

.result-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    text-align: center;
}

.result-card.result-yes {
    border-color: rgba(34, 197, 94, 0.3);
    background: linear-gradient(180deg, var(--success-bg) 0%, var(--bg-secondary) 100%);
}

.result-card.result-no {
    border-color: rgba(239, 68, 68, 0.3);
    background: linear-gradient(180deg, var(--error-bg) 0%, var(--bg-secondary) 100%);
}

.result-badge {
    padding: 0.75rem 2.5rem;
    border-radius: 100px;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 2px;
}

.badge-yes {
    background: var(--success);
    color: white;
    box-shadow: 0 0 30px rgba(34, 197, 94, 0.4);
}

.badge-no {
    background: var(--error);
    color: white;
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.4);
}

.badge-error {
    background: var(--text-muted);
    color: white;
    font-size: 1rem;
    letter-spacing: 1px;
}

.result-caption {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    line-height: 1.6;
    max-width: 90%;
}

/* Confidence Bar */
.confidence-bar {
    width: 100%;
    margin-top: 0.5rem;
}

.confidence-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.confidence-track {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 100px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-gold-dark), var(--accent-gold-light));
    border-radius: 100px;
    transition: width 0.6s ease-out;
    width: 0;
}

/* Footer */
.footer {
    padding: 1.5rem;
    text-align: center;
}

.footer p {
    font-size: 0.8125rem;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

/* Responsive */
@media (max-width: 480px) {
    html {
        font-size: 15px;
    }

    .container {
        padding: 1.5rem 1rem;
        gap: 1.5rem;
    }

    .logo {
        width: 64px;
        height: 64px;
    }

    .logo-letter {
        font-size: 2rem;
    }

    .title {
        font-size: 1.75rem;
    }

    .upload-zone {
        min-height: 240px;
    }

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

    .upload-icon svg {
        width: 36px;
        height: 36px;
    }

    .result-card {
        padding: 1.5rem;
    }

    .result-badge {
        padding: 0.625rem 2rem;
        font-size: 1.25rem;
    }
}

@media (max-width: 360px) {
    .container {
        padding: 1rem 0.75rem;
    }

    .result-caption {
        font-size: 0.875rem;
    }
}

/* High resolution displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .upload-zone,
    .result-card {
        border-width: 0.5px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus states for accessibility */
.analyze-btn:focus-visible,
.remove-btn:focus-visible {
    outline: 2px solid var(--accent-gold);
    outline-offset: 2px;
}

.upload-zone:focus-within {
    border-color: var(--accent-gold);
}

