/* CSS Variables - Instagram-inspired palette */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #fafafa;
    --bg-tertiary: #f0f0f0;
    --text-primary: #262626;
    --text-secondary: #8e8e8e;
    --text-tertiary: #c7c7c7;
    --border-color: #dbdbdb;
    --accent-gradient-start: #f09433;
    --accent-gradient-mid: #e6683c;
    --accent-gradient-end: #bc1888;
    --accent-purple: #833ab4;
    --accent-blue: #405de6;
    --like-red: #ed4956;
    --font-display: 'Playfair Display', serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 50%;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Navigation */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    height: 60px;
}

.nav-container {
    max-width: 975px;
    margin: 0 auto;
    padding: 0 20px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-left {
    flex: 1;
}

.logo {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.5px;
    background: linear-gradient(45deg, var(--accent-gradient-start), var(--accent-gradient-mid), var(--accent-gradient-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.search-bar {
    position: relative;
    width: 268px;
}

.search-bar input {
    width: 100%;
    height: 36px;
    padding: 0 16px 0 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    font-size: 14px;
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--text-tertiary);
    background: var(--bg-primary);
}

.search-bar input::placeholder {
    color: var(--text-secondary);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.nav-right {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 22px;
}

.nav-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: var(--text-primary);
    transition: transform var(--transition-fast), opacity var(--transition-fast);
    position: relative;
}

.nav-btn:hover {
    transform: scale(1.05);
    opacity: 0.7;
}

.nav-btn.active {
    color: var(--text-primary);
}

.nav-btn.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: var(--accent-gradient-end);
    border-radius: var(--radius-full);
}

.nav-avatar {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 1px solid var(--border-color);
}

/* Main Container */
.main-container {
    max-width: 935px;
    margin: 60px auto 0;
    padding: 30px 20px 80px;
    display: grid;
    grid-template-columns: 1fr 319px;
    gap: 30px;
}

/* Stories Section */
.stories-section {
    grid-column: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 24px;
}

.stories-container {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 4px;
}

.stories-container::-webkit-scrollbar {
    display: none;
}

.story-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform var(--transition-fast);
}

.story-item:hover {
    transform: translateY(-2px);
}

.story-ring {
    width: 66px;
    height: 66px;
    border-radius: var(--radius-full);
    padding: 3px;
    background: var(--bg-tertiary);
    position: relative;
}

.story-ring.has-story {
    background: linear-gradient(45deg, var(--accent-gradient-start), var(--accent-gradient-mid), var(--accent-gradient-end));
}

.story-avatar {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-full);
    overflow: hidden;
    border: 2px solid var(--bg-primary);
    position: relative;
}

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

.add-story .story-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
}

.add-icon {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    background: var(--accent-blue);
    color: white;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    border: 2px solid var(--bg-primary);
}

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

/* Feed Section */
.feed-section {
    grid-column: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Post */
.post {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    animation: fadeInUp 0.6s ease forwards;
    opacity: 0;
    transform: translateY(20px);
}

.post:nth-child(1) { animation-delay: 0.1s; }
.post:nth-child(2) { animation-delay: 0.2s; }
.post:nth-child(3) { animation-delay: 0.3s; }

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.post-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.post-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    overflow: hidden;
    border: 2px solid transparent;
    background: linear-gradient(45deg, var(--accent-gradient-start), var(--accent-gradient-mid), var(--accent-gradient-end));
    padding: 2px;
}

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

.post-info {
    display: flex;
    flex-direction: column;
}

.post-username {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
}

.post-username:hover {
    text-decoration: underline;
}

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

.post-more {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.post-more:hover {
    background: var(--bg-tertiary);
}

.post-image {
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    background: var(--bg-tertiary);
}

.post-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.post:hover .post-image img {
    transform: scale(1.02);
}

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

.post-actions-left {
    display: flex;
    gap: 16px;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    padding: 0;
    transition: transform var(--transition-fast), color var(--transition-fast);
}

.action-btn:hover {
    transform: scale(1.1);
    opacity: 0.6;
}

.action-btn.liked {
    color: var(--like-red);
    animation: heartBeat 0.4s ease;
}

@keyframes heartBeat {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.3); }
    50% { transform: scale(1); }
    75% { transform: scale(1.2); }
}

.action-btn.liked .heart-icon {
    fill: var(--like-red);
    stroke: var(--like-red);
}

.save-btn.saved {
    color: var(--text-primary);
}

.save-btn.saved svg {
    fill: var(--text-primary);
}

.post-likes {
    padding: 0 16px 8px;
}

.likes-count {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.post-caption {
    padding: 0 16px 8px;
    font-size: 14px;
    line-height: 1.5;
}

.caption-text {
    color: var(--text-primary);
}

.post-comments {
    padding: 0 16px 8px;
}

.view-comments {
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
}

.view-comments:hover {
    color: var(--text-primary);
}

.comment {
    margin-top: 4px;
    font-size: 14px;
}

.comment-username {
    font-weight: 600;
    color: var(--text-primary);
    margin-right: 4px;
}

.comment-text {
    color: var(--text-primary);
}

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

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    flex: 1;
    text-align: center;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-primary);
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-tertiary);
}

.modal-body {
    padding: 40px;
}

.upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 40px;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.upload-area:hover {
    border-color: var(--text-secondary);
    background: var(--bg-secondary);
}

.upload-area svg {
    color: var(--text-primary);
}

.upload-area p {
    font-size: 22px;
    color: var(--text-primary);
    font-weight: 300;
}

.btn-primary {
    background: var(--accent-blue);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Mobile Navigation */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: 8px 0;
    z-index: 1000;
}

.mobile-nav-btn {
    flex: 1;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-fast);
}

.mobile-nav-btn:hover {
    transform: scale(1.1);
}

.mobile-nav-btn.active {
    color: var(--text-primary);
}

.create-btn {
    background: transparent;
    border: 1px solid var(--text-primary);
    border-radius: var(--radius-sm);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Responsive Design */
@media (max-width: 935px) {
    .main-container {
        grid-template-columns: 1fr;
        max-width: 600px;
    }
}

@media (max-width: 768px) {
    .navbar {
        height: 50px;
    }

    .nav-center {
        display: none;
    }

    .nav-right {
        gap: 16px;
    }

    .nav-btn:not(:last-child) {
        display: none;
    }

    .main-container {
        margin-top: 50px;
        padding: 0 0 70px;
    }

    .stories-section {
        border-radius: 0;
        border-left: none;
        border-right: none;
        margin-bottom: 0;
    }

    .post {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .mobile-nav {
        display: flex;
    }
}

@media (max-width: 480px) {
    .logo {
        font-size: 24px;
    }

    .story-ring {
        width: 62px;
        height: 62px;
    }

    .story-avatar {
        width: 56px;
        height: 56px;
    }

    .story-username {
        font-size: 11px;
    }

    .upload-area p {
        font-size: 18px;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Selection */
::selection {
    background: var(--accent-gradient-mid);
    color: white;
}