/**
 * Instagram Integration Styles
 * Mobile-first design para integração do Instagram Scraper
 */

/* ===== SUGGESTIONS DROPDOWN ===== */
[data-instagram-suggestions] {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 99999 !important;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    border: 1px solid #e5e7eb;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 4px;
    pointer-events: auto !important;
}

.instagram-suggestions-list {
    padding: 8px;
}

.instagram-suggestion-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer !important;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    pointer-events: auto !important;
    position: relative;
    z-index: 1;
}

.instagram-suggestion-item:hover {
    background: #f9fafb;
    border-color: #e5e7eb;
}

.instagram-suggestion-item:active {
    transform: scale(0.98);
}

.suggestion-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: #f3f4f6;
}

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

.suggestion-info {
    flex: 1;
    min-width: 0;
}

.suggestion-username {
    font-weight: 600;
    color: #1f2937;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.suggestion-fullname {
    color: #6b7280;
    font-size: 12px;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== LOADING STATES ===== */
.instagram-suggestions-loading,
.instagram-preview-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    color: #6b7280;
    font-size: 14px;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid #e5e7eb;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

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

/* Garantir que o spinner sempre gire */
.instagram-suggestions-loading .loading-spinner,
.instagram-preview-loading .loading-spinner {
    animation: spin 0.8s linear infinite !important;
    will-change: transform;
}

/* Skeleton Loading com Shimmer */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

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

.skeleton-suggestions {
    padding: 8px;
}

.skeleton-suggestion-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    margin-bottom: 8px;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-text {
    height: 14px;
    flex: 1;
}

.skeleton-text-short {
    height: 12px;
    width: 60%;
    margin-top: 4px;
}

.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 16px;
}

.skeleton-post-item {
    aspect-ratio: 1;
}

/* ===== ERROR STATES ===== */
.instagram-suggestions-error,
.instagram-preview-error {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px;
    color: #d97706;
    font-size: 14px;
    background: #fef3c7;
    border-radius: 8px;
    margin: 8px;
}

/* ===== PREVIEW CONTAINER ===== */
[data-instagram-preview] {
    margin-top: 12px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    background: white;
}

/* ===== PROFILE PREVIEW ===== */
.instagram-profile-preview {
    padding: 16px;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e5e7eb;
}

.profile-info {
    flex: 1;
}

.profile-username {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 8px 0;
}

.profile-stats {
    display: flex;
    gap: 16px;
}

.stat-item {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
}

.stat-label {
    display: block;
    font-size: 11px;
    color: #6b7280;
    margin-top: 2px;
}

/* ===== POSTS PREVIEW ===== */
.instagram-posts-preview,
.instagram-reels-preview {
    padding: 16px;
}

.preview-title {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 12px 0;
}

.posts-grid,
.reels-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.post-item,
.reel-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.post-item:hover,
.reel-item:hover {
    transform: scale(1.02);
    border-color: #3b82f6;
}

.post-item.selected,
.reel-item.selected,
.extra-post-item.selected,
.extra-reel-item.selected {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3);
    transform: scale(1.05);
}

.post-item.selected::after,
.reel-item.selected::after,
.extra-post-item.selected::after,
.extra-reel-item.selected::after {
    content: "";
    position: absolute;
    top: 8px;
    right: 8px;
    background: #10b981;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    z-index: 10;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/></svg>');
    background-size: 16px 16px;
    background-position: center;
    background-repeat: no-repeat;
}

.post-image,
.reel-image {
    width: 100%;
    height: 100%;
    position: relative;
    background: #f3f4f6;
}

.post-image img,
.reel-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.post-overlay,
.reel-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    padding: 8px;
    color: white;
    font-size: 10px;
}

.post-stats {
    display: flex;
    gap: 8px;
    align-items: center;
}

