/* --- Instagram Clone --- */

:root {
    --background-primary: #FFFFFF;
    --background-secondary: #FAFAFA;
    --border-primary: #DBDBDB;
    --text-primary: #131313;
    --text-secondary: #8e8e8e;
    --button-primary: #0095F6;
    --button-primary-hover: #0077C6;
    --link-primary: #00376B;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--background-secondary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 18px;
}

.instagram-container {
    max-width: 614px;
    margin: 0 auto;
    padding: 0;
}

/* --- Header --- */
.main-header {
    background-color: var(--background-secondary);
    border-bottom: none;
    width: 100%;
    z-index: 100;
    padding: 0;
}

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

.logo a {
    text-decoration: none;
    color: inherit;
    font-family: 'Grand Hotel', cursive;
    font-size: 28px;
}

.search-bar input {
    background-color: var(--background-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 3px;
    padding: 6px 10px;
    text-align: center;
    width: 215px;
}

.hamburger-menu {
    position: relative;
}

.hamburger-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 5px;
}

.hamburger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background-color: var(--text-primary);
    transition: all 0.3s;
}

.mobile-nav {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background-color: var(--background-primary);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    padding: 10px;
    min-width: 150px;
    z-index: 101;
}

.mobile-nav.is-open {
    display: block;
}

.mobile-nav a {
    display: block;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--text-primary);
}

.mobile-nav a:hover {
    background-color: var(--background-secondary);
}

/* --- Post Feed --- */
.post-feed {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-top: 20px;
}

/* Kaartachtergrond */
.post-card {
    background-color: #FFFFFF !important;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
}

/* Onderdelen wit */
.post-card > *,
.post-card-header,
.post-card-actions,
.post-card-caption,
.post-card-comments,
.add-comment,
.media-scroller,
.media-item {
    background-color: #FFFFFF !important;
}

/* Specifieke fix voor input velden in comments */
.add-comment input {
    background-color: #FFFFFF !important;
}

.post-card-header {
    display: flex;
    align-items: center;
    padding: 14px 16px;
}

.post-card-header .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 12px;
}

.post-card-header .username {
    font-weight: 600;
}

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

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

.post-options {
    margin-left: auto;
    position: relative;
}

