/* 
 * Instagram Accounts Viewer - Premium Design System
 * Focus: Clean white aesthetic, modern typography, and subtle gradients.
 */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Inter:wght@400;500&display=swap');

:root {
    --bg-white: #FFFFFF;
    --text-main: #1A1A1A;
    --text-muted: #666666;
    --insta-gradient: linear-gradient(45deg, #a026d9 0%, #bc1888 50%, #8122b4 100%);
    --insta-purple-soft: rgba(160, 38, 217, 0.05);
    --insta-purple: #a026d9;
    --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.05);
    --transition-speed: 0.3s;
    --border-radius: 16px;
}

.ig-tracker-scope * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

.ig-tracker-scope .container {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    padding: 2rem 1rem;
    min-height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Header Styling */
header {
    margin-bottom: 4rem;
    text-align: center;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-main);
    background: var(--insta-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

/* Search Bar Styling */
.search-wrapper {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin-bottom: 2rem;
}

.search-input-container {
    position: relative;
    width: 100%;
    border-radius: 50px;
    /* Fully rounded pill shape */
    padding: 2px;
    background: #E0E0E0;
    transition: background var(--transition-speed);
}

.search-input-container:focus-within {
    background: var(--insta-gradient);
}

#usernameInput {
    width: 100%;
    padding: 1rem 1.5rem;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    outline: none;
    background: white;
    color: var(--text-main);
    transition: all var(--transition-speed);
}

#usernameInput::placeholder {
    color: #999;
    font-size: 0.85rem;
    /* Small font size */
    font-family: 'Inter', sans-serif;
    /* Inter font for placeholder */
}

.search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--insta-purple);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.search-btn svg {
    stroke-width: 3;
}

.search-btn:active {
    transform: translateY(-50%) scale(0.9);
}

/* Cooldown/Error Messages */
#statusMessage {
    margin-top: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    height: 1.5rem;
}

.error {
    color: #dc2743;
}

.info {
    color: var(--text-muted);
}

/* Error Modal Popup */
.error-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 1rem;
}

.error-modal-overlay.visible {
    opacity: 1;
}

.error-modal-card {
    background: #fff;
    border-radius: 20px;
    padding: 2rem 1.8rem 1.8rem;
    width: 100%;
    max-width: 340px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    transform: translateY(30px) scale(0.95);
    transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.error-modal-overlay.visible .error-modal-card {
    transform: translateY(0) scale(1);
}

.error-modal-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #fce4ec;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.2rem;
}

.error-modal-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 0.6rem;
    line-height: 1.3;
}

.error-modal-message {
    font-family: 'Inter', 'Outfit', sans-serif;
    font-size: 0.92rem;
    color: #666;
    line-height: 1.55;
    margin-bottom: 1.5rem;
}

.error-modal-btn {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 14px;
    background: var(--insta-gradient, linear-gradient(45deg, #a026d9, #bc1888));
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(160, 38, 217, 0.3);
}

.error-modal-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(160, 38, 217, 0.4);
}

.error-modal-btn:active {
    transform: translateY(0) scale(0.98);
}

/* Results UI */
#resultsContainer {
    width: 100%;
    display: none;
    /* Hidden by default */
    animation: fadeInUp 0.6s ease forwards;
}



@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.profile-card {
    background: var(--insta-purple-soft);
    border-radius: 24px;
    padding: 2rem 1.5rem;
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: flex-start;
    /* Left align everything */
    border: 1px solid rgba(188, 24, 136, 0.1);
    width: 100%;
    max-width: 100%;
    text-align: left;
    /* Left align text */
}

.profile-image-container {
    flex-shrink: 0;
}

.profile-image {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid white;
    box-shadow: var(--shadow-soft);
}

.profile-info {
    flex-grow: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.profile-username {
    font-size: 24px;
    /* Requested size */
    font-weight: 700;
}

.stats-container {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    justify-content: flex-start;
}

.stat-item {
    text-align: left;
}

.stat-value {
    font-weight: 700;
    font-size: 14px;
    /* Requested size base */
    display: block;
}

.stat-label {
    font-size: 14px;
    /* Requested size */
    color: var(--text-muted);
}

.bio {
    font-size: 14px;
    /* Requested size */
    color: var(--text-main);
    white-space: pre-line;
    text-align: left;
    width: 100%;
}



/* Post Grid */
.posts-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    text-align: left;
    width: 100%;
}

.posts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    width: 100%;
}

.post-item {
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    background: #f0f0f0;
}

.post-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.post-item:hover .post-image {
    transform: scale(1.05);
}

/* Analysis Button */
.analyze-btn {
    margin-top: 1rem;
    background: var(--insta-purple);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    width: auto;
}