.reel-overlay {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.play-icon {
    font-size: 12px;
}

/* ===== BOTÃO VER MAIS ===== */
.instagram-view-more {
    text-align: center;
    padding: 4px 12px 0 12px;
}

.instagram-view-more-btn {
    display: inline-block;
    padding: 6px 12px;
    color: #6b7280;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 6px;
}

.instagram-view-more-btn:hover {
    color: #1f2937;
    background: #f3f4f6;
}

.instagram-view-more-btn:active {
    transform: scale(0.95);
}

/* ===== PRIVATE PROFILE WARNING ===== */
.instagram-private-warning {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
}

.warning-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #f59e0b;
    flex-shrink: 0;
}

.warning-content h4 {
    font-size: 14px;
    font-weight: 600;
    color: #92400e;
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.warning-content h4 i {
    font-size: 12px;
}

.warning-content p {
    font-size: 12px;
    color: #92400e;
    margin: 0;
}

/* ===== RESPONSIVE DESIGN ===== */

/* Mobile (default) */
@media (max-width: 640px) {
    .profile-stats {
        gap: 12px;
    }
    
    .stat-number {
        font-size: 13px;
    }
    
    .stat-label {
        font-size: 10px;
    }
    
    .posts-grid,
    .reels-grid {
        gap: 6px;
    }
    
    .post-overlay,
    .reel-overlay {
        padding: 6px;
        font-size: 9px;
    }
}

/* Tablet */
@media (min-width: 641px) and (max-width: 1024px) {
    .profile-avatar {
        width: 70px;
        height: 70px;
    }
    
    .profile-username {
        font-size: 18px;
    }
    
    .posts-grid,
    .reels-grid {
        gap: 10px;
    }
}

/* Desktop */
@media (min-width: 1025px) {
    .instagram-suggestion-item {
        padding: 14px;
    }
    
    .suggestion-avatar {
        width: 44px;
        height: 44px;
    }
    
    .suggestion-username {
        font-size: 15px;
    }
    
    .suggestion-fullname {
        font-size: 13px;
    }
    
    .profile-avatar {
        width: 80px;
        height: 80px;
    }
    
    .profile-username {
        font-size: 20px;
    }
    
    .stat-number {
        font-size: 16px;
    }
    
    .stat-label {
        font-size: 12px;
    }
    
    .posts-grid,
    .reels-grid {
        gap: 12px;
    }
}

/* ===== EXTRAS (STEP 3) ===== */
.extra-instagram-content {
    padding: 12px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.extra-posts-grid,
.extra-reels-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.extra-post-item,
.extra-reel-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 2px solid transparent;
}

.extra-post-item:hover,
.extra-reel-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.extra-post-item.selected,
.extra-reel-item.selected {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.extra-post-item img,
.extra-reel-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.extra-post-overlay,
.extra-reel-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.extra-post-likes,
.extra-reel-views {
    font-size: 10px;
    color: white;
    font-weight: 600;
}

.extra-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 20px;
    opacity: 0.9;
}

.extra-instagram-loading,
.extra-instagram-error {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    background: #f9fafb;
    border-radius: 8px;
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    .instagram-suggestion-item,
    .post-item,
    .reel-item {
        transition: none;
        animation: none;
    }
    
    /* Manter animação do spinner mesmo com prefers-reduced-motion */
    .loading-spinner {
        animation: spin 0.8s linear infinite !important;
    }
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
    [data-instagram-suggestions] {
        background: #1f2937;
        border-color: #374151;
    }
    
    .instagram-suggestion-item {
        color: #f9fafb;
    }
    
    .instagram-suggestion-item:hover {
        background: #374151;
    }
    
    .suggestion-username {
        color: #f9fafb;
    }
    
    .suggestion-fullname {
        color: #9ca3af;
    }
    
    [data-instagram-preview] {
        background: #1f2937;
        border-color: #374151;
    }
    
    .profile-username,
    .preview-title {
        color: #f9fafb;
    }
    
    .stat-number {
        color: #f9fafb;
    }
    
    .stat-label {
        color: #9ca3af;
    }
}

/* ===== UTILITIES ===== */
.hidden {
    display: none !important;
}

.lazy-load {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lazy-load.loaded {
    opacity: 1;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

[data-instagram-suggestions]:not(.hidden) {
    animation: fadeIn 0.2s ease;
}

[data-instagram-preview]:not(.hidden) {
    animation: fadeIn 0.3s ease;
}
