* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: #000;
    color: #fff;
    overflow-x: hidden;
}

/* Container Principal */
.instagram-container {
    max-width: 480px;
    margin: 0 auto;
    background: #000;
    min-height: 100vh;
    position: relative;
    padding-bottom: 60px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #000;
    position: sticky;
    top: 0;
    z-index: 100;
}

.back-btn,
.menu-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
}

.username-header {
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: 16px;
}

/* Profile Section */
.profile-section {
    padding: 16px;
}

.profile-header {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
}

.profile-pic-container {
    cursor: pointer;
    margin-right: 24px;
}

.story-ring {
    width: 86px;
    height: 86px;
    border-radius: 50%;
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    padding: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-pic {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid #000;
    object-fit: cover;
}

.profile-stats {
    flex: 1;
    display: flex;
    justify-content: space-around;
    gap: 15px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-number {
    font-weight: 600;
    font-size: 16px;
}

.stat-label {
    font-size: 13px;
    color: #a8a8a8;
}

.profile-info {
    margin-bottom: 16px;
}

.profile-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.profile-bio {
    font-size: 14px;
    line-height: 1.4;
}

.profile-bio p {
    margin-bottom: 2px;
}

.link {
    color: #e0f1ff;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.btn-primary,
.btn-secondary {
    flex: 1;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

.btn-primary {
    background: #0095f6;
    color: #fff;
    transition: all 0.2s ease;
}

.btn-primary.following {
    background: #262626;
    color: #fff;
}

.btn-primary.following:hover {
    background: #363636;
}

.btn-secondary {
    background: #262626;
    color: #fff;
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    border-top: 1px solid #262626;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    color: #8e8e8e;
    cursor: pointer;
    border-top: 1px solid transparent;
    margin-top: -1px;
}

.tab-btn.active {
    color: #fff;
    border-top-color: #fff;
}

/* Posts Grid */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
}

.post-item {
    aspect-ratio: 1;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.post-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.post-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    max-width: 480px;
    width: 100%;
    background: #000;
    border-top: 1px solid #262626;
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    z-index: 1000;
}

/* Post View Bottom Nav override */
.post-view-container .bottom-nav {
    position: sticky;
    bottom: 0;
    left: 0;
    transform: none;
    margin-top: auto;
    width: 100%;
    margin-top: 200px !important;
}

.nav-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-btn.active svg {
    fill: currentColor;
}

.profile-nav-pic {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    overflow: hidden;
}

.profile-nav-pic img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Post View Container */
.post-view-container {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: 100vh;
    background: #000;
    z-index: 2000;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.post-view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #000;
    position: sticky;
    top: 0;
    z-index: 100;
}

.post-view-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.post-view-title span:first-child {
    font-weight: 600;
    font-size: 16px;
}

.post-view-username {
    font-size: 11px;
    color: #a8a8a8;
}

.follow-btn-header {
    background: none;
    border: none;
    color: #0095f6;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    padding: 8px;
    transition: all 0.2s ease;
}

.follow-btn-header.following {
    color: #fff;
}

/* Post View Content */
.post-view-content {
    background: #000;
}

.post-view-user-info {
    padding: 12px 16px;
}

.post-user-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.post-user-pic {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.post-user-details {
    flex: 1;
}

.post-username {
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
}

.post-music {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #fff;
}

.post-music-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
}

.post-menu-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.post-image-container {
    width: 100%;
    position: relative;
    background: #000;
}

.post-image-container img {
    width: 100%;
    display: block;
}

.post-counter {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
}

.post-sound-btn {
    position: absolute;
    bottom: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Post Actions */
.post-actions {
    display: flex;
    justify-content: space-between;
    padding: 8px 16px;
}

.post-actions-left {
    display: flex;
    gap: 16px;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px;
}

.comment-count {
    font-size: 14px;
    color: #fff;
    font-weight: 400;
}

.post-dots {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 8px 0;
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #363636;
}

.dot.active {
    background: #0095f6;
}

.post-likes {
    padding: 0 16px 8px;
    font-size: 14px;
}

.post-likes strong {
    font-weight: 600;
}

.post-caption {
    padding: 0 16px 8px;
    font-size: 14px;
    white-space: pre-wrap;
    line-height: 1.4;
    display: flex;
    flex-direction: column;
}

.caption-username {
    font-weight: 600;
    margin-right: 6px;
    display: inline-block;
    margin-bottom: 4px;
}

.caption-emoji {
    font-size: 16px;
}

.post-date {
    padding: 0 16px 16px;
    font-size: 11px;
    color: #8e8e8e;
}

/* Story View Container */
.story-view-container {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: 100vh;
    background: #000;
    z-index: 3000;
}

/* Chat View */
.chat-view-container {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: 100vh;
    background: #000;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    border: 1px solid #262626;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #262626;
}

.chat-user {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.chat-user-pic {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-user-details {
    display: flex;
    flex-direction: column;
}

.chat-username {
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
}

.chat-user-handle {
    font-size: 11px;
    color: #a8a8a8;
}

.chat-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-action-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 6px;
}

.chat-action-btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-intro {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 16px;
}

.chat-intro-pic {
    width: 86px;
    height: 86px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 12px;
}

.chat-intro-texts {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.chat-intro-name {
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
}

.chat-intro-meta {
    font-size: 12px;
    color: #a8a8a8;
}

.chat-view-profile-btn {
    background: #262626;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    margin-top: 8px;
    cursor: pointer;
}

.message-list {
    flex: 1;
    padding: 12px 16px 80px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message-item {
    max-width: 70%;
    padding: 8px 12px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
}

.message-item.sent {
    align-self: flex-end;
    background: #1a1a1a;
    color: #fff;
}

.message-item.received {
    align-self: flex-start;
    background: #262626;
    color: #fff;
}

.chat-input-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0,0,0,0.9);
    border-top: 1px solid #262626;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 24px;
    color: #fff;
    font-size: 14px;
}

.chat-icon-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
}

.story-progress-bars {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    gap: 4px;
    padding: 8px 4px;
    z-index: 10;
}

.progress-bar {
    flex: 1;
    height: 2px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 1px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #fff;
    width: 0%;
    transition: width 0.1s linear;
}

.story-header {
    position: absolute;
    top: 16px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    z-index: 10;
}

.story-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.story-user-pic {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #fff;
    object-fit: cover;
}

.story-user-details {
    display: flex;
    flex-direction: column;
}

.story-username {
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: 14px;
}

.story-time {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.story-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.story-sound-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: #fff;
    display: flex;
    align-items: center;
}

.follow-btn-story {
    background: none;
    border: 1px solid #fff;
    color: #fff;
    padding: 6px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.follow-btn-story.following {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.story-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.story-content {
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.story-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.story-image video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.story-text {
    color: #fff;
    padding: 40px;
}

.story-footer {
    position: absolute;
    bottom: 100px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 16px;
    z-index: 10;
}

.story-footer-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: #fff;
    font-size: 24px;
}

.story-repost-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(10px);
}

.story-reply-bar {
    position: absolute;
    bottom: 16px;
    left: 16px;
    right: 16px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 8px;
}

.story-reply-input {
    width: auto;
    flex: 1;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 24px;
    color: #fff;
    font-size: 14px;
    backdrop-filter: blur(10px);
}

.story-reply-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: #fff;
    display: flex;
    align-items: center;
}

.story-reply-icon-btn[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.story-reply-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

/* Responsive - Desktop */
@media (min-width: 768px) {
    body {
        display: flex;
        justify-content: center;
        align-items: center;
        min-height: 100vh;
        background: #000;
    }

    .instagram-container,
    .post-view-container,
    .story-view-container,
    .chat-view-container {
        border: 1px solid #262626;
        border-radius: 0;
    }
}

/* Animations */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.slide-in {
    animation: slideInRight 0.3s ease-out;
}

.slide-out {
    animation: slideOutRight 0.3s ease-out;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 0;
}

.action-btn:active,
.nav-btn:active {
    opacity: 0.7;
}
