/* Instagram Biolink — visual fiel ao app */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ===== Tema claro ===== */
.ig-light {
    --ig-bg: #ffffff;
    --ig-bg-secondary: #fafafa;
    --ig-text: #262626;
    --ig-text-secondary: #737373;
    --ig-border: #dbdbdb;
    --ig-btn-secondary-bg: #efefef;
    --ig-btn-secondary-text: #262626;
    --ig-tab-active: #262626;
    --ig-tab-inactive: #8e8e8e;
    --ig-overlay: rgba(0,0,0,0.3);
    --ig-modal-bg: #ffffff;
}

.ig-dark {
    --ig-bg: #000000;
    --ig-bg-secondary: #121212;
    --ig-text: #f5f5f5;
    --ig-text-secondary: #a8a8a8;
    --ig-border: #262626;
    --ig-btn-secondary-bg: #363636;
    --ig-btn-secondary-text: #f5f5f5;
    --ig-tab-active: #f5f5f5;
    --ig-tab-inactive: #737373;
    --ig-overlay: rgba(255,255,255,0.15);
    --ig-modal-bg: #121212;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    background: var(--ig-bg);
}

body.ig-dark, body.ig-light {
    background: var(--ig-bg);
}

.ig-app {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--ig-bg);
    color: var(--ig-text);
    min-height: 100vh;
    width: 100%;
    max-width: 430px;
    margin: 0 auto;
    position: relative;
    overflow-x: hidden;
}

/* Top bar */
.ig-topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--ig-bg);
    border-bottom: 1px solid var(--ig-border);
}

.ig-topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 44px;
    padding: 0 8px;
}