.analyze-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Comparison Section */
.comparison-section {
    margin-top: 3rem;
    width: 100%;
    background: white;
    border-radius: 24px;
    padding: 2rem;
    box-shadow: var(--shadow-soft);
    display: none;
    margin-bottom: 2rem;
}

.comparison-header {
    margin-bottom: 1.5rem;
    text-align: left;
}

.comparison-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 1rem;
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.5rem 1rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
}

.tab-btn.active {
    color: var(--insta-purple);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1rem;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--insta-gradient);
}

.comparison-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.mini-profile-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem;
    background: var(--insta-purple-soft);
    border-radius: 12px;
    transition: all 0.2s;
    text-decoration: none;
    color: inherit;
    border: 1px solid rgba(188, 24, 136, 0.05);
}

.mini-profile-card:hover {
    transform: translateY(-2px);
    background: rgba(188, 24, 136, 0.1);
    border-color: rgba(188, 24, 136, 0.2);
}

.mini-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
}

.mini-info {
    display: flex;
    flex-direction: column;
}

.mini-username {
    font-weight: 600;
    font-size: 0.9rem;
}

.mini-fullname {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .ig-tracker-scope .container {
        padding: 2rem 0;
        /* Remove side padding to allow full width */
        max-width: 100%;
        width: 100%;
    }

    .search-wrapper {
        max-width: 90%;
        /* Keep search bar slightly inset for better look */
        margin-bottom: 2rem;
    }

    .search-input-container {
        position: relative;
        width: 100%;
        background: #E0E0E0 !important;
        border-radius: 50px !important;
        /* Fully rounded pill shape */
        padding: 2px;
        display: block !important;
    }

    #usernameInput {
        width: 100% !important;
        height: 50px !important;
        border: none !important;
        border-radius: 50px !important;
        padding: 0 50px 0 1.5rem !important;
        /* Room for icon on right */
        display: block !important;
        background: #FFFFFF !important;
        color: #1A1A1A !important;
        font-size: 0.9rem;
    }

    .search-btn {
        position: absolute !important;
        right: 6px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        width: 38px !important;
        height: 38px !important;
        border-radius: 50% !important;
        /* Fully circular icon */
        padding: 0 !important;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--insta-purple) !important;
    }

    .profile-card {
        flex-direction: column;
        padding: 2rem 1.5rem;
        text-align: left;
        gap: 1.5rem;
        width: 100%;
        border-radius: 0;
        /* Full screen look usually means no corners on sides */
        border-left: none;
        border-right: none;
    }

    .comparison-section {
        margin-top: 2rem;
        padding: 1.5rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-shadow: none;
        border-top: 1px solid #eee;
    }

    .comparison-grid {
        grid-template-columns: 1fr;
        /* Stack items on small screens */
    }

    .mini-profile-card {
        padding: 1rem;
    }

    .profile-image {
        width: 100px;
        height: 100px;
    }

    .profile-username {
        font-size: 1.4rem;
    }

    .stats-container {
        justify-content: space-between;
        gap: 5px;
        width: 100%;
        display: flex;
    }

    .stat-item {
        flex: 1;
        text-align: center;
    }

    .stat-value {
        font-size: 1rem;
    }

    .stat-label {
        font-size: 0.75rem;
        white-space: nowrap;
    }

    .posts-grid {
        grid-template-columns: repeat(2, 1fr);
    }


}

/* Loading Spinner */
/* Processing Screen Styles */
.processing-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1rem;
}

.loading-card {
    background: #fff;
    border-radius: 24px;
    padding: 2.5rem 2rem 2rem;
    width: 100%;
    max-width: 300px;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
    animation: loadingCardIn 0.4s ease forwards;
}

@keyframes loadingCardIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.simple-loader {
    width: 52px;
    height: 52px;
    border: 5px solid #f0e6f6;
    border-top: 5px solid var(--insta-purple);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.loading-message {
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0;
    min-height: 1.5em;
    animation: messageFade 0.4s ease;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

@keyframes messageFade {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.loading-tip {
    font-family: 'Inter', 'Outfit', sans-serif;
    font-size: 0.78rem;
    color: #999;
    margin: 0;
    line-height: 1.4;
    max-width: 240px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeInModal 0.3s ease;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    animation: slideUpModal 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-content h3 {
    margin-bottom: 0.8rem;
    color: var(--text-main);
    font-size: 1.4rem;
    font-weight: 700;
}

.modal-content p {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.primary-btn {
    background: var(--insta-purple);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    /* Slim rectangle */
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    width: 100%;
    /* Slim but full width relative to card */
    transition: all 0.2s;
    font-family: inherit;
}

.primary-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.close-text-btn {
    background: none;
    border: none;
    color: var(--insta-purple);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 8px;
    font-family: inherit;
    transition: opacity 0.2s;
}

.close-text-btn:hover {
    opacity: 0.7;
}

@keyframes fadeInModal {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUpModal {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}