/* ============================
   INSTAGRAM 2026 STYLE CLONE
   Dark Mode + Modern UI
   ============================ */

:root {
    /* Light theme */
    --bg: #ffffff;
    --bg-secondary: #fafafa;
    --bg-hover: #f2f2f2;
    --border: #dbdbdb;
    --border-light: #efefef;
    --text: #000000;
    --text-secondary: #8e8e8e;
    --text-light: #c7c7c7;
    --primary: #0095f6;
    --primary-hover: #1877f2;
    --danger: #ed4956;
    --danger-hover: #c6232e;
    --gradient-ig: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    --gradient-story: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
    --nav-height: 60px;
}

[data-theme="dark"] {
    --bg: #000000;
    --bg-secondary: #121212;
    --bg-hover: #1a1a1a;
    --border: #262626;
    --border-light: #1c1c1c;
    --text: #f5f5f5;
    --text-secondary: #a8a8a8;
    --text-light: #555;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    padding-top: var(--nav-height);
    transition: background var(--transition), color var(--transition);
}

a { color: var(--text); text-decoration: none; }
a:hover { color: var(--text-secondary); }

.container { max-width: 975px; margin: 0 auto; padding: 0 20px; }

/* ===== NAVBAR 2026 ===== */
.navbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
    background: var(--bg); border-bottom: 1px solid var(--border);
    height: var(--nav-height); backdrop-filter: blur(12px);
}

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

.nav-logo {
    font-size: 1.45rem; font-weight: 600;
    background: var(--gradient-ig); -webkit-background-clip: text;
    -webkit-text-fill-color: transparent; background-clip: text;
    display: flex; align-items: center; gap: 6px;
}

.nav-logo i { font-size: 1.5rem; }

.nav-search { flex: 1; max-width: 364px; margin: 0 24px; }

.nav-search form {
    display: flex; align-items: center;
    background: var(--bg-secondary); border-radius: 10px;
    border: 1px solid transparent; transition: var(--transition);
}

.nav-search form:focus-within {
    border-color: var(--text-secondary); background: var(--bg);
}

.search-input {
    border: none; background: transparent; padding: 10px 16px;
    width: 100%; font-size: 0.9rem; outline: none; color: var(--text);
}

.search-input::placeholder { color: var(--text-secondary); }
.nav-search button { border: none; background: transparent; padding: 10px 14px; color: var(--text-secondary); cursor: pointer; }

.nav-links { display: flex; align-items: center; gap: 4px; }

.nav-icon {
    color: var(--text); font-size: 1.5rem; padding: 10px;
    border-radius: 10px; transition: var(--transition); position: relative;
}

.nav-icon:hover { background: var(--bg-hover); }

.nav-avatar {
    width: 26px; height: 26px; border-radius: 50%; object-fit: cover;
    border: 2px solid transparent; transition: var(--transition);
}

.nav-icon:hover .nav-avatar { border-color: var(--text); }

.theme-toggle { cursor: pointer; }

/* Notification dot */
.notification-dot {
    position: absolute; top: 8px; right: 7px;
    width: 8px; height: 8px; background: var(--danger); border-radius: 50%;
    border: 2px solid var(--bg);
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 18px; border-radius: 10px; border: none;
    font-weight: 600; font-size: 0.88rem; cursor: pointer;
    transition: var(--transition); gap: 6px; text-decoration: none;
}

.btn-primary {
    background: var(--primary); color: white;
    border: none;
}
.btn-primary:hover { background: var(--primary-hover); color: white; }

.btn-outline {
    background: transparent; color: var(--text);
    border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg-secondary); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-hover); }

.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--bg-hover); }

.btn-sm { padding: 5px 12px; font-size: 0.8rem; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; border-radius: 50%; background: var(--bg-secondary); }

/* ===== MESSAGES ===== */
.messages-container {
    position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
    z-index: 2000; display: flex; flex-direction: column; gap: 8px;
}