.options-button {
    background: none;
    border: none;
    font-weight: bold;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.options-menu {
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--background-primary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    z-index: 1;
    min-width: 120px;
    overflow: hidden;
    padding: 4px 0;
}

.options-menu .delete-post-form {
    margin: 0;
}

.delete-button,
.edit-button {
    background: none;
    border: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
    padding: 8px 16px;
    font-size: 14px;
    display: block;
    text-decoration: none;
    box-sizing: border-box;
    line-height: 1.4;
}

.delete-button {
    color: #ED4956;
    font-weight: 700;
}

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

.delete-button:hover,
.edit-button:hover {
    background-color: var(--background-secondary);
}

/* MEDIA CONTAINER */
.post-card-media {
    position: relative;
    width: 100%;
    transition: height 200ms ease;
    will-change: height;
    overflow: hidden; /* behoud flicker fix, hoogte wordt dynamisch gezet */
}

.media-scroller {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    height: auto;
}

.media-scroller::-webkit-scrollbar {
    display: none;
}

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

/* AFBEELDINGEN - Basis styling */
.post-card-media img {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    /* object-fit en max-height worden nu per aspect ratio gezet */
}

/* Desktop: aspect ratio specifieke behandeling */
@media (min-width: 769px) {
    .post-card-media img[data-aspect="portrait"] {
        max-height: min(120vh, 1000px); /* Veel meer ruimte voor portrait */
        object-fit: cover; /* BEHOUD volledige breedte vulling - GEEN witte randen */
        object-position: center;
    }
    
    .post-card-media img[data-aspect="wide"],
    .post-card-media img[data-aspect="square"] {
        max-height: 80vh; /* Ongewijzigd - behoud huidige gedrag */
        object-fit: cover; /* Behoud huidige stijl */
        object-position: center;
    }
    
    /* Fallback voor images zonder data-aspect (tijdens laden) */
    .post-card-media img:not([data-aspect]) {
        max-height: 80vh;
        object-fit: cover;
        object-position: center;
    }
}

/* Mobiel: behoud huidige gedrag (werkt perfect) */
@media (max-width: 768px) {
    .post-card-media img {
        max-height: 80vh;
        object-fit: cover;
        object-position: center;
    }
}

/* VIDEO'S – altijd COVER, geen letterboxing */
.post-card-media video {
    width: 100%;
    max-width: 100%;
    height: auto;
    object-fit: cover;
    object-position: center;
    display: block;
    margin: 0 auto;
    background-color: transparent;
    touch-action: pan-y; /* voorkom horizontale pan binnen controls */
    -ms-touch-action: pan-y;
    transform: translateZ(0); /* betere layer op mobiel */
    z-index: 0;
}

/* Desktop: beperk portrait video hoogte */
@media (min-width: 769px) {
    .post-card-media video[data-aspect="portrait"] {
        max-height: 80vh; /* Match hoogte met andere media voor consistentie */
        object-fit: cover; /* Vul de container, snijd bij indien nodig */
        background-color: transparent; /* Geen zwarte balken meer nodig */
    }
    
    .post-card-media video[data-aspect="wide"],
    .post-card-media video[data-aspect="square"] {
        max-height: 80vh;
        object-fit: cover; /* Behoud cover voor landscape/square */
    }
}

/* Mobiel: frame-vullend voor portrait, behoud bestaande voor andere */
@media (max-width: 768px) {
    .post-card-media video {
        max-height: none;
        min-height: 300px;
        object-fit: cover;
    }
    
    .post-card-media video[data-aspect="wide"] {
        max-height: 50vh;
        object-fit: cover;
    }
    
    .post-card-media video[data-aspect="portrait"] {
        width: 100%;
        height: auto;
        max-height: 80vh; /* Iets hogere limiet voor portrait op mobiel */
        object-fit: cover; /* Frame-vullend, geen zwarte randen */
        object-position: center center; /* Centreer de video content */
    }
    
    /* Voor zeer smalle schermen (telefoons in portrait mode) */
    @media (max-width: 480px) {
        .post-card-media video[data-aspect="portrait"] {
            min-height: 400px; /* Minimum hoogte voor portrait video's */
            max-height: calc(100vh - 200px); /* Laat ruimte voor UI elementen */
        }
    }
}

/* Video styling zonder dambordpatroon */
.post-card-media video:not([poster]) {
    background-color: #000;
    min-height: 200px;
}

.media-item {
    position: relative;
}

/* NIEUWE SIMPELE VIDEO STYLING */
.video-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #000;
}

.video-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.video-play-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: translate(-50%, -50%) scale(1.1);
}

.video-play-btn .play-icon {
    color: #000;
    margin-left: 4px; /* Visuele correctie voor play icon */
}

.video-container.playing .video-play-btn {
    display: none;
}

