/* ═══════════════════════════════════════════════════════════
   InstaDownloader — Design System & Styles
   Dark glassmorphism theme with Instagram gradient accents
   ═══════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties ─────────────────────────────── */
:root {
    /* Background */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-card-hover: rgba(255, 255, 255, 0.07);
    --bg-glass: rgba(255, 255, 255, 0.06);
    --bg-glass-border: rgba(255, 255, 255, 0.1);

    /* Text */
    --text-primary: #f0f0f5;
    --text-secondary: rgba(240, 240, 245, 0.6);
    --text-tertiary: rgba(240, 240, 245, 0.35);
    --text-accent: #e879f9;

    /* Instagram Gradient */
    --gradient-instagram: linear-gradient(135deg, #f9ce34, #ee2a7b, #6228d7);
    --gradient-accent: linear-gradient(135deg, #c084fc, #e879f9, #fb7185);
    --gradient-button: linear-gradient(135deg, #7c3aed, #c026d3, #e11d48);
    --gradient-button-hover: linear-gradient(135deg, #8b5cf6, #d946ef, #f43f5e);
    --gradient-success: linear-gradient(135deg, #34d399, #06b6d4);

    /* Reel/Photo/Video colors */
    --color-reel: #e879f9;
    --color-photo: #60a5fa;
    --color-video: #34d399;
    --color-carousel: #fbbf24;

    /* Sizes */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    /* Shadows */
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.05);
    --shadow-glow: 0 0 60px rgba(168, 85, 247, 0.15);
    --shadow-button: 0 4px 20px rgba(168, 85, 247, 0.3);

    /* Transitions */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

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

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

/* ── Animated Background ───────────────────────────────── */
.bg-gradient {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(120, 40, 200, 0.15), transparent),
        radial-gradient(ellipse 60% 40% at 80% 60%, rgba(232, 40, 120, 0.08), transparent),
        radial-gradient(ellipse 50% 30% at 20% 80%, rgba(100, 60, 255, 0.06), transparent);
    z-index: 0;
    animation: bgShift 20s ease-in-out infinite alternate;
}

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

.bg-noise {
    position: fixed;
    inset: 0;
    opacity: 0.015;
    z-index: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

/* ── Container ─────────────────────────────────────────── */
.container {
    position: relative;
    z-index: 1;
    max-width: 640px;
    margin: 0 auto;
    padding: 60px 20px 40px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Header ────────────────────────────────────────────── */
.header {
    text-align: center;
    margin-bottom: 48px;
    animation: fadeInUp 0.8s ease-out;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 12px;
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: var(--gradient-instagram);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 16px rgba(238, 42, 123, 0.3);
}

.logo-icon svg {
    width: 24px;
    height: 24px;
}

.logo h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

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

.tagline {
    color: var(--text-secondary);
    font-size: 1.05rem;
    font-weight: 400;
    letter-spacing: -0.01em;
}

/* ── Glass Card ────────────────────────────────────────── */
.glass-card {
    background: var(--bg-glass);
    border: 1px solid var(--bg-glass-border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-card);
    transition: var(--transition-smooth);
}

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: var(--shadow-card), var(--shadow-glow);
}

/* ── Input Section ─────────────────────────────────────── */
.main {
    flex: 1;
}

.input-section {
    animation: fadeInUp 0.8s ease-out 0.1s both;
}

.input-card {
    padding: 8px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0;
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-md);
    padding: 0 6px 0 16px;
    border: 1px solid transparent;
    transition: var(--transition-smooth);
}

.input-wrapper:focus-within {
    border-color: rgba(168, 85, 247, 0.4);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.08);
}

.input-icon {
    color: var(--text-tertiary);
    flex-shrink: 0;
    transition: var(--transition-smooth);
}

.input-wrapper:focus-within .input-icon {
    color: var(--text-accent);
}

.input-icon svg {
    width: 18px;
    height: 18px;
}

#url-input {
    width: 100%;
    padding: 14px 12px;
    border: none;
    background: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 400;
    outline: none;
}

#url-input::placeholder {
    color: var(--text-tertiary);
}

.paste-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    border: none;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.paste-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
    transform: scale(1.05);
}

.paste-btn:active {
    transform: scale(0.95);
}

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

/* ── Fetch Button ──────────────────────────────────────── */
.fetch-btn {
    flex-shrink: 0;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--gradient-button);
    color: white;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-smooth);
    box-shadow: var(--shadow-button);
    position: relative;
    overflow: hidden;
}

.fetch-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gradient-button-hover);
    opacity: 0;
    transition: var(--transition-smooth);
}

.fetch-btn:hover:not(:disabled)::before {
    opacity: 1;
}

.fetch-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 28px rgba(168, 85, 247, 0.4);
}

.fetch-btn:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
}

.fetch-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.fetch-btn .btn-text,
.fetch-btn .btn-arrow {
    position: relative;
    z-index: 1;
}

.fetch-btn .btn-arrow {
    width: 18px;
    height: 18px;
    transition: var(--transition-smooth);
}

