:root {
    --bg-color: #000000;
    --text-primary: #ffffff;
    --text-secondary: #a8a8a8;
    --border-color: #262626;
    --accent-gradient: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    --nav-bg: rgba(0, 0, 0, 0.85);
    --hover-bg: #1a1a1a;
    --radius-full: 9999px;
    --radius-md: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
    display: flex;
    justify-content: center;
}

/* App Container for Desktop Constraints */
#app-container {
    width: 100%;
    max-width: 450px; /* Mobile width */
    height: 100vh;
    height: 100dvh;
    background-color: var(--bg-color);
    position: relative;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

/* Header */
#main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background-color: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-logo {
    width: 32px;
    height: 32px;
    background-color: #2fb344; /* Premium Green */
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 20px;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 2px 10px rgba(47, 179, 68, 0.3);
}

.logo {
    font-family: 'Inter', sans-serif;
    font-size: 22px;
    font-style: italic;
    font-weight: 700;
    letter-spacing: -1px;
}

.header-actions {
    display: flex;
    gap: 20px;
    font-size: 24px;
}

.header-actions i {
    cursor: pointer;
    transition: transform 0.2s;
}

.header-actions i:active {
    transform: scale(0.9);
}

/* Main Content Area */
#main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    scrollbar-width: none;
}
#main-content::-webkit-scrollbar {
    display: none;
}

/* Views (Pages) */
.view {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background-color: var(--bg-color);
    transition: opacity 0.3s ease;
}

.view.active {
    display: block;
    animation: fade-in 0.3s ease;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Stories Area */
.stories-container {
    display: flex;
    gap: 15px;
    padding: 15px 16px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border-color);
    scrollbar-width: none;
}
.stories-container::-webkit-scrollbar {
    display: none;
}

.story {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    flex-shrink: 0;
}

.story span {
    font-size: 11px;
    color: var(--text-primary);
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.story-avatar {
    width: 66px;
    height: 66px;
    border-radius: var(--radius-full);
    padding: 3px;
    background: var(--accent-gradient);
    position: relative;
}

.story-avatar img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 2px solid var(--bg-color);
}

.story-avatar.create-story {
    background: transparent;
    padding: 0;
}
.story-avatar.create-story img {
    border: none;
}
.add-story-btn {
    position: absolute;
    bottom: 0px;
    right: 0px;
    background-color: #0095f6;
    border: 2px solid var(--bg-color);
    border-radius: var(--radius-full);
    width: 22px;
    height: 22px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
}

/* Feed Container */
#feed-container {
    padding-bottom: 60px; /* space for nav */
}

/* Post Style */
.post {
    margin-bottom: 20px;
}

.post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
}

.post-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 13px;
}

.post-user img {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    object-fit: cover;
}

.post-options {
    color: var(--text-secondary);
    font-size: 20px;
}

.post-media-container {
    width: 100%;
    position: relative;
    background-color: #111;
}

.post-slides {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
}
.post-slides::-webkit-scrollbar {
    display: none;
}

.slide-item {
    min-width: 100%;
    scroll-snap-align: start;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.slide-item img, .slide-item video {
    width: 100%;
    max-height: 500px;
    object-fit: contain;
    display: block;
}

.slide-indicator {
    position: absolute;
    top: 10px;
    right: 16px;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    z-index: 2;
}

.post-actions {
    display: flex;
    justify-content: space-between;
    padding: 10px 16px;
    font-size: 26px;
}

.post-actions-left {
    display: flex;
    gap: 16px;
}
.post-actions i {
    cursor: pointer;
    transition: transform 0.2s;
}
.post-actions i:active {
    transform: scale(0.9);
}

.post-likes {
    font-weight: 600;
    font-size: 13px;
    padding: 0 16px;
    margin-bottom: 6px;
}

.post-caption {
    font-size: 13px;
    padding: 0 16px;
    line-height: 1.4;
}
.post-caption strong {
    font-weight: 600;
}

.post-comments-link {
    color: var(--text-secondary);
    font-size: 13px;
    padding: 6px 16px;
    cursor: pointer;
}

.post-time {
    color: var(--text-secondary);
    font-size: 10px;
    padding: 0 16px;
    text-transform: uppercase;
}

/* Bottom Navigation */
#bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 50px;
    background-color: var(--nav-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
    position: fixed;
    bottom: 0;
    width: 100%;
    max-width: 450px;
    z-index: 20;
}

.nav-item {
    font-size: 26px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s, transform 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 50px;
    height: 50px;
}
.nav-item:active {
    transform: scale(0.9);
}

.nav-item.active {
    color: var(--text-primary);
}
.nav-item.active i {
    font-weight: bold; /* simple trick */
}

.nav-item.profile-nav img {
    width: 26px;
    height: 26px;
    border-radius: var(--radius-full);
}
.nav-item.profile-nav.active img {
    border: 2px solid var(--text-primary);
}

/* Reels View */
#view-reels {
    background-color: #000;
    z-index: 5;
}
.reels-container {
    height: 100%;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scrollbar-width: none;
}
.reels-container::-webkit-scrollbar {
    display: none;
}

