/**
 * Instagram Ad Preview Styles
 * Accurate reproduction of Instagram Feed & Story ads 2025-2026
 */

/* =============================================================================
   CSS VARIABLES - Instagram Colors
   ============================================================================= */

:root {
    /* Instagram Colors */
    --ig-bg: #ffffff;
    --ig-text-primary: #262626;
    --ig-text-secondary: #8e8e8e;
    --ig-text-link: #00376b;
    --ig-border: #dbdbdb;
    --ig-blue: #0095f6;
    --ig-like-red: #ed4956;
    --ig-sponsored-color: #737373;
    --ig-cta-bg: #0095f6;
    --ig-cta-text: #ffffff;
    --ig-link-card-bg: #efefef;
    --ig-separator: #efefef;
}

/* =============================================================================
   FEED AD - CONTAINER
   ============================================================================= */

.ig-ad-preview-feed {
    max-width: 468px;
    background: var(--ig-bg);
    border: 1px solid var(--ig-border);
    border-radius: 8px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ig-text-primary);
    overflow: hidden;
}

/* =============================================================================
   FEED AD - HEADER
   ============================================================================= */

.ig-ad-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 10px;
}

.ig-ad-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: linear-gradient(135deg, #405de6, #5851db, #833ab4, #c13584, #e1306c, #fd1d1d, #f56040, #f77737, #fcaf45, #ffdc80);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.ig-ad-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ig-ad-header-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
}

.ig-ad-page-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--ig-text-primary);
    line-height: 18px;
}

.ig-ad-sponsored {
    font-size: 12px;
    color: var(--ig-sponsored-color);
    line-height: 16px;
}

.ig-ad-menu {
    font-size: 16px;
    color: var(--ig-text-primary);
    cursor: pointer;
    letter-spacing: 2px;
    flex-shrink: 0;
}

/* =============================================================================
   FEED AD - IMAGE AREA
   ============================================================================= */

.ig-ad-image {
    width: 100%;
    position: relative;
    background: #f0f0f0;
    overflow: hidden;
}

/* Square format (1:1) */
.ig-ad-image--square {
    aspect-ratio: 1 / 1;
}

/* Fallback for older browsers */
@supports not (aspect-ratio: 1 / 1) {
    .ig-ad-image--square {
        padding-bottom: 100%;
    }
}

/* Portrait format (4:5) */
.ig-ad-image--portrait {
    aspect-ratio: 4 / 5;
}

@supports not (aspect-ratio: 4 / 5) {
    .ig-ad-image--portrait {
        padding-bottom: 125%;
    }
}

/* Landscape format (1.91:1) */
.ig-ad-image--landscape {
    aspect-ratio: 1.91 / 1;
}

@supports not (aspect-ratio: 1.91 / 1) {
    .ig-ad-image--landscape {
        padding-bottom: 52.4%;
    }
}

.ig-ad-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

.ig-ad-image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    color: #aaaaaa;
    font-size: 48px;
}

/* =============================================================================
   FEED AD - ACTION ICONS
   ============================================================================= */

.ig-ad-actions {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
}

.ig-ad-actions-left {
    display: flex;
    gap: 16px;
    align-items: center;
}

.ig-ad-actions-right {
    display: flex;
    align-items: center;
}

.ig-ad-actions svg {
    width: 24px;
    height: 24px;
    color: var(--ig-text-primary);
    cursor: pointer;
}

.ig-ad-actions svg:hover {
    color: var(--ig-text-secondary);
}

/* =============================================================================
   FEED AD - PRIMARY TEXT (CAPTION)
   ============================================================================= */

.ig-ad-primary-text {
    padding: 0 16px 8px;
    font-size: 14px;
    line-height: 18px;
    color: var(--ig-text-primary);
}

.ig-ad-page-name-bold {
    font-weight: 600;
    margin-right: 4px;
}

.ig-ad-caption {
    /* default inline */
}

.ig-ad-more {
    color: var(--ig-text-secondary);
    cursor: pointer;
}

.ig-ad-caption-placeholder {
    color: var(--ig-text-secondary);
    font-style: italic;
}

/* =============================================================================
   FEED AD - LINK CARD
   ============================================================================= */

.ig-ad-link-card {
    margin: 8px 16px 12px;
    background: var(--ig-link-card-bg);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
}

.ig-ad-link-card-text {
    flex: 1;
    min-width: 0;
}

.ig-ad-link-domain {
    font-size: 12px;
    color: var(--ig-text-secondary);
    text-transform: uppercase;
    margin-bottom: 2px;
}