.fetch-btn:hover:not(:disabled) .btn-arrow {
    transform: translateX(3px);
}

.fetch-btn .btn-loader {
    display: none;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 1;
}

.fetch-btn.loading .btn-text,
.fetch-btn.loading .btn-arrow {
    display: none;
}

.fetch-btn.loading .btn-loader {
    display: flex;
}

/* ── Spinner ───────────────────────────────────────────── */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ── Supported Types ───────────────────────────────────── */
.supported-types {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.type-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 100px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.type-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.type-dot.reel { background: var(--color-reel); box-shadow: 0 0 8px rgba(232, 121, 249, 0.5); }
.type-dot.photo { background: var(--color-photo); box-shadow: 0 0 8px rgba(96, 165, 250, 0.5); }
.type-dot.video { background: var(--color-video); box-shadow: 0 0 8px rgba(52, 211, 153, 0.5); }
.type-dot.carousel { background: var(--color-carousel); box-shadow: 0 0 8px rgba(251, 191, 36, 0.5); }

/* ── Preview Section ───────────────────────────────────── */
.preview-section {
    margin-top: 32px;
    display: none;
    animation: fadeInUp 0.5s ease-out;
}

.preview-section.visible {
    display: block;
}

.preview-card {
    overflow: hidden;
}

.preview-thumbnail {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--bg-secondary);
}

.preview-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition-smooth);
}

.preview-card:hover .preview-thumbnail img {
    transform: scale(1.03);
}

.type-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 5px 12px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.type-badge.reel {
    background: rgba(232, 121, 249, 0.2);
    color: var(--color-reel);
    border: 1px solid rgba(232, 121, 249, 0.3);
}

.type-badge.photo {
    background: rgba(96, 165, 250, 0.2);
    color: var(--color-photo);
    border: 1px solid rgba(96, 165, 250, 0.3);
}

.type-badge.video {
    background: rgba(52, 211, 153, 0.2);
    color: var(--color-video);
    border: 1px solid rgba(52, 211, 153, 0.3);
}

.type-badge.carousel {
    background: rgba(251, 191, 36, 0.2);
    color: var(--color-carousel);
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.duration-badge {
    position: absolute;
    bottom: 12px;
    right: 12px;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    display: none;
}

.duration-badge.visible {
    display: block;
}

/* ── Preview Info ──────────────────────────────────────── */
.preview-info {
    padding: 20px 24px 24px;
}

.preview-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.preview-uploader {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 20px;
}

.carousel-info {
    display: none;
    align-items: center;
    gap: 6px;
    color: var(--color-carousel);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 20px;
    padding: 10px 14px;
    background: rgba(251, 191, 36, 0.08);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(251, 191, 36, 0.15);
}

.carousel-info.visible {
    display: flex;
}

/* ── Download Button ───────────────────────────────────── */
.download-btn {
    width: 100%;
    padding: 16px 24px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--gradient-success);
    color: white;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 20px rgba(52, 211, 153, 0.25);
}

.download-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(52, 211, 153, 0.35);
}

.download-btn:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
}

.download-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.download-btn .btn-text {
    display: flex;
    align-items: center;
    gap: 10px;
}

.download-btn .btn-loader {
    display: none;
    align-items: center;
    gap: 8px;
}

.download-btn.loading .btn-text {
    display: none;
}

.download-btn.loading .btn-loader {
    display: flex;
}

/* ── Toast Notifications ───────────────────────────────── */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(120px);
    padding: 14px 22px;
    background: #1c1c24;
    border: 1px solid rgba(255, 80, 80, 0.3);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: #ff6b6b;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    z-index: 100;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 90vw;
}

.toast.visible {
    transform: translateX(-50%) translateY(0);
}

.toast-success {
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.3);
}

.toast-icon svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* ── Footer ────────────────────────────────────────────── */
.footer {
    text-align: center;
    padding: 40px 0 0;
    margin-top: auto;
}

.footer p {
    color: var(--text-tertiary);
    font-size: 0.8rem;
}

.footer .disclaimer {
    margin-top: 6px;
    font-size: 0.72rem;
}

.heart {
    color: #ef4444;
    display: inline-block;
    animation: heartbeat 1.5s ease-in-out infinite;
}

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

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

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.shimmer {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.03) 25%,
        rgba(255, 255, 255, 0.08) 50%,
        rgba(255, 255, 255, 0.03) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 640px) {
    .container {
        padding: 40px 16px 24px;
    }

    .logo h1 {
        font-size: 1.6rem;
    }

    .tagline {
        font-size: 0.9rem;
    }

    .input-card {
        flex-direction: column;
        padding: 10px;
    }

    .input-wrapper {
        width: 100%;
    }

    .fetch-btn {
        width: 100%;
        justify-content: center;
        padding: 16px;
    }

    .preview-info {
        padding: 16px 18px 20px;
    }

    .supported-types {
        gap: 6px;
    }

    .type-pill {
        padding: 5px 10px;
        font-size: 0.75rem;
    }
}
