/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #fafafa;
    color: #262626;
    height: 100vh;
    overflow: hidden;
}

/* Loading Page */
.loading-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: heartbeat 1.5s ease-in-out infinite;
}

.loading-image {
    width: 300px;
    height: 300px;
    animation: pulse 2s ease-in-out infinite;
}

.loading-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Main Layout Grid */
.app-container {
    display: grid;
    grid-template-rows: 60px 100px 1fr 60px;
    height: 100vh;
    max-width: 100%;
}

/* Header */
.header {
    grid-row: 1;
    background-color: #ffffff;
    border-bottom: 1px solid #dbdbdb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 24px;
    font-weight: 700;
    color: #262626;
    background: linear-gradient(45deg, #0095f6, #bc1888);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-icons {
    display: flex;
    gap: 20px;
    align-items: center;
}

.icon {
    width: 24px;
    height: 24px;
    color: #262626;
    cursor: pointer;
    transition: color 0.3s ease;
}

.heart-icon {
    color: #dc2743;
}

.translation-icon-container {
    position: relative;
}

.translation-icon {
    color: #dc2743;
}

/* Stories Section */
.stories {
    grid-row: 2;
    background-color: #ffffff;
    border-bottom: 1px solid #dbdbdb;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px 20px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.stories::-webkit-scrollbar {
    display: none;
}

.stories-container {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: center;
    min-width: max-content;
}

.story-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.3s ease;
    min-width: 70px;
}

.story-item:hover {
    transform: scale(1.05);
}

.story-item.active {
    background-color: rgba(0, 149, 246, 0.1);
    border-radius: 10px;
    padding: 5px;
}

.story-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    padding: 3px;
    position: relative;
}

.story-circle::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    right: 3px;
    bottom: 3px;
    border-radius: 50%;
    background: #ffffff;
    z-index: 1;
}

.your-story::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    right: 3px;
    bottom: 3px;
    border-radius: 50%;
    background: #0095f6;
    z-index: 1;
}

.story-icon {
    width: 20px;
    height: 20px;
    color: #262626;
    position: relative;
    z-index: 3;
    display: block !important;
    opacity: 1 !important;
}

.your-story {
    background: #0095f6;
}

.your-story .story-icon {
    color: #ffffff !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.plus-icon {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    background: #0095f6;
    border: 2px solid #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4;
}

.plus-icon svg {
    width: 10px;
    height: 10px;
    color: #ffffff;
}

.story-label {
    font-size: 12px;
    font-weight: 400;
    color: #262626;
    text-align: center;
    max-width: 60px;
    line-height: 1.2;
    margin-top: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Main Content */
.main-content {
    grid-row: 3;
    background-color: #fafafa;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.main-content::-webkit-scrollbar {
    display: none;
}

.post-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

.post {
    background-color: #ffffff;
    border: 1px solid #dbdbdb;
    border-radius: 8px;
    margin-bottom: 20px;
    display: none;
}

.post.active {
    display: block;
}

/* Post Header */
.post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #dbdbdb;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-pic {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    position: relative;
}

.profile-pic::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    border-radius: 50%;
    background: #ffffff;
    z-index: 1;
}

.profile-pic svg {
    width: 18px;
    height: 18px;
    color: #262626;
    position: relative;
    z-index: 2;
}

.user-details {
    display: flex;
    align-items: center;
    gap: 8px;
}

.username {
    font-weight: 600;
    font-size: 14px;
    color: #262626;
}

.verified-icon {
    width: 16px;
    height: 16px;
    color: #0095f6;
    filter: drop-shadow(0 0 2px rgba(0, 149, 246, 0.3));
}

.more-icon {
    width: 16px;
    height: 16px;
    color: #8e8e8e;
    cursor: pointer;
}

/* Post Content */
.post-content {
    padding: 0;
}

.post-content h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #262626;
    margin-bottom: 15px;
    line-height: 1.3;
}

.post-content p {
    font-size: 1rem;
    color: #8e8e8e;
    line-height: 1.5;
}

/* Post Images */
.post-image {
    width: 100%;
    height: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f8f8f8;
}

.post-image img {
    max-width: 100%;
    height: auto;
    max-height: 800px;
    object-fit: contain;
}

