/* =============================================================
   Insta Video Downloader — Responsive Styles
   ============================================================= */

/* ── Reset & Base ───────────────────────────────────────────── */
.imd-wrap *,
.imd-wrap *::before,
.imd-wrap *::after {
    box-sizing: border-box;
}

[hidden],
.imd-wrap [hidden] {
    display: none !important;
}

/* ── CSS Variables ──────────────────────────────────────────── */
.imd-wrap {
    --imd-green:      #16a34a;
    --imd-green-dark: #15803d;
    --imd-green-light:#22c55e;
    --imd-gradient:   linear-gradient(100deg, #8B3AE5, #F3175F 55%, #F59300);
    --imd-card:       #ffffff;
    --imd-border:     rgba(15,23,42,.08);
    --imd-text:       #0f172a;
    --imd-muted:      #64748b;
    --imd-radius:     18px;
    --imd-shadow:     0 12px 32px -8px rgba(15,23,42,.14), 0 2px 6px rgba(15,23,42,.06);

    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', system-ui, sans-serif;
    color:       var(--imd-text);
    width:       100%;
    max-width:   640px;
    margin:      0 auto;
    padding:     24px 16px 48px;
}

/* ── Card ───────────────────────────────────────────────────── */
.imd-card {
    background:    var(--imd-card);
    border:        1px solid var(--imd-border);
    border-radius: var(--imd-radius);
    box-shadow:    var(--imd-shadow);
    padding:       28px 26px;
    margin-bottom: 20px;
    width:         100%;
    animation:     imd-fade-up .35s ease both;
}

@keyframes imd-fade-up {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

#imd-wrap p {
    margin: 0 !important;
}

.imd-label {
    display:       block;
    font-size:     .8rem;
    font-weight:   800;
    color:         var(--imd-text);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 12px;
}

/* ── Input Row ──────────────────────────────────────────────── */
.imd-input-row {
    display:      flex;
    gap:          8px;
    align-items:  stretch;
    margin-bottom: 14px;
}

.imd-url-input {
    flex:          1 1 auto;
    min-width:     0;
    background:    #f8fafc;
    border:        2px solid rgba(15,23,42,.10);
    border-radius: 12px;
    color:         var(--imd-text);
    font-size:     1.05rem;
    font-weight:   500;
    padding:       16px 18px;
    outline:       none;
    transition:    border-color .2s, box-shadow .2s, background .2s;
    width:         100%;
}
.imd-url-input::placeholder { color: var(--imd-muted); opacity: .7; }
.imd-url-input:focus {
    border-color: var(--imd-green);
    box-shadow:   0 0 0 4px rgba(22,163,74,.14);
    background:   #fff;
}

/* ── Buttons ────────────────────────────────────────────────── */
.imd-btn {
    display:         inline-flex;
    align-items:     center;
    justify-content: center;
    font-size:       1.05rem;
    font-weight:     800;
    padding:         17px 24px;
    border-radius:   12px;
    border:          none;
    cursor:          pointer;
    text-decoration: none;
    white-space:     nowrap;
    transition:      background .18s, transform .16s cubic-bezier(.34,1.56,.64,1), box-shadow .18s, opacity .18s;
    line-height:     1;
}

.imd-btn-icon { width: 19px; height: 19px; flex-shrink: 0; }

.imd-btn-block { display: flex; width: 100%; }

.imd-btn-primary {
    background: var(--imd-gradient) !important;
    color:      #fff;
    box-shadow: none !important;
    letter-spacing: .01em;
    padding: 12px !important;
    border-radius: 50px !important;
    border: none !important;
}
.imd-btn-primary:hover  { transform: translateY(-2px) scale(1.01); }
.imd-btn-primary:active { transform: scale(.98); }
.imd-btn-primary:disabled { opacity: .6; cursor: not-allowed; transform: none; box-shadow: none; }

.imd-btn-success {
    background: var(--imd-gradient) !important;
    color:      #fff !important;
    box-shadow: 0 10px 24px -4px rgba(22,163,74,.45), 0 2px 6px rgba(22,163,74,.25);
}
.imd-btn-success:hover  { transform: translateY(-2px) scale(1.01); box-shadow: 0 14px 30px -4px rgba(22,163,74,.5), 0 2px 8px rgba(22,163,74,.3); color: #fff !important; }
.imd-btn-success:active { transform: scale(.98); }
.imd-btn-success.imd-btn-downloading {
    pointer-events: none;
    opacity:        .85;
}
.imd-btn-success.imd-btn-downloading .imd-btn-icon {
    animation: imd-bounce-down .6s ease infinite;
}
@keyframes imd-bounce-down {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(3px); }
}

.imd-btn:focus-visible {
    outline:        2px solid var(--imd-green-dark);
    outline-offset: 2px;
}

.imd-btn-ghost {
    background: var(--imd-gradient) !important;
    color:      #fff;
    box-shadow: none !important;
    letter-spacing: .01em;
    padding: 12px 20px !important;
    border-radius: 50px !important;
    border: none !important;

}
.imd-btn-ghost:hover { transform: translateY(-2px) scale(1.01); }

.imd-btn-link {
    background:    none;
    color:         var(--imd-green-dark);
    padding:       8px;
    font-weight:   600;
    font-size:     .92rem;
    width:         100%;
}
.imd-btn-link:hover { text-decoration: underline; }

/* ── Error Message ──────────────────────────────────────────── */
.imd-error-msg {
    margin-top:    12px;
    font-size:     .9rem;
    color:         #dc2626;
    background:    rgba(220,38,38,.06);
    border:        1px solid rgba(220,38,38,.20);
    border-radius: 8px;
    padding:       10px 14px;
    width:         100%;
}

.imd-hint {
    margin:      12px 0 0;
    font-size:   .82rem;
    color:       var(--imd-muted);
    text-align:  center;
}

/* ── Loading ────────────────────────────────────────────────── */
.imd-loading {
    display:        flex;
    align-items:    center;
    gap:            12px;
    padding:        26px 4px;
    font-size:      1rem;
    font-weight:    600;
    color:          var(--imd-text);
    flex-direction: column;
}

.imd-spinner {
    width:            30px;
    height:           30px;
    min-width:        30px;
    border:           3px solid #e5e7eb;
    border-top-color: var(--imd-green);
    border-radius:    50%;
    animation:        imd-spin .7s linear infinite;
}

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

.imd-progress {
    width:         100%;
    max-width:     260px;
    height:        4px;
    background:    #e5e7eb;
    border-radius: 999px;
    overflow:      hidden;
    margin-top:    4px;
}
.imd-progress-bar {
    display:       block;
    height:        100%;
    width:         30%;
    background:    var(--imd-green);
    border-radius: 999px;
    animation:     imd-progress-slide 1.4s ease-in-out infinite;
}
@keyframes imd-progress-slide {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(360%); }
}

