/* ============================================
   AlwaysViral Tools – Instagram Video Downloader
   Design System & Styles
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ---------- CSS Variables ---------- */
:root {
    --bg-body: #fff0f5;
    --bg-card: #ffffff;
    --bg-input: #fce7f3;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    --border-focus: #db2777;
    --accent-purple: #833ab4;
    --accent-red: #fd1d1d;
    --accent-orange: #fcb045;
    --success-bg: #ecfdf5;
    --success-border: #6ee7b7;
    --success-text: #065f46;
    --success-icon: #10b981;
    --error-bg: #fef2f2;
    --error-border: #fca5a5;
    --error-text: #991b1b;
    --warning-bg: #fffbeb;
    --warning-border: #fcd34d;
    --warning-text: #92400e;
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 25px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 40px -5px rgba(0,0,0,0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Tool Section Container ---------- */
.tool-section { max-width: 800px; margin: 60px auto; padding: 0 20px; }
@media (max-width: 768px) { .tool-section { margin: 30px auto; padding: 0 16px; } }

/* ---------- Tool Header ---------- */
.tool-header { text-align: center; margin-bottom: 32px; }

.tool-header__icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 64px; height: 64px; border-radius: var(--radius-lg);
    background: linear-gradient(135deg, #f472b6, #be185d, #831843);
    margin-bottom: 20px;
    box-shadow: 0 8px 24px rgba(131, 58, 180, 0.25);
    animation: pulse-glow 3s ease-in-out infinite;
}
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 8px 24px rgba(131, 58, 180, 0.25); }
    50% { box-shadow: 0 8px 32px rgba(131, 58, 180, 0.4); }
}
.tool-header__icon svg { width: 32px; height: 32px; fill: #ffffff; }

.tool-header__title {
    font-size: 26px; font-weight: 800; color: var(--text-primary);
    margin-bottom: 8px; letter-spacing: -0.5px;
}
.tool-header__subtitle {
    font-size: 15px; color: var(--text-secondary);
    max-width: 440px; margin: 0 auto; line-height: 1.5;
}

/* ---------- Tool Card ---------- */
.tool-card {
    background: var(--bg-card); border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg); padding: 40px;
    border: 1px solid var(--border-color); transition: var(--transition);
    position: relative; overflow: hidden;
}
.tool-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, #833ab4, #fd1d1d, #fcb045);
    opacity: 0; transition: var(--transition);
}
.tool-card:hover::before { opacity: 1; }
@media (max-width: 768px) { .tool-card { padding: 24px; border-radius: var(--radius-lg); } }