/* Post Caption */
.post-caption {
    padding: 15px 20px 10px;
    border-bottom: 1px solid #dbdbdb;
}

.caption-text {
    font-size: 16px;
    font-weight: 700;
    color: #262626;
    line-height: 1.4;
}

/* Chat Container */
.chat-container {
    padding: 20px;
    height: 400px;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 20px;
    padding: 10px 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.chat-messages::-webkit-scrollbar {
    display: none;
}

.message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.message.received {
    align-items: flex-start;
}

.message.sent {
    align-items: flex-end;
}

.message-content {
    background-color: #efefef;
    color: #262626;
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 80%;
    font-size: 0.9rem;
    line-height: 1.4;
}

.message.sent .message-content {
    background-color: #0095f6;
    color: #ffffff;
}

.message-time {
    font-size: 0.7rem;
    color: #8e8e8e;
    margin-top: 4px;
    padding: 0 8px;
}

.chat-input-container {
    border-top: 1px solid #dbdbdb;
    padding-top: 15px;
}

.chat-input {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #dbdbdb;
    border-radius: 25px;
    font-size: 14px;
    background-color: #ffffff;
    color: #262626;
}

.chat-input input:focus {
    outline: none;
    border-color: #0095f6;
}

#send-button {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background-color: #0095f6;
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

#send-button:hover {
    background-color: #1877f2;
    transform: scale(1.05);
}

#send-button svg {
    width: 20px;
    height: 20px;
}

/* Post Actions */
.post-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-top: 1px solid #dbdbdb;
}

.action-buttons {
    display: flex;
    gap: 20px;
}

.action-icon {
    width: 40px;
    height: 40px;
    color: #262626;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 12px;
    border-radius: 50%;
}

.heart-action {
    color: #dc2743;
}

.action-icon:hover {
    color: #8e8e8e;
    background-color: rgba(0, 0, 0, 0.05);
    transform: scale(1.1);
}

.heart-action:hover {
    color: #dc2743;
    animation: pulse 0.6s ease-in-out;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.post-likes {
    padding: 0 20px 15px;
}

.post-likes span {
    font-weight: 600;
    font-size: 14px;
    color: #262626;
}

/* Bottom Navigation */
.bottom-nav {
    grid-row: 4;
    background-color: #ffffff;
    border-top: 1px solid #dbdbdb;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0;
    position: relative;
    z-index: 1000;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 8px;
    border-radius: 8px;
}

.nav-item.active {
    background-color: rgba(0, 0, 0, 0.05);
}

.nav-icon {
    width: 24px;
    height: 24px;
    color: #262626;
    transition: color 0.3s ease;
}

.nav-item.active .nav-icon {
    color: #0095f6;
}

.nav-item:hover .nav-icon {
    color: #8e8e8e;
}

.nav-item.active:hover .nav-icon {
    color: #0095f6;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .app-container {
        grid-template-rows: 50px 90px 1fr 50px;
        height: 100vh;
    }
    
    .loading-image {
        width: 200px;
        height: 200px;
    }
    
    .header {
        padding: 0 15px;
    }
    
    .logo {
        font-size: 20px;
    }
    
    .icon {
        width: 22px;
        height: 22px;
    }
    
    .notification-badge {
        width: 16px;
        height: 16px;
        font-size: 9px;
    }
    
    .stories {
        padding: 10px 15px;
    }
    
    .stories-container {
        gap: 15px;
    }
    
    .story-circle {
        width: 50px;
        height: 50px;
    }
    
    .story-icon {
        width: 16px;
        height: 16px;
    }
    
    .plus-icon {
        width: 16px;
        height: 16px;
    }
    
    .plus-icon svg {
        width: 8px;
        height: 8px;
    }
    
    .story-label {
        font-size: 10px;
        max-width: 50px;
    }
    
    .post-container {
        max-width: 100%;
        padding: 15px;
    }
    
    .post-image img {
        max-height: 400px;
    }
    
    .post-content h2 {
        font-size: 1.3rem;
    }
    
    .post-content p {
        font-size: 0.9rem;
    }
    
    .action-icon {
        width: 35px;
        height: 35px;
        padding: 10px;
    }
    
    .chat-container {
        padding: 15px;
        height: 350px;
    }
    
    .chat-input input {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    #send-button {
        width: 40px;
        height: 40px;
    }
    
    #send-button svg {
        width: 18px;
        height: 18px;
    }
    
    .bottom-nav {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 9999 !important;
        width: 100vw !important;
        display: flex !important;
        background-color: #ffffff !important;
        border-top: 1px solid #dbdbdb !important;
    }
}