.message {
    padding: 12px 28px; border-radius: 12px; font-weight: 500;
    animation: slideDown 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.message-success { background: #e8f5e9; color: #2e7d32; }
.message-error { background: #fce4ec; color: #c62828; }
.message-info { background: #e3f2fd; color: #1565c0; }

@keyframes slideDown {
    from { opacity: 0; transform: translateX(-50%) translateY(-16px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== AUTH ===== */
.auth-container {
    display: flex; justify-content: center; align-items: center;
    min-height: calc(100vh - var(--nav-height) - 40px);
}

.auth-box {
    background: var(--bg); border: 1px solid var(--border);
    border-radius: 4px; padding: 40px; width: 100%; max-width: 380px;
}

.auth-logo {
    font-size: 2.4rem; font-weight: 600; text-align: center; margin-bottom: 28px;
    background: var(--gradient-ig); -webkit-background-clip: text;
    -webkit-text-fill-color: transparent; background-clip: text;
}

.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form label { display: none; }

.form-input, .auth-form input, .auth-form textarea {
    width: 100%; padding: 11px 14px; border: 1px solid var(--border);
    border-radius: 6px; font-size: 0.9rem; background: var(--bg-secondary);
    color: var(--text); outline: none; transition: var(--transition);
}

.form-input:focus, .auth-form input:focus {
    border-color: var(--text-secondary); background: var(--bg);
}

.auth-form button { margin-top: 8px; }
.auth-footer { margin-top: 20px; text-align: center; font-size: 0.85rem; color: var(--text-secondary); }
.auth-footer a { color: var(--primary); font-weight: 600; }

/* ===== FEED LAYOUT ===== */
.feed-layout {
    display: grid; grid-template-columns: 1fr 320px; gap: 24px;
    padding-top: 24px;
}

/* ===== STORIES BAR ===== */
.stories-bar {
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px 14px; margin-bottom: 20px;
    display: flex; gap: 14px; overflow-x: auto;
    scrollbar-width: none; -ms-overflow-style: none;
}

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

.story-item {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    cursor: pointer; flex-shrink: 0; min-width: 64px;
}

.story-ring {
    width: 62px; height: 62px; border-radius: 50%; padding: 2.5px;
    background: var(--gradient-story);
}

.story-ring img {
    width: 100%; height: 100%; border-radius: 50%; object-fit: cover;
    border: 2.5px solid var(--bg);
}

.story-ring-read {
    background: var(--border);
}

.story-add .story-ring {
    background: var(--border-light); display: flex;
    align-items: center; justify-content: center;
}

.story-add .story-ring i {
    font-size: 1.5rem; color: var(--primary);
}

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

/* ===== THREADS BAR ===== */
.threads-bar {
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; margin-bottom: 20px;
}

.thread-create {
    display: flex; gap: 10px; align-items: center;
}

.thread-create input {
    flex: 1; border: none; background: var(--bg-secondary);
    padding: 10px 14px; border-radius: 20px; font-size: 0.9rem;
    color: var(--text); outline: none;
}

.thread-create button { white-space: nowrap; }

.thread-list { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }

.thread-item {
    display: flex; gap: 10px; align-items: flex-start; padding: 8px;
    border-radius: var(--radius-sm); transition: var(--transition);
}

.thread-item:hover { background: var(--bg-hover); }
.thread-item img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.thread-item strong { font-size: 0.85rem; }
.thread-item span { font-size: 0.8rem; color: var(--text-secondary); margin-left: 6px; }

/* ===== POST CARD ===== */
.card {
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 16px;
}

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

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

.post-avatar {
    width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
    border: 2px solid var(--border-light);
}

.verified-badge {
    color: var(--primary); font-size: 0.75rem; margin-left: 3px;
}

.post-dot-btn { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text); padding: 4px; }

/* Post Images Carousel */
.post-images {
    position: relative; background: var(--bg-secondary);
}

.post-images img {
    width: 100%; display: block; object-fit: cover;
    max-height: 650px;
}

.carousel-dots {
    position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 4px;
}

.carousel-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: rgba(255,255,255,0.5); transition: var(--transition);
}

.carousel-dot.active { background: var(--primary); width: 7px; height: 7px; }

.carousel-prev, .carousel-next {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(255,255,255,0.9); border: none; width: 28px; height: 28px;
    border-radius: 50%; font-size: 1rem; cursor: pointer; opacity: 0;
    transition: var(--transition); color: #333;
}

.post-images:hover .carousel-prev,
.post-images:hover .carousel-next { opacity: 1; }

.carousel-prev { left: 8px; }
.carousel-next { right: 8px; }

/* Post Actions */
.post-actions {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 14px;
}

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

.action-btn {
    background: none; border: none; font-size: 1.4rem; cursor: pointer;
    padding: 4px; transition: 0.15s; color: var(--text); display: flex;
}

.action-btn:hover { opacity: 0.6; }

.like-btn .fa-heart.liked { color: var(--danger); animation: heartPop 0.3s ease; }
.like-btn .fa-heart { transition: 0.15s; }

@keyframes heartPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.25); }
    100% { transform: scale(1); }
}

.saved-icon { color: var(--text); }

/* Post Info */
.post-likes { padding: 0 14px; font-size: 0.88rem; font-weight: 600; margin-bottom: 2px; }

.post-caption { padding: 0 14px 8px; font-size: 0.88rem; }
.post-caption strong { margin-right: 6px; }

.post-comments-link {
    padding: 0 14px 4px; font-size: 0.82rem; color: var(--text-secondary);
}

.comment { padding: 1px 14px; font-size: 0.85rem; }
.comment strong { margin-right: 5px; }

.post-time-link { padding: 6px 14px; font-size: 0.72rem; color: var(--text-secondary); }

.comment-form { border-top: 1px solid var(--border-light); padding: 0 14px; }

.inline-comment-form {
    display: flex; align-items: center; gap: 8px; padding: 12px 0;
}

.inline-comment-form input {
    flex: 1; border: none; outline: none; font-size: 0.88rem;
    background: transparent; color: var(--text);
}

.inline-comment-form input::placeholder { color: var(--text-secondary); }

.comment-submit-btn {
    background: none; border: none; color: var(--primary);
    font-weight: 600; cursor: pointer; font-size: 0.88rem;
    opacity: 0.4; transition: var(--transition);
}

.inline-comment-form input:not(:placeholder-shown) + .comment-submit-btn { opacity: 1; }
.comment-submit-btn:disabled { opacity: 0.3; }

/* ===== SIDEBAR ===== */
.feed-sidebar { position: sticky; top: calc(var(--nav-height) + 16px); }

.sidebar-profile {
    padding: 16px; display: flex; align-items: center; gap: 14px;
}

.sidebar-avatar {
    width: 50px; height: 50px; border-radius: 50%; object-fit: cover;
}

.sidebar-user { flex: 1; }
.sidebar-user strong { font-size: 0.9rem; }
.sidebar-user p { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }

.switch-btn { font-size: 0.78rem; color: var(--primary); font-weight: 600; }

.sidebar-suggestions { padding: 0 16px 16px; }
.sidebar-suggestions-header {
    display: flex; justify-content: space-between; padding: 8px 0 12px;
}

.sidebar-suggestions-header span { font-size: 0.85rem; color: var(--text-secondary); font-weight: 600; }
.sidebar-suggestions-header a { font-size: 0.78rem; font-weight: 600; }

.suggestion-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 0;
}

.suggestion-item img {
    width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
}

.suggestion-info { flex: 1; }
.suggestion-info strong { font-size: 0.85rem; }
.suggestion-info p { font-size: 0.75rem; color: var(--text-secondary); }

.sidebar-footer {
    padding: 16px; font-size: 0.72rem; color: var(--text-light);
}

.sidebar-footer a { margin-right: 8px; color: var(--text-light); }

/* ===== EXPLORE ===== */
.explore-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
    padding-top: 4px;
}