/* ── Result Card ────────────────────────────────────────────── */
.imd-result-inner {
    display:        flex;
    flex-direction: column;
    gap:            14px;
    align-items:    stretch;
}

.imd-ready-text {
    display:      flex;
    align-items:  center;
    justify-content: center;
    gap:          8px;
    font-size:   1.1rem;
    font-weight: 700;
    color:       var(--imd-green-dark);
    margin:      0;
    text-align:  center;
}

.imd-check-icon {
    width:           22px;
    height:          22px;
    flex-shrink:     0;
    background:      rgba(22,163,74,.12);
    border-radius:   50%;
    padding:         3px;
    animation:       imd-pop .3s ease .1s both;
}
@keyframes imd-pop {
    from { transform: scale(0); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

.imd-video-frame {
    border-radius: 10px;
    overflow:      hidden;
    background:    #000;
}

#imd-video-player {
    width:         100%;
    max-height:    480px;
    display:       block;
}

.imd-result-meta {
    margin:      0;
    font-size:   .85rem;
    color:       var(--imd-muted);
    text-align:  center;
}

/* ── How-to Steps ───────────────────────────────────────────── */
.imd-steps {
    display:               grid;
    grid-template-columns: repeat(3, 1fr);
    gap:                   14px;
    margin-bottom:         24px;
    width:                 100%;
}

.imd-step {
    background:    var(--imd-card);
    border:        1px solid var(--imd-border);
    border-radius: var(--imd-radius);
    padding:       22px 16px;
    text-align:    center;
    box-shadow:    0 4px 14px rgba(15,23,42,.05);
    transition:    border-color .2s, transform .2s, box-shadow .2s;
}
.imd-step:hover {
    border-color: rgba(22,163,74,.30);
    transform:    translateY(-4px);
    box-shadow:   0 14px 28px -6px rgba(15,23,42,.14);
}

.imd-step-icon {
    width:           38px;
    height:          38px;
    background:      var(--imd-gradient) !important;
    color:           #fff;
    border-radius:   50%;
    display:         flex;
    align-items:     center;
    justify-content: center;
    margin:          0 auto 14px;
    font-weight:     800;
    font-size:       1rem;
    box-shadow:      0 6px 14px -3px rgba(22,163,74,.4);
}

.imd-step h3 {
    font-size:   .9rem;
    font-weight: 800;
    margin:      0 0 6px;
    color:       var(--imd-text);
}
.imd-step p {
    font-size:   .82rem;
    color:       var(--imd-muted);
    margin:      0;
    line-height: 1.5;
}

/* ── Tablet (max 640px) ─────────────────────────────────────── */
@media (max-width: 640px) {

    .imd-wrap {
        padding: 16px 12px 40px;
    }

    .imd-hero-title { font-size: 1.5rem; }
    .imd-hero-subtitle { font-size: .95rem; }
    .imd-badge { font-size: .76rem; padding: 6px 11px; }

    .imd-input-row {
        flex-wrap: nowrap;
    }
    .imd-btn-ghost span { display: none; }
    .imd-btn-ghost { padding: 0 14px; }

    .imd-btn-primary {
        padding: 15px;
        font-size: 1.05rem;
    }

    .imd-steps {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .imd-step {
        display:        flex;
        align-items:    center;
        gap:            14px;
        text-align:     left;
        padding:        16px;
        flex-direction: column;
    }
    .imd-step-icon { margin: 0; flex-shrink: 0; }
    .imd-step h3   { margin-bottom: 3px; }

    .imd-card {
        padding: 20px 18px;
    }
}

/* ── Toast ──────────────────────────────────────────────────── */
.imd-toast {
    position:        fixed;
    left:            50%;
    bottom:          24px;
    transform:       translateX(-50%) translateY(20px);
    background:      var(--imd-text);
    color:           #fff;
    font-size:       .9rem;
    font-weight:     600;
    padding:         12px 20px;
    border-radius:   999px;
    box-shadow:      0 8px 24px rgba(0,0,0,.2);
    opacity:         0;
    pointer-events:  none;
    transition:      opacity .25s ease, transform .25s ease;
    z-index:         9999;
    max-width:       90vw;
    text-align:      center;
}
.imd-toast.imd-toast-show {
    opacity:   1;
    transform: translateX(-50%) translateY(0);
}

/* ── Reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .imd-card, .imd-check-icon, .imd-step, .imd-btn { animation: none !important; transition: none !important; }
}

/* ── Very small phones (max 380px) ─────────────────────────── */
@media (max-width: 380px) {
    .imd-wrap {
        padding: 12px 10px 32px;
    }
    .imd-url-input {
        font-size: .95rem;
        padding:   12px 14px;
    }
}
