/* 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;
}

/* Instagram Grid Container */
.palm-instagram-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Account Header Styling - Compact */
.palm-instagram-header {
    margin-bottom: 30px;
    padding: 15px 0;
    border-bottom: 1px solid #e0e0e0;
}

.palm-instagram-header-wrapper {
    display: flex;
    align-items: center;
    gap: 20px;
}

@media (max-width: 768px) {
    .palm-instagram-header-wrapper {
        flex-direction: column;
        gap: 15px;
        align-items: center;
        text-align: center;
    }
}

/* Profile Picture */
.palm-instagram-profile-pic {
    position: relative;
    flex-shrink: 0;
}

.palm-instagram-avatar {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    padding: 2px;
    display: block;
}

@media (max-width: 768px) {
    .palm-instagram-avatar {
        width: 70px;
        height: 70px;
    }
}

/* Verified Badge */
.palm-instagram-verified {
    position: absolute;
    bottom: 0;
    right: 0;
    background: #3897f0;
    border: 2px solid #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.palm-instagram-verified svg {
    width: 14px;
    height: 14px;
    color: #fff;
}

/* Header Info Section */
.palm-instagram-header-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 30px;
    justify-content: space-between;
}

@media (max-width: 768px) {
    .palm-instagram-header-info {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
}

.palm-instagram-header-name {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 150px;
}

.palm-instagram-username {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: #262626;
    line-height: 1.2;
}

.palm-instagram-username-handle {
    font-size: 13px;
    color: #999;
    font-weight: 400;
}

@media (max-width: 768px) {
    .palm-instagram-username {
        font-size: 18px;
    }
}

/* Follow Button */
.palm-instagram-follow-btn {
    background: #3897f0;
    color: #fff;
    border: none;
    padding: 8px 24px;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.palm-instagram-follow-btn:hover {
    background: #2981cc;
    transform: translateY(-1px);
}

.palm-instagram-follow-btn svg {
    width: 14px;
    height: 14px;
}

/* Header Stats */
.palm-instagram-header-stats {
    display: flex;
    gap: 30px;
    align-items: center;
}

@media (max-width: 768px) {
    .palm-instagram-header-stats {
        justify-content: center;
        gap: 25px;
    }
}

.palm-instagram-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    white-space: nowrap;
}

.palm-instagram-stat-number {
    font-size: 18px;
    font-weight: 600;
    color: #262626;
    line-height: 1;
}

.palm-instagram-stat-label {
    font-size: 12px;
    color: #999;
    margin-top: 2px;
    font-weight: 400;
}

/* Hide full name and bio in compact mode */
.palm-instagram-header-fullname {
    display: none;
}

.palm-instagram-header-bio {
    display: none;
}

/* Grid Layout - Improved for More Posts */
.palm-instagram-masonry {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
    background-color: #fafafa;
    margin-bottom: 40px;
}

@media (max-width: 1024px) {
    .palm-instagram-masonry {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 10px;
    }
}

@media (max-width: 768px) {
    .palm-instagram-masonry {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .palm-instagram-masonry {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
}

/* Individual Post */
.palm-instagram-post {
    position: relative;
    width: 100%;
    padding-bottom: 100%; /* 1:1 Aspect Ratio */
    background-color: #000;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 4px;
}

.palm-instagram-post:hover {
    opacity: 0.95;
    transform: scale(1.02);
}

/* Link wrapper */
.palm-instagram-link {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    text-decoration: none;
}

/* Media (Image/Video) */
.palm-instagram-media {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Overlay - Hidden by default */
.palm-instagram-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 2;
}

.palm-instagram-post:hover .palm-instagram-overlay {
    opacity: 1;
}

/* Stats in Overlay */
.palm-instagram-stats {
    display: flex;
    align-items: center;
    gap: 24px;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
}

.palm-instagram-likes,
.palm-instagram-comments {
    display: flex;
    align-items: center;
    gap: 6px;
}

.palm-instagram-likes svg,
.palm-instagram-comments svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

/* Caption in Overlay */
.palm-instagram-caption {
    color: #fff;
    font-size: 12px;
    text-align: center;
    margin-top: 12px;
    padding: 0 16px;
    max-width: 85%;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Video/Carousel Indicator */
.palm-instagram-media-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1;
}

.palm-instagram-media-icon svg {
    width: 20px;
    height: 20px;
    fill: #fff;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

/* Load More Button Container */
.palm-instagram-load-more-container {
    display: flex;
    justify-content: center;
    padding: 30px 20px;
    margin-top: 20px;
}

.palm-instagram-load-more-btn {
    background: linear-gradient(45deg, #405de6, #5b51d8, #833ab4, #c13584, #e1306c, #fd1d1d);
    color: #fff;
    border: none;
    padding: 12px 40px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.palm-instagram-load-more-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.palm-instagram-load-more-btn:active {
    transform: translateY(0);
}

.palm-instagram-load-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.palm-instagram-load-more-btn.loading {
    position: relative;
    pointer-events: none;
}

.palm-instagram-load-more-btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    right: 15px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Loading message */
.palm-instagram-loading {
    text-align: center;
    padding: 30px 20px;
    color: #666;
    font-size: 14px;
}

/* Empty state */
.palm-instagram-empty {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 16px;
}

/* Smooth fade in animation for new posts */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.palm-instagram-post.new-post {
    animation: fadeIn 0.3s ease-out;
}