.explore-item {
    position: relative; aspect-ratio: 1; overflow: hidden;
    cursor: pointer;
}

.explore-item img { width: 100%; height: 100%; object-fit: cover; transition: 0.3s; }

.explore-item:hover img { transform: scale(1.05); }

.explore-overlay {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.35);
    display: flex; align-items: center; justify-content: center;
    gap: 20px; color: white; font-weight: 600; opacity: 0;
    transition: 0.2s; font-size: 0.95rem;
}

.explore-item:hover .explore-overlay { opacity: 1; }

.explore-item.multi::after {
    content: '\f03e'; font-family: 'Font Awesome 6 Free'; font-weight: 900;
    position: absolute; top: 8px; right: 8px; color: white;
    font-size: 1.1rem; text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* ===== PROFILE PAGE ===== */
.profile-header {
    display: flex; gap: 60px; padding: 30px 0 36px;
    border-bottom: 1px solid var(--border);
}

.profile-avatar-lg {
    width: 150px; height: 150px; border-radius: 50%; object-fit: cover;
    border: 4px solid var(--border-light);
}

.profile-avatar-lg.has-story { border-color: var(--gradient-story); }

.profile-info { flex: 1; }

.profile-name-row {
    display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}

.profile-name-row h2 { font-size: 1.25rem; font-weight: 400; }

.profile-stats {
    display: flex; gap: 36px; margin-bottom: 16px;
}

.profile-stat { font-size: 0.95rem; }
.profile-stat strong { font-weight: 600; }

.profile-bio { white-space: pre-line; font-size: 0.9rem; line-height: 1.5; margin-bottom: 8px; }
.profile-bio a { color: var(--primary); }

.profile-website {
    color: var(--primary); font-weight: 600; font-size: 0.9rem;
}

/* Profile tabs */
.profile-tabs {
    display: flex; justify-content: center; gap: 50px; padding: 10px 0;
    border-top: 1px solid var(--border);
}

.profile-tab {
    padding: 12px 0; border: none; background: none; cursor: pointer;
    color: var(--text-secondary); font-size: 0.8rem; font-weight: 600;
    letter-spacing: 0.5px; text-transform: uppercase; display: flex;
    align-items: center; gap: 6px;
    border-top: 1px solid transparent; margin-top: -1px; transition: var(--transition);
}

.profile-tab i { font-size: 0.7rem; }

.profile-tab.active, .profile-tab:hover {
    color: var(--text); border-top-color: var(--text);
}

/* Profile posts grid */
.profile-posts-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
}