/* Responsive aanpassingen */
@media (max-width: 768px) {
    .video-play-btn {
        width: 70px;
        height: 70px;
    }
    
    .video-play-btn .play-icon {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 480px) {
    .video-play-btn {
        width: 60px;
        height: 60px;
    }
    
    .video-play-btn .play-icon {
        width: 36px;
        height: 36px;
    }
}

/* YOUTUBE VIDEO STYLING */
.youtube-container {
    position: relative;
    width: 100%;
    background-color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.youtube-thumbnail {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.youtube-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: none;
    border: none;
    cursor: pointer;
    z-index: 10;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.youtube-play-btn:hover {
    transform: translate(-50%, -50%) scale(1.1);
    opacity: 0.9;
}

.youtube-play-btn .youtube-icon {
    width: 68px;
    height: 48px;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

.youtube-iframe {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    border: none;
    background-color: #000;
}

/* Responsive YouTube styling */
@media (max-width: 768px) {
    .youtube-play-btn .youtube-icon {
        width: 56px;
        height: 40px;
    }
    
    .youtube-thumbnail {
        padding-bottom: 56.25%; /* Maintain 16:9 on mobile */
    }
}

@media (max-width: 480px) {
    .youtube-play-btn .youtube-icon {
        width: 48px;
        height: 34px;
    }
}

/* YouTube container in carousel */
.media-item .youtube-container {
    width: 100%;
    max-height: 80vh;
    object-fit: cover;
}

/* Desktop: beperk YouTube video hoogte zoals andere videos */
@media (min-width: 769px) {
    .post-card-media .youtube-container {
        max-height: 80vh;
    }
    
    .youtube-iframe {
        max-height: 80vh;
    }
}

/* Mobiel: frame-vullend voor YouTube */
@media (max-width: 768px) {
    .post-card-media .youtube-container {
        max-height: none;
        min-height: 300px;
    }
    
    .youtube-iframe {
        min-height: 300px;
        max-height: 80vh;
    }
}

/* Voor zeer smalle schermen */
@media (max-width: 480px) {
    .post-card-media .youtube-container {
        min-height: 250px;
        max-height: calc(100vh - 200px);
    }
    
    .youtube-iframe {
        min-height: 250px;
        max-height: calc(100vh - 200px);
    }
}

/* YouTube loading state */
.youtube-container.loading .youtube-thumbnail::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* YouTube thumbnail overlay for better visibility */
.youtube-thumbnail::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(0, 0, 0, 0.1) 100%);
    pointer-events: none;
}

/* Ensure YouTube videos work within existing carousel indicators */
.youtube-container ~ .carousel-indicators,
.youtube-container ~ .carousel-counter {
    z-index: 15; /* Higher than YouTube elements */
}

/* Indicators/counter overlappen maar blokkeren geen aanrakingen */
.carousel-indicators {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 2;
    pointer-events: none; /* niet interactief -> blokkeert video controls niet */
}

.indicator-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.4) !important;
    border: 1px solid rgba(255, 255, 255, 0.8) !important;
}

.indicator-dot.active {
    background-color: rgba(0, 0, 0, 0.8) !important;
    border: 1px solid rgba(255, 255, 255, 1) !important;
}

.carousel-counter {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7) !important;
    color: white !important;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    z-index: 2;
    pointer-events: none; /* blokkeer video niet */
}

.post-card-actions {
    display: flex;
    align-items: center;
    padding: 4px 16px;
}

.like-form {
    display: inline-block;
}

.like-button {
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 600;
    color: var(--button-primary);
}

.like-button.liked {
    color: red;
}
.like-button .like-icon {
    width: 24px;
    height: 24px;
    fill: white;
    stroke: #ED4956;
    stroke-width: 2;
    transition: all 0.2s ease-in-out;
}

.like-button:hover .like-icon {
    fill: rgba(255, 255, 255, 0.8);
    stroke: #ED4956;
}

.like-button.liked .like-icon {
    fill: #ED4956;
    stroke: #ED4956;
    stroke-width: 2;
    animation: like-animation 0.45s 1;
}

@keyframes like-animation {
    0% { transform: scale(1); }
    15% { transform: scale(1.2); }
    30% { transform: scale(0.95); }
    45%, 100% { transform: scale(1); }
}

.like-count {
    font-weight: 600;
    margin-left: 8px;
}

.post-card-caption {
    padding: 0 16px 4px;
}

.post-card-caption .username {
    font-weight: 600;
    margin-right: 4px;
}

.post-spotify-embed {
    margin-top: 12px;
}

.post-spotify-embed iframe {
    border: none;
    border-radius: 12px;
    width: 100%;
    min-height: 152px;
}

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

.view-all {
    color: var(--link-primary);
    cursor: pointer;
    margin-bottom: 8px;
    font-size: 14px;
}

.view-all:hover {
    text-decoration: underline;
}

.comment {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
    padding: 2px 0;
}