/* ---------- Form Elements ---------- */
.form-group { margin-bottom: 20px; }
.form-label {
    display: block; font-size: 13px; font-weight: 600; color: var(--text-primary);
    margin-bottom: 8px; letter-spacing: 0.3px; text-transform: uppercase;
}
.input-wrapper { position: relative; display: flex; align-items: center; }
.input-wrapper__prefix {
    position: absolute; left: 16px; color: var(--text-muted);
    font-size: 15px; font-weight: 500; pointer-events: none; transition: var(--transition);
}
.input-wrapper__field {
    width: 100%; padding: 14px 16px; font-size: 15px;
    font-family: 'Inter', sans-serif; font-weight: 500; color: var(--text-primary);
    background: var(--bg-input); border: 2px solid var(--border-color);
    border-radius: var(--radius-md); outline: none; transition: var(--transition);
}
.input-wrapper__field--with-prefix { padding-left: 38px; }
.input-wrapper__field::placeholder { color: var(--text-muted); font-weight: 400; }
.input-wrapper__field:focus {
    border-color: var(--border-focus); background: var(--bg-card);
    box-shadow: 0 0 0 4px rgba(17, 24, 39, 0.08);
}
.input-wrapper__field:focus + .input-wrapper__prefix,
.input-wrapper__field:not(:placeholder-shown) + .input-wrapper__prefix { color: var(--text-primary); }
.input-wrapper__field:disabled { opacity: 0.5; cursor: not-allowed; background: #f3f4f6; }

/* ---------- Submit Button ---------- */
.btn-submit {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; padding: 15px 24px; font-size: 15px; font-weight: 600;
    font-family: 'Inter', sans-serif; color: #ffffff; background: var(--text-primary);
    border: none; border-radius: var(--radius-md); cursor: pointer;
    transition: var(--transition); letter-spacing: 0.3px; position: relative; overflow: hidden;
}
.btn-submit:hover:not(:disabled) {
    background: #1f2937; transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(17, 24, 39, 0.3);
}
.btn-submit:disabled { opacity: 0.5; cursor: not-allowed; background: #9ca3af; }
.btn-submit svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }

/* ---------- Loading Spinner ---------- */
.spinner {
    display: none; width: 20px; height: 20px;
    border: 2.5px solid rgba(255,255,255,0.3); border-top-color: #ffffff;
    border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn-submit.loading .spinner { display: block; }
.btn-submit.loading .btn-text, .btn-submit.loading .btn-icon { display: none; }

/* ---------- Attempts Badge ---------- */
.attempts-badge {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    margin-top: 16px; padding: 8px 16px; font-size: 13px; font-weight: 500;
    color: var(--text-secondary); background: var(--bg-input);
    border-radius: var(--radius-full); border: 1px solid var(--border-color);
}
.attempts-badge__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success-icon); }
.attempts-badge__dot.warning { background: #f59e0b; }
.attempts-badge__dot.danger { background: #ef4444; }

/* ---------- Result Container ---------- */
.result-container { margin-top: 28px; animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   VIDEO GRID & CARDS
   ============================================ */

.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.video-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}
.video-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.video-card__thumbnail {
    position: relative;
    width: 100%;
    padding-top: 125%; /* 4:5 Aspect Ratio for IG */
    background: #000;
}
.video-card__thumbnail img {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    object-fit: cover;
}
.video-card__play {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 48px; height: 48px;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; backdrop-filter: blur(4px);
}
.video-card__play svg { width: 24px; height: 24px; fill: currentColor; }

.video-card__content {
    padding: 16px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}
.video-card__caption {
    font-size: 13px;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 12px;
    line-height: 1.4;
}

.video-card__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}
.video-card__stat {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-download {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; margin-top: 12px; padding: 10px;
    background: var(--text-primary); color: #fff;
    border-radius: var(--radius-md); text-decoration: none;
    font-size: 13px; font-weight: 600; transition: var(--transition);
}
.btn-download:hover {
    background: #1f2937;
}

/* ---------- Error / Warning Messages ---------- */
.result-error {
    display: flex; align-items: center; gap: 14px;
    padding: 20px 24px; background: var(--error-bg);
    border: 1px solid var(--error-border); border-radius: var(--radius-md);
}
.result-error__icon {
    display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; min-width: 44px; border-radius: 50%;
    background: #ef4444; color: #fff; font-size: 20px;
}
.result-error__text h3 { font-size: 16px; font-weight: 700; color: var(--error-text); margin-bottom: 2px; }
.result-error__text p { font-size: 13px; color: #b91c1c; }

/* ---------- Limit Reached ---------- */
.limit-overlay {
    margin-top: 24px; padding: 28px 24px;
    background: var(--warning-bg); border: 1px solid var(--warning-border);
    border-radius: var(--radius-md); text-align: center;
}
.limit-overlay__icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 56px; height: 56px; border-radius: 50%;
    background: #f59e0b; color: #fff; font-size: 28px; margin-bottom: 14px;
}
.limit-overlay h3 { font-size: 17px; font-weight: 700; color: var(--warning-text); margin-bottom: 6px; }
.limit-overlay p { font-size: 14px; color: #b45309; line-height: 1.5; }

/* ---------- Analyzing State ---------- */
.analyzing-state {
    margin-top: 24px; padding: 32px 24px; text-align: center;
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-lg); animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.analyzing-state__dots {
    display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 16px;
}
.analyzing-state__dots span {
    width: 10px; height: 10px; border-radius: 50%;
    background: linear-gradient(135deg, #833ab4, #fd1d1d);
    animation: dot-bounce 1.4s ease-in-out infinite;
}
.analyzing-state__dots span:nth-child(2) { animation-delay: 0.2s; }
.analyzing-state__dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}
.analyzing-state__title { font-size: 16px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.analyzing-state__sub { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

/* ---------- Footer ---------- */
.tool-footer { text-align: center; margin-top: 40px; padding: 24px; }
.tool-footer p { font-size: 12px; color: var(--text-muted); margin-top: 16px; }
.tool-footer a { color: var(--text-secondary); text-decoration: none; font-weight: 600; transition: var(--transition); }
.tool-footer a:hover { color: var(--text-primary); }

/* ---------- CTA Carousel ---------- */
.cta-carousel {
    width: 100%; overflow: hidden; position: relative;
    padding: 10px 0; margin-top: 20px;
}
.cta-carousel::before, .cta-carousel::after {
    content: ""; position: absolute; top: 0; width: 100px; height: 100%; z-index: 2;
    pointer-events: none;
}
.cta-carousel::before { left: 0; background: linear-gradient(to right, var(--bg-body), transparent); }
.cta-carousel::after { right: 0; background: linear-gradient(to left, var(--bg-body), transparent); }

.cta-track {
    display: flex; gap: 20px; width: max-content;
    animation: scroll 60s linear infinite;
}
.cta-track:hover { animation-play-state: paused; }

.cta-card {
    flex: 0 0 280px; background: var(--bg-card);
    padding: 24px; border-radius: var(--radius-xl);
    border: 1px solid var(--border-color); box-shadow: var(--shadow-md);
    text-decoration: none; transition: var(--transition);
    display: flex; flex-direction: column; align-items: center; text-align: center;
}
.cta-card:hover { transform: translateY(-5px); border-color: var(--accent-purple); box-shadow: var(--shadow-lg); }
.cta-card__icon { font-size: 32px; margin-bottom: 12px; }
.cta-card__title { font-size: 15px; font-weight: 800; color: var(--text-primary); margin-bottom: 8px; line-height: 1.3; }
.cta-card__btn {
    font-size: 12px; font-weight: 700; color: #fff;
    background: linear-gradient(135deg, #f472b6, #be185d, #831843);
    padding: 8px 18px; border-radius: var(--radius-full);
    margin-top: auto; box-shadow: 0 4px 12px rgba(131, 58, 180, 0.2);
}

@keyframes scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(calc(-300px * 4)); }
}

@media (max-width: 480px) {
    .tool-header__title { font-size: 22px; }
    .video-grid { grid-template-columns: 1fr; }
}

/* ---------- SEO Section ---------- */
.seo-section { max-width: 920px; margin: 0 auto; padding: 80px 24px; font-family: 'Inter', sans-serif; color: var(--text-primary); }
.seo-prose { background: #fff; border: 1px solid #e5e7eb; border-radius: 24px; padding: 48px; box-shadow: var(--shadow-md); margin-bottom: 40px; }
.seo-prose h2 { font-size: 26px; font-weight: 800; color: #111827; margin: 40px 0 20px; letter-spacing: -0.5px; }
.seo-prose h3 { font-size: 19px; font-weight: 700; color: #111827; margin: 32px 0 16px; }
.seo-prose p { font-size: 15px; color: #4b5563; line-height: 1.8; margin-bottom: 20px; }
.seo-prose ul { margin-bottom: 24px; padding-left: 20px; }
.seo-prose li { font-size: 15px; color: #4b5563; line-height: 1.8; margin-bottom: 12px; list-style: none; padding-left: 28px; position: relative; }
.seo-prose li::before { content: ''; position: absolute; left: 0; top: 10px; width: 8px; height: 8px; background: linear-gradient(135deg, #833ab4, #fd1d1d); border-radius: 50%; }

.faq-item { background: #fff; border: 1px solid #e5e7eb; border-radius: 16px; overflow: hidden; margin-bottom: 16px; }
.faq-question { width: 100%; padding: 24px; display: flex; align-items: center; justify-content: space-between; background: none; border: none; cursor: pointer; text-align: left; }
.faq-question span { font-size: 16px; font-weight: 700; color: #111827; }
.faq-chevron { width: 20px; height: 20px; fill: #9ca3af; transition: transform 0.3s ease; }
.faq-item.open .faq-chevron { transform: rotate(180deg); fill: var(--accent-purple); }
.faq-answer { max-height: 0; overflow: hidden; transition: all 0.3s ease; padding: 0 24px; }
.faq-item.open .faq-answer { max-height: 1000px; padding: 0 24px 24px; }