.profile-post-item {
    position: relative; aspect-ratio: 1; overflow: hidden; cursor: pointer;
}

.profile-post-item img { width: 100%; height: 100%; object-fit: cover; transition: 0.3s; }
.profile-post-item:hover img { transform: scale(1.05); }

.profile-post-overlay {
    position: absolute; inset: 0; background: rgba(0,0,0,0.35);
    display: flex; align-items: center; justify-content: center;
    gap: 20px; color: white; font-weight: 600; opacity: 0; transition: 0.2s;
}

.profile-post-item:hover .profile-post-overlay { opacity: 1; }

.no-posts {
    grid-column: 1/-1; text-align: center; padding: 60px 20px;
    color: var(--text-secondary);
}

/* ===== REELS PAGE ===== */
.reels-page { padding-top: 16px; }
.reels-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.reels-header h2 { font-size: 1.1rem; font-weight: 600; }

.reels-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 4px;
}

.reel-item {
    position: relative; aspect-ratio: 9/16; overflow: hidden; cursor: pointer;
    border-radius: 4px;
}

.reel-item video { width: 100%; height: 100%; object-fit: cover; }

.reel-overlay {
    position: absolute; bottom: 0; left: 0; right: 0;
    padding: 12px; background: linear-gradient(transparent, rgba(0,0,0,0.7));
    color: white;
}

.reel-overlay strong { font-size: 0.85rem; }
.reel-overlay span { display: block; font-size: 0.75rem; opacity: 0.8; }

/* ===== STORY VIEW ===== */
.story-view-overlay {
    position: fixed; inset: 0; background: #1a1a1a; z-index: 5000;
    display: flex; align-items: center; justify-content: center;
}

.story-view-content { position: relative; max-width: 450px; width: 100%; }

.story-view-content img {
    width: 100%; border-radius: 8px; max-height: 90vh; object-fit: contain;
}

.story-view-progress {
    position: absolute; top: 8px; left: 8px; right: 8px;
    display: flex; gap: 3px;
}

.story-progress-bar {
    height: 2px; background: rgba(255,255,255,0.3);
    border-radius: 1px; flex: 1; overflow: hidden;
}

.story-progress-fill {
    height: 100%; background: white; transition: width 0.1s linear;
}

.story-view-header {
    position: absolute; top: 20px; left: 16px; right: 16px;
    display: flex; align-items: center; gap: 10px; color: white;
}

.story-view-close {
    position: absolute; top: 16px; right: 16px; color: white;
    font-size: 1.5rem; cursor: pointer; z-index: 10;
}

/* ===== SEARCH ===== */
.search-page { padding-top: 20px; }
.search-results { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }

.search-result-item {
    display: flex; align-items: center; gap: 12px; padding: 12px;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius-sm); transition: var(--transition);
}

.search-result-item:hover { background: var(--bg-hover); }

/* ===== CREATE POST MODAL ===== */
.create-post-card { padding: 18px; }

.create-post-form { display: flex; flex-direction: column; gap: 12px; }

.file-upload-label {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 30px; border: 2px dashed var(--border); border-radius: var(--radius);
    cursor: pointer; color: var(--text-secondary); transition: var(--transition);
    text-align: center; gap: 8px;
}

.file-upload-label:hover { border-color: var(--primary); color: var(--primary); }
.file-upload-label i { font-size: 2rem; }
.file-upload-label input[type="file"] { display: none; }

/* ===== UTILITY ===== */
.text-muted { color: var(--text-secondary); font-size: 0.85rem; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-secondary); }
.empty-state i { font-size: 3.5rem; margin-bottom: 16px; display: block; }
.empty-state h3 { margin-bottom: 8px; color: var(--text); }
.empty-state .btn { margin-top: 16px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .feed-layout { grid-template-columns: 1fr; }
    .feed-sidebar { display: none; }
    .container { padding: 0 10px; }
    .nav-search { max-width: 200px; }
}

@media (max-width: 640px) {
    .profile-header { flex-direction: column; align-items: center; gap: 16px; text-align: center; }
    .profile-stats { justify-content: center; gap: 24px; }
    .profile-name-row { justify-content: center; }
    .explore-grid, .profile-posts-grid { gap: 2px; }
    .nav-search { display: none; }
    .story-ring { width: 54px; height: 54px; }
}