.ig-topbar-username {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.ig-topbar-btn {
    background: none;
    border: none;
    color: var(--ig-text);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.ig-topbar-back { visibility: hidden; }

/* Profile */
.ig-main { padding-bottom: 24px; }

.ig-profile {
    padding: 12px 16px 0;
    overflow: hidden;
}

.ig-profile-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    width: 100%;
    min-width: 0;
}

.ig-avatar-col { flex-shrink: 0; }

/* Story ring — gradiente Instagram */
.ig-story-ring {
    background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    border: none;
    border-radius: 50%;
    padding: 3px;
    cursor: pointer;
    display: block;
    line-height: 0;
}

.ig-story-ring-inner {
    display: block;
    background: var(--ig-bg);
    border-radius: 50%;
    padding: 3px;
}

.ig-story-ring img,
.ig-avatar-plain img {
    width: 77px;
    height: 77px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.ig-avatar-plain img { width: 86px; height: 86px; }

.ig-avatar-ph {
    width: 77px;
    height: 77px;
    border-radius: 50%;
    background: linear-gradient(45deg, #405de6, #5851db, #833ab4, #c13584, #e1306c, #fd1d1d);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 28px;
    font-weight: 600;
}

.ig-avatar-plain .ig-avatar-ph { width: 86px; height: 86px; }

/* Stats */
.ig-stats {
    list-style: none;
    display: flex;
    flex: 1;
    min-width: 0;
    justify-content: space-between;
    gap: 2px;
    padding: 0;
    margin: 0;
}

.ig-stats li {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 0;
    text-align: center;
}

.ig-stats strong {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ig-stats span {
    font-size: 11px;
    color: var(--ig-text-secondary);
    line-height: 1.2;
    white-space: nowrap;
}

/* Meta */
.ig-profile-meta { margin-bottom: 12px; }

.ig-display-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.ig-bio {
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
}

.ig-bio-link {
    font-size: 14px;
    font-weight: 600;
    color: #00376b;
    text-decoration: none;
    display: block;
    margin-top: 4px;
}

.ig-dark .ig-bio-link { color: #e0f1ff; }

/* Action buttons */
.ig-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.ig-btn {
    flex: 1;
    height: 32px;
    border: none;
    border-radius: var(--ig-btn-radius, 8px);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-family: inherit;
    transition: opacity 0.15s;
}

.ig-btn:active { opacity: 0.7; }

.ig-btn-primary {
    background: var(--ig-btn-primary, #0095f6);
    color: var(--ig-btn-text, #fff);
}

.ig-btn-secondary {
    background: var(--ig-btn-secondary-bg);
    color: var(--ig-btn-secondary-text);
}

.ig-btn-icon { flex: 0 0 32px; padding: 0; }

.ig-btn.following {
    background: var(--ig-btn-secondary-bg);
    color: var(--ig-text-secondary);
}

/* Highlights */
.ig-highlights {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding: 8px 0 12px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.ig-highlights::-webkit-scrollbar { display: none; }

.ig-highlight {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 64px;
    padding: 0;
    color: var(--ig-text);
    font-family: inherit;
}

.ig-highlight-ring {
    display: block;
    padding: 2px;
    border-radius: 50%;
    border: 1px solid var(--ig-border);
}

.ig-highlight.active .ig-highlight-ring {
    border: 2px solid var(--ig-text);
}

.ig-highlight-inner {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--ig-bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    color: var(--ig-text-secondary);
    overflow: hidden;
}

.ig-highlight-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ig-highlight-label {
    font-size: 12px;
    max-width: 64px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Tabs */
.ig-tabs {
    display: flex;
    border-top: 1px solid var(--ig-border);
    border-bottom: 1px solid var(--ig-border);
}

.ig-tab {
    flex: 1;
    height: 44px;
    background: none;
    border: none;
    border-bottom: 1px solid transparent;
    color: var(--ig-tab-inactive);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: -1px;
    padding: 0;
}

.ig-tab.active {
    color: var(--ig-tab-active);
    border-bottom-color: var(--ig-tab-active);
}

.ig-tab svg { width: 24px; height: 24px; }

/* Posts grid — 3 colunas estilo Instagram */
.ig-posts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
}

.ig-post-item {
    position: relative;
    aspect-ratio: 1;
    border: none;
    padding: 0;
    cursor: pointer;
    background: var(--ig-bg-secondary);
    overflow: hidden;
    display: block;
    width: 100%;
}

.ig-post-item img,
.ig-post-item .profile-grid-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.15s;
    pointer-events: none;
}

.ig-post-item:hover img { transform: scale(1.03); }

.ig-post-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ig-text-secondary);
    background: var(--ig-bg-secondary);
}

.ig-post-overlay {
    position: absolute;
    inset: 0;
    background: var(--ig-overlay);
    opacity: 0;
    transition: opacity 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.ig-post-item:hover .ig-post-overlay { opacity: 1; }

.ig-post-badge { font-size: 20px; color: #fff; }

.ig-post-item.hidden { display: none; }

.ig-reels-grid[hidden],
.ig-posts-grid[hidden] { display: none !important; }

.ig-reel-play {
    opacity: 1 !important;
    font-size: 24px;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

.ig-reel-placeholder {
    font-size: 28px;
    color: var(--ig-text-secondary);
}

.ig-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px 16px;
    color: var(--ig-text-secondary);
    font-size: 14px;
}

.ig-brand {
    text-align: center;
    padding: 16px;
    font-size: 11px;
}

.ig-brand a { color: var(--ig-text-secondary); text-decoration: none; }

/* ===== Story viewer ===== */
.ig-story-viewer {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
}

.ig-story-viewer[hidden] { display: none !important; }

.ig-story-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    padding: 12px 12px 0;
    max-width: 430px;
    margin: 0 auto;
}

.ig-story-progress {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}

.ig-story-progress-bar {
    flex: 1;
    height: 2px;
    background: rgba(255,255,255,0.35);
    border-radius: 2px;
    overflow: hidden;
}

.ig-story-progress-fill {
    height: 100%;
    background: #fff;
    width: 0%;
    transition: width linear;
}

.ig-story-progress-fill.done { width: 100%; }

.ig-story-user {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
}

.ig-story-user img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.ig-story-close {
    margin-left: auto;
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

.ig-story-content {
    flex: 1;
    width: 100%;
    max-width: 430px;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 52px 12px 40px;
    box-sizing: border-box;
}

.ig-story-content img,
.ig-story-content video {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
}

.ig-story-caption {
    position: absolute;
    bottom: 80px;
    left: 16px;
    right: 16px;
    color: #fff;
    font-size: 16px;
    text-align: center;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

.ig-story-link-btn {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    color: #000;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
}

.ig-story-nav {
    position: absolute;
    top: 60px;
    bottom: 0;
    width: 35%;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 5;
}

.ig-story-prev { left: 0; }
.ig-story-next { right: 0; }

/* ===== Post modal ===== */
.ig-modal {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.ig-modal[hidden] { display: none !important; }

.ig-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.65);
}

.ig-modal-sheet {
    position: relative;
    background: var(--ig-modal-bg);
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-width: 430px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.25s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.ig-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 28px;
    color: var(--ig-text);
    cursor: pointer;
    z-index: 2;
    line-height: 1;
}

.ig-modal-image-wrap {
    width: 100%;
    aspect-ratio: 1;
    background: var(--ig-bg-secondary);
}

.ig-modal-image-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ig-modal-body {
    padding: 20px 16px 32px;
}

.ig-modal-body h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.ig-modal-body p {
    font-size: 14px;
    color: var(--ig-text-secondary);
    line-height: 1.5;
    margin-bottom: 16px;
}

.ig-modal-cta {
    display: block;
    text-align: center;
    width: 100%;
    height: 44px;
    line-height: 44px;
    padding: 0;
}

@media (min-width: 768px) {
    .ig-profile-row { gap: 20px; }
    .ig-story-ring img, .ig-avatar-plain img { width: 116px; height: 116px; }
    .ig-avatar-ph { width: 116px; height: 116px; font-size: 40px; }
    .ig-avatar-plain .ig-avatar-ph { width: 116px; height: 116px; }
    .ig-stats strong { font-size: 16px; }
    .ig-stats span { font-size: 12px; }
}
