/* Investment Portfolio Plugin - Frontend Styles */

/* Main container */
.ipp-companies-container {
    padding: 20px 0;
    max-width: 1200px;
    margin: 0 auto;
}

/* Companies grid */
.ipp-companies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    padding: 20px;
}

/* Company card */
.ipp-company-card {
    background: #FFFFFF;
    border: 2px solid #f0f0f0;
    border-radius: 12px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.ipp-company-card:hover {
    transform: translateY(-5px);
    border-color: #5737FB;
    box-shadow: 0 8px 25px rgba(87, 55, 251, 0.15);
}

/* Company logo */
.ipp-company-logo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 15px;
    display: block;
    border: 3px solid #5737FB;
}

/* Company name */
.ipp-company-name {
    font-size: 18px;
    font-weight: 600;
    color: #333333;
    margin: 0;
    line-height: 1.4;
}

/* Popup overlay */
.ipp-popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.ipp-popup-overlay.active {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 20px;
}

/* Popup container - CRITICAL FIX: Always position within viewport */
.ipp-popup {
    background: #FFFFFF;
    width: 100%;
    max-width: 450px;
    max-height: calc(100vh - 40px);
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    overflow-y: auto;
    position: relative;
    
    /* CRITICAL: Ensure popup stays within viewport boundaries */
    margin-right: 0;
    margin-top: auto;
    margin-bottom: auto;
}

.ipp-popup-overlay.active .ipp-popup {
    transform: translateX(0);
}

/* Popup header */
.ipp-popup-header {
    background: linear-gradient(135deg, #5737FB 0%, #7C5CFF 100%);
    color: #FFFFFF;
    padding: 25px;
    border-radius: 15px 15px 0 0;
    position: relative;
}

/* Close button */
.ipp-popup-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #FFFFFF;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.ipp-popup-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Company logo in popup */
.ipp-popup-logo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid #FFFFFF;
    margin-bottom: 15px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

/* Company name in popup */
.ipp-popup-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    text-align: center;
}

/* Popup body */
.ipp-popup-body {
    padding: 30px;
}

/* Info item */
.ipp-info-item {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #f0f0f0;
}

.ipp-info-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.ipp-info-label {
    font-weight: 600;
    font-size: 14px;
    color: #5737FB;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    display: block;
}

.ipp-info-value {
    font-size: 16px;
    color: #333333;
    line-height: 1.6;
    margin: 0;
}

.ipp-info-value a {
    color: #5737FB;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.ipp-info-value a:hover {
    color: #4527E0;
    text-decoration: underline;
}

/* Sector badge */
.ipp-sector-badge {
    display: inline-block;
    background: linear-gradient(135deg, #5737FB 0%, #7C5CFF 100%);
    color: #FFFFFF;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    margin-top: 5px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .ipp-companies-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 20px;
        padding: 15px;
    }
    
    .ipp-company-card {
        padding: 20px 15px;
    }
    
    .ipp-company-logo {
        width: 60px;
        height: 60px;
    }
    
    .ipp-company-name {
        font-size: 16px;
    }
    
    /* CRITICAL: Mobile popup positioning */
    .ipp-popup-overlay.active {
        justify-content: center;
        align-items: flex-start;
        padding: 10px;
        padding-top: 20px;
    }
    
    .ipp-popup {
        max-width: 100%;
        width: 100%;
        max-height: calc(100vh - 40px);
        transform: translateY(100%);
        margin: 0;
    }
    
    .ipp-popup-overlay.active .ipp-popup {
        transform: translateY(0);
    }
    
    .ipp-popup-header {
        padding: 20px;
    }
    
    .ipp-popup-logo {
        width: 60px;
        height: 60px;
    }
    
    .ipp-popup-title {
        font-size: 20px;
    }
    
    .ipp-popup-body {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .ipp-companies-grid {
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 10px;
    }
    
    .ipp-company-card {
        padding: 15px;
    }
    
    .ipp-company-logo {
        width: 50px;
        height: 50px;
    }
    
    .ipp-company-name {
        font-size: 15px;
    }
}

/* Loading animation */
.ipp-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.ipp-loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 4px solid #f0f0f0;
    border-top: 4px solid #5737FB;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Scrollbar styling for popup */
.ipp-popup::-webkit-scrollbar {
    width: 6px;
}

.ipp-popup::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.ipp-popup::-webkit-scrollbar-thumb {
    background: #5737FB;
    border-radius: 3px;
}

.ipp-popup::-webkit-scrollbar-thumb:hover {
    background: #4527E0;
}