.comment-content {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.comment .username {
    font-weight: 600;
    margin-right: 5px;
    line-height: 1.4;
}

.comment .comment-content span:last-child {
    line-height: 1.4;
}

.comment-date {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.delete-comment-button {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    padding: 0 0 0 10px;
    line-height: 1.2;
}

.delete-comment-form {
    display: inline;
    margin-left: auto;
}

.delete-comment-button {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
}

.add-comment {
    border-top: 1px solid var(--border-primary);
    padding: 12px 16px;
    display: flex;
}

.add-comment input {
    border: none;
    outline: none;
    flex-grow: 1;
    font-size: 14px;
}

.add-comment button {
    background: none;
    border: none;
    color: var(--button-primary);
    font-weight: 600;
    cursor: pointer;
}

/* --- Login Page --- */
.login-page-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.login-form-container {
    background-color: var(--background-primary);
    border: 1px solid var(--border-primary);
    border-radius: 1px;
    padding: 40px;
    width: 350px;
    text-align: center;
}

.login-form-container .logo {
    margin-bottom: 20px;
}

.login-form input {
    width: 100%;
    padding: 9px;
    margin-bottom: 6px;
    border: 1px solid var(--border-primary);
    border-radius: 3px;
    background-color: var(--background-secondary);
}

.login-form button {
    width: 100%;
    padding: 8px;
    border: none;
    border-radius: 4px;
    background-color: var(--button-primary);
    color: white;
    font-weight: 600;
    cursor: pointer;
}

.login-form button:hover {
    background-color: var(--button-primary-hover);
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

.modal-content {
    background: var(--background-primary);
    padding: 0;
    border-radius: 12px;
    width: 500px;
    max-width: 90%;
    position: relative;
    text-align: center;
}

.modal-content h2 {
    font-size: 16px;
    font-weight: 600;
    padding: 10px;
    border-bottom: 1px solid var(--border-primary);
}

.modal-close {
    position: absolute;
    top: 0;
    right: 10px;
    background: none;
    border: none;
    font-size: 30px;
    cursor: pointer;
    line-height: 40px;
}

#new-post-form {
    padding: 20px;
}

.form-group {
    margin-bottom: 15px;
    text-align: left;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
}

.form-group input,
.form-group textarea {
    box-sizing: border-box;
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-primary);
    border-radius: 3px;
    font-size: 16px; /* Voorkom auto-zoom op iOS */
}

#progress-container {
    width: 100%;
    background-color: #f3f3f3;
    border-radius: 4px;
    margin-bottom: 15px;
}

#progress-bar {
    height: 10px;
    background-color: var(--button-primary);
    border-radius: 4px;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--background-primary);
    border: 1px solid var(--border-primary);
    border-top: none;
    border-radius: 0 0 3px 3px;
    display: none;
}

.search-results a {
    display: block;
    padding: 10px;
    text-decoration: none;
    color: var(--text-primary);
}

.search-results a:hover {
    background-color: var(--background-secondary);
}
.read-more-link {
    color: var(--link-primary);
    font-weight: 500;
    text-decoration: none;
}

/* Mobiele aanpassingen voor de modal */
@media (max-width: 600px) {
    .modal-content {
        width: 95%;
        max-width: 95%;
        max-height: 90vh;
        overflow-y: auto;
    }

    #new-post-form {
        padding: 15px;
    }
}

/* --- Fullscreen Functionaliteit --- */

/* Maak afbeeldingen in posts klikbaar */
.post-card-media img {
    cursor: pointer;
    touch-action: manipulation; /* Voorkom 300ms delay op mobiel */
}

/* Pseudo-fullscreen voor iOS/fallback */
.pseudo-fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: black;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pseudo-fullscreen-image {
    max-width: 100vw;
    max-height: 100vh;
    object-fit: contain;
}

/* Echte fullscreen styling voor ondersteunde browsers */
img:fullscreen, img:-webkit-full-screen {
    object-fit: contain !important; /* Forceer contain voor volledige zichtbaarheid */
    width: 100vw !important;
    height: 100vh !important;
    background: black !important;
    max-height: none !important; /* Override alle max-height regels */
}

/* Pseudo-fullscreen styling voor iOS/fallback */
.pseudo-fullscreen-image {
    max-width: 100vw !important;
    max-height: 100vh !important;
    object-fit: contain !important; /* Forceer contain voor volledige zichtbaarheid */
    background: black;
    width: auto !important;
    height: auto !important;
}

/* Extra specificiteit voor fullscreen overlay */
.pseudo-fullscreen-overlay .pseudo-fullscreen-image {
    object-fit: contain !important;
    max-height: 100vh !important;
    max-width: 100vw !important;
}
