/* ============================================
   AlwaysViral Tools – Instagram Engagement Calculator
   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: 640px; 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 14px 38px; 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::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; }

/* ---------- reCAPTCHA ---------- */
.recaptcha-container { display: flex; justify-content: center; margin-bottom: 24px; transform-origin: center; }
@media (max-width: 400px) { .recaptcha-container { transform: scale(0.85); margin-bottom: 16px; } }

/* ---------- 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::after {
    content: ''; position: absolute; top: 50%; left: 50%; width: 0; height: 0;
    background: rgba(255,255,255,0.1); border-radius: 50%;
    transform: translate(-50%,-50%); transition: width 0.6s ease, height 0.6s ease;
}
.btn-submit:hover:not(:disabled)::after { width: 300px; height: 300px; }
.btn-submit:hover:not(:disabled) {
    background: #1f2937; transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(17, 24, 39, 0.3);
}
.btn-submit:active:not(:disabled) { transform: translateY(0); box-shadow: none; }
.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); }
}

/* ============================================
   ENGAGEMENT RESULTS DISPLAY
   ============================================ */

/* ---------- Profile Header ---------- */
.eng-profile {
    display: flex; align-items: center; gap: 16px;
    padding: 24px; background: linear-gradient(135deg, #f8f9ff 0%, #f0f4ff 100%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: 1px solid var(--border-color);
}
.eng-profile__avatar {
    width: 72px; height: 72px; border-radius: 50%;
    border: 3px solid #fff; box-shadow: var(--shadow-md);
    object-fit: cover; flex-shrink: 0;
}
.eng-profile__avatar-placeholder {
    width: 72px; height: 72px; border-radius: 50%;
    background: linear-gradient(135deg, #833ab4, #fd1d1d);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 28px; font-weight: 800;
    border: 3px solid #fff; box-shadow: var(--shadow-md); flex-shrink: 0;
}
.eng-profile__info { flex: 1; min-width: 0; }
.eng-profile__username {
    font-size: 18px; font-weight: 700; color: var(--text-primary);
}
.eng-profile__username a { color: inherit; text-decoration: none; }
.eng-profile__username a:hover { color: var(--accent-purple); }
.eng-profile__meta {
    display: flex; gap: 12px; margin-top: 4px; flex-wrap: wrap;
}
.eng-profile__tag {
    font-size: 12px; font-weight: 600; padding: 3px 10px;
    border-radius: var(--radius-full); background: rgba(131,58,180,0.08);
    color: var(--accent-purple); border: 1px solid rgba(131,58,180,0.15);
}

/* ---------- Engagement Hero ---------- */
.eng-hero {
    text-align: center; padding: 32px 24px;
    border-bottom: 1px solid var(--border-color);
}
.eng-hero__gauge {
    position: relative; width: 160px; height: 160px;
    margin: 0 auto 16px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.eng-hero__gauge-ring {
    position: absolute; inset: 0; border-radius: 50%;
    background: conic-gradient(var(--gauge-color, #10b981) 0 calc(var(--gauge-pct, 0) * 3.6deg), #e5e7eb calc(var(--gauge-pct, 0) * 3.6deg) 360deg);
}
.eng-hero__gauge-inner {
    position: relative; width: 126px; height: 126px; border-radius: 50%;
    background: var(--bg-card); display: flex; flex-direction: column;
    align-items: center; justify-content: center; z-index: 1;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.04);
    padding: 8px; overflow: hidden;
}
.eng-hero__rate {
    font-size: 20px; font-weight: 800; letter-spacing: -0.5px;
    line-height: 1; max-width: 110px; text-align: center;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.eng-hero__pct { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-top: 2px; }
.eng-hero__label {
    font-size: 14px; font-weight: 600; margin-top: 8px;
}
.eng-hero__sublabel {
    font-size: 12px; color: var(--text-muted); margin-top: 2px;
}

/* ---------- Engagement CTA ---------- */
.eng-hero__cta {
    margin-top: 16px;
}
.eng-hero__cta .btn-submit {
    background: linear-gradient(135deg, #f472b6, #be185d, #831843);
    background-size: 200% 200%;
    animation: gradient-shift 4s ease infinite;
    border-radius: var(--radius-full);
    font-size: 13px;
    padding: 11px 20px;
    width: auto;
    display: inline-flex;
}
@keyframes gradient-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.eng-hero__cta .btn-submit:hover:not(:disabled) {
    background: linear-gradient(135deg, #6d2e96, #d41717, #e09e35);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(131, 58, 180, 0.4);
}

/* ---------- Quick Stats Row ---------- */
.eng-quick {
    display: grid; grid-template-columns: repeat(3, 1fr);
    border-bottom: 1px solid var(--border-color);
}
.eng-quick__item {
    text-align: center; padding: 16px 8px;
    border-right: 1px solid var(--border-color);
    transition: var(--transition);
}
.eng-quick__item:last-child { border-right: none; }
.eng-quick__item:hover { background: var(--bg-input); }
.eng-quick__value { font-size: 18px; font-weight: 800; color: var(--text-primary); }
.eng-quick__label {
    font-size: 10px; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px;
}

/* ---------- Metric Cards Grid ---------- */
.eng-metrics {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 1px; background: var(--border-color);
    border-bottom: 1px solid var(--border-color);
}
.eng-metric {
    background: var(--bg-card); padding: 18px 16px;
    text-align: center; transition: var(--transition);
}
.eng-metric:hover { background: var(--bg-input); }
.eng-metric__icon { font-size: 20px; margin-bottom: 6px; }
.eng-metric__value { font-size: 17px; font-weight: 800; color: var(--text-primary); }
.eng-metric__label {
    font-size: 10px; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.3px; margin-top: 2px;
}
.eng-metric__hint {
    font-size: 11px; color: var(--text-muted); margin-top: 4px; line-height: 1.3;
}

/* ---------- Content Mix Bar ---------- */
.eng-mix {
    padding: 20px 24px; border-bottom: 1px solid var(--border-color);
}
.eng-mix__title {
    font-size: 11px; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px;
}
.eng-mix__bar {
    display: flex; height: 28px; border-radius: var(--radius-sm);
    overflow: hidden; background: var(--bg-input);
}
.eng-mix__segment {
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: #fff;
    min-width: 2%; transition: width 0.6s ease;
}
.eng-mix__segment--clips { background: linear-gradient(135deg, #833ab4, #c13584); }
.eng-mix__segment--carousel { background: linear-gradient(135deg, #fd1d1d, #e1306c); }
.eng-mix__segment--image { background: linear-gradient(135deg, #fcb045, #f77737); }

.eng-mix__legend {
    display: flex; gap: 16px; margin-top: 10px; flex-wrap: wrap;
}
.eng-mix__legend-item {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--text-secondary); font-weight: 500;
}
.eng-mix__dot {
    width: 8px; height: 8px; border-radius: 50%;
}
.eng-mix__dot--clips { background: #833ab4; }
.eng-mix__dot--carousel { background: #fd1d1d; }
.eng-mix__dot--image { background: #fcb045; }

/* ---------- Most Engaged Post ---------- */
.eng-top-post {
    display: flex; align-items: center; gap: 14px;
    padding: 18px 24px; border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}
.eng-top-post:hover { background: var(--bg-input); }
.eng-top-post__icon {
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    background: linear-gradient(135deg, rgba(131,58,180,0.08), rgba(253,29,29,0.06));
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; flex-shrink: 0;
}
.eng-top-post__info { flex: 1; min-width: 0; }
.eng-top-post__label {
    font-size: 11px; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.3px;
}
.eng-top-post__link {
    font-size: 13px; font-weight: 600; color: var(--accent-purple);
    text-decoration: none; display: block;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.eng-top-post__link:hover { text-decoration: underline; }
.eng-top-post__lift {
    font-size: 13px; font-weight: 700; color: var(--success-text);
    background: var(--success-bg); padding: 4px 10px;
    border-radius: var(--radius-full); border: 1px solid var(--success-border);
    white-space: nowrap;
}

/* ---------- Analysis Period ---------- */
.eng-period {
    padding: 16px 24px; border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 8px;
}
.eng-period__label {
    font-size: 11px; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.3px;
}
.eng-period__value {
    font-size: 13px; font-weight: 600; color: var(--text-secondary);
}

/* ---------- Note ---------- */
.eng-note {
    padding: 16px 24px;
    font-size: 13px; color: var(--text-muted); font-style: italic;
}

/* ---------- Engagement Card Wrapper ---------- */
.eng-card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-lg); overflow: hidden;
    box-shadow: var(--shadow-md);
}

/* ---------- 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 * 8)); } /* Card width + Gap */
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
    .tool-header__title { font-size: 22px; }
    .tool-header__subtitle { font-size: 14px; }
    .eng-metrics { grid-template-columns: repeat(2, 1fr); }
    .eng-profile { flex-direction: column; text-align: center; }
    .eng-profile__meta { justify-content: center; }
    .eng-hero__gauge { width: 130px; height: 130px; }
    .eng-hero__gauge-inner { width: 102px; height: 102px; }
    .eng-hero__rate { font-size: 17px; }
    .eng-quick__value { font-size: 15px; }
    .eng-period { flex-direction: column; text-align: center; }
    .eng-top-post { flex-direction: column; text-align: center; }
}