.ig-ad-link-headline {
    font-size: 14px;
    font-weight: 600;
    color: var(--ig-text-primary);
    line-height: 18px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ig-ad-link-description {
    font-size: 12px;
    color: var(--ig-text-secondary);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ig-ad-cta-button {
    background: var(--ig-cta-bg);
    color: var(--ig-cta-text);
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    margin-left: 12px;
    flex-shrink: 0;
    font-family: inherit;
}

/* =============================================================================
   STORY AD - CONTAINER
   ============================================================================= */

.ig-ad-preview-story {
    position: relative;
    width: 360px;
    height: 640px;
    background: #000000;
    border-radius: 12px;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #ffffff;
}

/* =============================================================================
   STORY AD - PROGRESS BARS
   ============================================================================= */

.ig-story-progress {
    display: flex;
    gap: 4px;
    padding: 8px 8px 0;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
}

.ig-story-progress-bar {
    flex: 1;
    height: 2px;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 2px;
}

.ig-story-progress-bar--active {
    background: rgba(255, 255, 255, 0.9);
}

/* =============================================================================
   STORY AD - HEADER (OVERLAY)
   ============================================================================= */

.ig-story-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    position: absolute;
    top: 16px;
    left: 0;
    right: 0;
    z-index: 10;
}

.ig-ad-avatar--story {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
    overflow: hidden;
    flex-shrink: 0;
}

.ig-ad-avatar--story img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ig-story-header-info {
    flex: 1;
    display: flex;
    align-items: center;
    min-width: 0;
}

.ig-story-page-name {
    font-weight: 600;
    font-size: 14px;
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.ig-story-sponsored {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    margin-left: 8px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.ig-story-close {
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

/* =============================================================================
   STORY AD - IMAGE
   ============================================================================= */

.ig-story-image {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.ig-story-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ig-story-image-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.3);
    font-size: 48px;
}

/* =============================================================================
   STORY AD - CTA
   ============================================================================= */

.ig-story-cta {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    text-align: center;
    padding: 16px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.3));
}

.ig-story-cta-arrow {
    color: #ffffff;
    font-size: 14px;
    margin-bottom: 4px;
}

.ig-story-cta-text {
    display: inline-block;
    background: #ffffff;
    color: var(--ig-text-primary);
    padding: 8px 24px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* =============================================================================
   FORM FIELDS
   ============================================================================= */

.ad-form .form-group {
    margin-bottom: 20px;
}

.ad-form .form-label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
    color: var(--color-text, #1a2e1a);
}

.ad-form .form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--ig-border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    color: var(--ig-text-primary);
    background: #fff;
    box-sizing: border-box;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.ad-form .form-input:focus {
    outline: none;
    border-color: var(--ig-blue);
    box-shadow: 0 0 0 3px rgba(0, 149, 246, 0.1);
}

.ad-form textarea.form-input {
    resize: vertical;
    min-height: 72px;
}

.ad-form select.form-input {
    appearance: auto;
    cursor: pointer;
}

.ad-form .form-hint {
    display: block;
    font-size: 12px;
    color: var(--color-text-tertiary, #566a5e);
    margin-top: 4px;
}

.ad-form .input-with-counter {
    position: relative;
}

.ad-form .input-with-counter input,
.ad-form .input-with-counter textarea {
    padding-right: 70px;
}

.ad-form .input-with-counter .char-counter {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: var(--ig-text-secondary);
    pointer-events: none;
}

.ad-form .input-with-counter textarea ~ .char-counter {
    top: auto;
    bottom: 8px;
    transform: none;
}

/* =============================================================================
   PREVIEW AREA - CENTERING & FORMAT LABEL
   ============================================================================= */

#preview-area {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.preview-wrapper {
    overflow: hidden;
}

#preview-format-label {
    display: inline-block;
    background: var(--ig-blue);
    color: #fff;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.preview-format-info {
    text-align: center;
    margin-bottom: 12px;
}

/* =============================================================================
   PHONE FRAME OVERRIDE FOR INSTAGRAM STORY
   ============================================================================= */

.phone-frame .phone-screen {
    padding: 0;
}

/* =============================================================================
   FORMAT CARDS
   ============================================================================= */

.ig-format-cards {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.ig-format-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 80px;
    padding: 10px 14px;
    border: 1px solid var(--ig-border);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.ig-format-card:hover {
    background: #f5f5f5;
    border-color: #bbb;
}

.ig-format-card.active {
    border: 2px solid var(--ig-blue);
    background: rgba(0, 149, 246, 0.05);
    box-shadow: 0 0 0 1px rgba(0, 149, 246, 0.1);
}

.ig-format-card-icon {
    color: var(--ig-text-secondary);
}

.ig-format-card.active .ig-format-card-icon {
    color: var(--ig-blue);
}

.ig-format-card-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--ig-text-primary);
    line-height: 1;
}