.reel-item {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    scroll-snap-align: start;
    position: relative;
    background-color: #121212;
    display: flex;
    justify-content: center;
    align-items: center;
}

.reel-video-placeholder {
    width: 100%;
    height: 100%;
    background-color: #222;
    background-position: center;
    background-size: cover;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0.8;
}

.reel-overlay {
    position: absolute;
    bottom: 70px;
    left: 16px;
    z-index: 2;
}

.reel-user {
    display: flex;
    align-items: center;
    gap: 10px;
}
.reel-user img {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
}
.reel-user span {
    font-weight: 600;
    font-size: 14px;
}
.reel-user button {
    background-color: transparent;
    border: 1px solid var(--text-primary);
    color: var(--text-primary);
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 10px;
}

.reel-caption {
    font-size: 13px;
    margin-top: 10px;
}

.reel-actions {
    position: absolute;
    bottom: 70px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 2;
    align-items: center;
}
.reel-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-size: 28px;
}
.reel-action span {
    font-size: 12px;
    font-weight: 600;
}

/* Messages View */
#view-messages {
    background-color: var(--bg-color);
    z-index: 15;
}

.messages-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 24px;
}
.messages-header h2 {
    font-size: 18px;
    font-weight: 700;
}
.back-btn {
    cursor: pointer;
    font-size: 30px;
}

.messages-search {
    padding: 16px;
}
.messages-search input {
    width: 100%;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    border: none;
    background-color: var(--border-color);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}
.messages-search input::placeholder {
    color: var(--text-secondary);
}

.messages-list {
    overflow-y: auto;
    height: calc(100vh - 150px);
}

.message-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 15px;
    cursor: pointer;
    transition: background-color 0.2s;
}
.message-item:hover {
    background-color: var(--hover-bg);
}

.message-avatar {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    position: relative;
    flex-shrink: 0;
}
.message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
}
.active-dot {
    width: 14px;
    height: 14px;
    background-color: #4CAF50;
    border: 3px solid var(--bg-color);
    border-radius: var(--radius-full);
    position: absolute;
    bottom: 0;
    right: 0;
}

.message-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.message-info h4 {
    font-size: 14px;
    font-weight: 600;
}
.message-snippet {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
    display: flex;
    gap: 5px;
}

.camera-action {
    color: var(--text-secondary);
    font-size: 24px;
}

/* Chat Detail View */
#view-chat-detail {
    z-index: 25;
    display: none; /* explicitly manage display via js block/none */
    flex-direction: column;
    justify-content: space-between;
}
#view-chat-detail.active {
    display: flex; /* because default view active sets display:block */
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 24px;
    background-color: var(--bg-color);
}
.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.chat-header-actions i {
    cursor: pointer;
    font-size: 22px;
    color: var(--text-secondary);
    transition: color 0.2s;
}
.chat-header-actions i:hover {
    color: var(--text-primary);
}
.chat-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    margin-left: 10px;
}
.chat-user-info img {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
}
.chat-user-info h3 {
    font-size: 15px;
    font-weight: 600;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background-color: var(--bg-color);
}

.bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
}

.bubble.received {
    align-self: flex-start;
    background-color: #262626;
    color: #fff;
}

.bubble.sent {
    align-self: flex-end;
    background-color: #3797F0;
    color: #fff;
}

.bubble img {
    display: block;
    margin: -4px -4px; /* offset padding */
    border-radius: 12px;
}


.chat-input-area {
    padding: 10px 16px;
    background-color: var(--bg-color);
    border-top: 1px solid var(--border-color);
}
.chat-input-wrapper {
    display: flex;
    align-items: center;
    background-color: #262626;
    border-radius: 20px;
    padding: 8px 16px;
    gap: 12px;
}
.chat-input-wrapper i {
    font-size: 22px;
    color: var(--text-primary);
}
.chat-input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}
.chat-input-wrapper input::placeholder {
    color: var(--text-secondary);
}

/* Animations that give a dynamic feel */
.like-animation {
    animation: heartBurst 0.3s ease forwards;
    color: #ed4956 !important; /* Instagram red */
}
@keyframes heartBurst {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

#voice-btn.recording {
    color: #ed4956 !important;
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0.5; transform: scale(1.1); }
}

.bubble audio {
    display: block;
    margin-top: 5px;
    height: 35px;
    max-width: 100%;
}

.bubble.sent audio {
    filter: invert(1);
}