@media (max-width: 480px) {
    .app-container {
        grid-template-rows: 45px 80px 1fr 45px;
        height: 100vh;
    }
    
    .loading-image {
        width: 200px;
        height: 200px;
    }
    
    .logo {
        font-size: 18px;
    }
    
    .icon {
        width: 20px;
        height: 20px;
    }
    
    .stories {
        padding: 8px 10px;
    }
    
    .story-circle {
        width: 45px;
        height: 45px;
    }
    
    .story-icon {
        width: 14px;
        height: 14px;
    }
    
    .story-label {
        font-size: 9px;
    }
    
    .post-image img {
        max-height: 350px;
    }
    
    .post-content h2 {
        font-size: 1.2rem;
    }
    
    .action-icon {
        width: 32px;
        height: 32px;
        padding: 8px;
    }
    
    .chat-container {
        height: 300px;
    }
    
    .bottom-nav {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 9999 !important;
        width: 100vw !important;
        display: flex !important;
        background-color: #ffffff !important;
        border-top: 1px solid #dbdbdb !important;
    }
}

/* Desktop/Laptop Responsive */
@media (min-width: 1200px) {
    .post-container {
        max-width: 1200px;
    }
    
    .post-image img {
        max-height: 900px;
    }
    
    .loading-image {
        width: 400px;
        height: 400px;
    }
}

/* Large Desktop */
@media (min-width: 1600px) {
    .post-container {
        max-width: 1400px;
    }
    
    .post-image img {
        max-height: 1000px;
    }
    
    .loading-image {
        width: 500px;
        height: 500px;
    }
}

/* Dark Mode Styles */
.dark-mode {
    background-color: #000000 !important;
    color: #ffffff !important;
}

.dark-mode .app-container {
    background-color: #000000 !important;
}

.dark-mode .header {
    background-color: #000000 !important;
    border-bottom-color: #333333 !important;
}

.dark-mode .logo {
    color: #ffffff !important;
}

.dark-mode .icon {
    color: #ffffff !important;
}

.dark-mode .heart-icon {
    color: #dc2743 !important;
    fill: #dc2743 !important;
}

.dark-mode .stories {
    background-color: #000000 !important;
    border-bottom-color: #333333 !important;
}

.dark-mode .story-label {
    color: #ffffff !important;
}

.dark-mode .main-content {
    background-color: #000000 !important;
}

.dark-mode .post {
    background-color: #000000 !important;
    border-color: #333333 !important;
}

.dark-mode .post-header {
    border-bottom-color: #333333 !important;
}

.dark-mode .username {
    color: #ffffff !important;
}

.dark-mode .post-caption {
    border-bottom-color: #333333 !important;
}

.dark-mode .caption-text {
    color: #ffffff !important;
}

.dark-mode .post-actions {
    border-top-color: #333333 !important;
}

.dark-mode .action-icon {
    color: #ffffff !important;
}

.dark-mode .heart-action {
    color: #dc2743 !important;
    fill: #dc2743 !important;
}

.dark-mode .bottom-nav {
    background-color: #000000 !important;
    border-top-color: #333333 !important;
}

.dark-mode .nav-icon {
    color: #ffffff !important;
}

.dark-mode .chat-container {
    background-color: #000000 !important;
}

.dark-mode .message-content {
    background-color: #333333 !important;
    color: #ffffff !important;
}

.dark-mode .message.sent .message-content {
    background-color: #0095f6 !important;
    color: #ffffff !important;
}

.dark-mode .chat-input input {
    background-color: #333333 !important;
    color: #ffffff !important;
    border-color: #555555 !important;
}

.dark-mode .chat-input-container {
    border-top-color: #333333 !important;
}

/* Touch Interactions */
@media (hover: none) and (pointer: coarse) {
    .story-item:hover {
        transform: none;
    }
    
    .story-item:active {
        transform: scale(0.95);
    }
    
    .action-icon:hover {
        transform: none;
    }
    
    .action-icon:active {
        transform: scale(1.2);
    }
}