.ig-format-card-ratio {
    font-size: 11px;
    color: var(--ig-text-secondary);
    line-height: 1;
}

.ig-format-card.active .ig-format-card-label {
    color: var(--ig-blue);
}

.ig-format-card.active .ig-format-card-ratio {
    color: var(--ig-blue);
}

/* =============================================================================
   IMAGE UPLOAD ZONE
   ============================================================================= */

.ig-upload-zone {
    border: 2px dashed var(--ig-border);
    border-radius: 8px;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color 150ms ease, background 150ms ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.ig-upload-zone:hover,
.ig-upload-zone.drag-over {
    border-color: var(--ig-blue);
    background: rgba(0, 149, 246, 0.03);
}

.ig-upload-text {
    font-size: 14px;
    color: var(--ig-text-primary);
}

.ig-upload-hint {
    font-size: 12px;
    color: var(--ig-text-secondary);
}

.ig-upload-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border: 1px solid var(--ig-border);
    border-radius: 8px;
    margin-top: 8px;
}

.ig-upload-preview img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.ig-upload-preview-name {
    flex: 1;
    font-size: 13px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ig-upload-remove {
    background: none;
    border: none;
    color: var(--ig-like-red);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    padding: 4px 8px;
    font-family: inherit;
    flex-shrink: 0;
    margin-left: auto;
}

.ig-upload-divider {
    text-align: center;
    font-size: 12px;
    color: var(--ig-text-secondary);
    margin: 10px 0;
    position: relative;
}

.ig-upload-divider::before,
.ig-upload-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 30%;
    height: 1px;
    background: var(--ig-border);
}

.ig-upload-divider::before { left: 0; }
.ig-upload-divider::after { right: 0; }

/* Sample images */
.ig-sample-images {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.ig-sample-label {
    font-size: 12px;
    color: var(--ig-text-secondary);
    white-space: nowrap;
}

.ig-sample-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 150ms ease, transform 150ms ease;
}

.ig-sample-thumb:hover {
    border-color: var(--ig-blue);
    transform: scale(1.05);
}

/* =============================================================================
   LIKES
   ============================================================================= */

.ig-ad-likes {
    padding: 0 16px 4px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ig-text-primary);
}

/* =============================================================================
   CAROUSEL PREVIEW
   ============================================================================= */

/* --- Carousel preview --- */

.ig-carousel-container {
    position: relative;
}

.ig-carousel-track {
    display: flex;
    overflow: hidden;
}

.ig-carousel-card {
    flex: 0 0 100%;
    transition: transform 0.3s ease;
}

.ig-carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--ig-text-primary);
    z-index: 5;
    padding: 0;
    line-height: 1;
}

.ig-carousel-arrow:hover {
    background: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.ig-carousel-arrow--left {
    left: 8px;
}

.ig-carousel-arrow--right {
    right: 8px;
}

.ig-carousel-arrow[disabled] {
    opacity: 0;
    pointer-events: none;
}

.ig-carousel-dots {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 8px 0;
}

.ig-carousel-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ig-border);
    transition: background 0.2s ease;
    cursor: pointer;
    border: none;
    padding: 0;
}

.ig-carousel-dot--active {
    background: var(--ig-blue);
}

/* --- Carousel form cards --- */

.ig-carousel-card-item {
    border: 1px solid var(--ig-border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ig-carousel-card-item img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.ig-carousel-card-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #aaa;
    font-size: 20px;
    cursor: pointer;
}

.ig-carousel-card-info {
    flex: 1;
    font-size: 13px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ig-carousel-card-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.ig-carousel-card-actions button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    padding: 2px 6px;
}

.ig-carousel-card-upload-btn {
    color: var(--ig-blue);
}

.ig-carousel-card-remove-btn {
    color: var(--ig-like-red);
}

.ig-carousel-add-card {
    width: 100%;
    margin-top: 4px;
}

/* =============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================= */

@media (max-width: 768px) {
    .ig-ad-preview-feed {
        max-width: 100%;
    }

    .ig-format-cards {
        width: 100%;
    }

    .ig-format-card {
        flex: 1;
        min-width: 0;
    }
}

@media (max-width: 400px) {
    .ig-ad-preview-story {
        width: 100%;
        height: auto;
        aspect-ratio: 9 / 16;
    }

    @supports not (aspect-ratio: 9 / 16) {
        .ig-ad-preview-story {
            height: 0;
            padding-bottom: 177.78%;
        }
    }

    .ig-ad-link-card {
        flex-direction: column;
        align-items: stretch;
    }

    .ig-ad-cta-button {
        margin-left: 0;
        margin-top: 8px;
        text-align: center;
    }
}
