/* Profile Selection Modal Styles */
.profile-selection-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(3px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    padding: 2rem 2rem 1rem 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.modal-header h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.8rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.modal-header p {
    margin: 0;
    font-size: 1rem;
    opacity: 0.9;
    line-height: 1.4;
}

.profile-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
    padding: 2rem;
    max-height: 400px;
    overflow-y: auto;
}

.profile-item {
    position: relative;
    padding: 1.5rem;
    border: 2px solid #e8e8e8;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fff;
    overflow: hidden;
    outline: none;
}

.profile-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.2s ease;
}

.profile-item:hover {
    border-color: #667eea;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.profile-item:hover::before {
    transform: scaleX(1);
}

.profile-item:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

.profile-item.selected {
    border-color: #667eea;
    background: #f8f9ff;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2);
}

.profile-item.selected::before {
    transform: scaleX(1);
}

.profile-item.loading {
    pointer-events: none;
    opacity: 0.7;
}

.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.profile-header h4 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
}

.profile-id {
    background: #f0f0f0;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #666;
}

.profile-details {
    display: grid;
    gap: 0.75rem;
}

.profile-detail {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.profile-detail strong {
    min-width: 80px;
    color: #555;
    font-size: 0.9rem;
    font-weight: 600;
}

.profile-detail span {
    color: #333;
    font-size: 0.9rem;
    flex: 1;
}

.role-badge {
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
}

.role-admin {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
}

.role-emc {
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    color: white;
}

.role-viewer {
    background: linear-gradient(135deg, #a8edea, #fed6e3);
    color: #333;
}

.role-supplier {
    background: linear-gradient(135deg, #ffecd2, #fcb69f);
    color: #333;
}

.profile-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
}

.profile-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 0.5rem;
}

.profile-loading-overlay span {
    font-size: 0.9rem;
    color: #667eea;
    font-weight: 500;
}

.modal-footer {
    padding: 1rem 2rem 2rem 2rem;
    background: #fafafa;
    border-radius: 0 0 12px 12px;
}

.help-text {
    margin: 0;
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
    text-align: center;
}

/* Loading State */
.loading-state {
    padding: 3rem 2rem;
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem auto;
}

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

.loading-state p {
    margin: 0;
    font-size: 1rem;
    color: #666;
}

/* App Loading States */
.app-loading, .app-initializing {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: #f8f9fa;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.app-loading .spinner {
    width: 60px;
    height: 60px;
    border-width: 6px;
}

.app-loading p, .app-initializing p {
    margin-top: 1rem;
    font-size: 1.1rem;
    color: #555;
}

/* Error States */
.profile-error {
    padding: 2rem;
    text-align: center;
    color: #d32f2f;
}

.profile-error h4 {
    margin: 0 0 1rem 0;
    font-size: 1.2rem;
}

.profile-error p {
    margin: 0;
    line-height: 1.5;
}

.retry-button {
    margin-top: 1rem;
    padding: 0.75rem 1.5rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s;
}

.retry-button:hover {
    background: #5a6fd8;
}

.retry-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Error button container */
.error-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

@media (max-width: 480px) {
    .error-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .retry-button {
        width: 100%;
        max-width: 200px;
    }
}

/* User Not Provisioned Error Styles */
.user-not-provisioned {
    max-width: 600px;
    margin: 0 auto;
}

.user-not-provisioned .error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    text-align: center;
}

.user-not-provisioned h4 {
    color: #d32f2f;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    text-align: center;
}

.user-not-provisioned p {
    font-size: 1.1rem;
    line-height: 1.6;
    text-align: center;
    margin-bottom: 2rem;
}

.error-details, .error-actions {
    background: #f8f9fa;
    border-left: 4px solid #667eea;
    padding: 1.5rem;
    margin: 1.5rem 0;
    border-radius: 4px;
}

.error-details h5, .error-actions h5 {
    margin: 0 0 1rem 0;
    color: #333;
    font-size: 1.1rem;
    font-weight: 600;
}

.error-details ul, .error-actions ol {
    margin: 0;
    padding-left: 1.5rem;
}

.error-details li, .error-actions li {
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.technical-details {
    margin: 1.5rem 0;
    padding: 1rem;
    background: #f5f5f5;
    border-radius: 4px;
}

.technical-details details {
    cursor: pointer;
}

.technical-details summary {
    font-weight: 600;
    color: #666;
    font-size: 0.9rem;
    padding: 0.5rem 0;
}

.technical-details p {
    margin: 0.5rem 0;
    font-size: 0.85rem;
    color: #555;
    font-family: monospace;
    background: white;
    padding: 0.5rem;
    border-radius: 2px;
}

.retry-button.secondary {
    background: #6c757d;
}

.retry-button.secondary:hover {
    background: #5a6268;
}

/* Contact Information Styling */
.error-actions strong {
    color: #667eea;
    background: #f8f9ff;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: monospace;
}

/* Responsive Design */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 95vh;
    }
    
    .modal-header {
        padding: 1.5rem 1.5rem 1rem 1.5rem;
    }
    
    .modal-header h3 {
        font-size: 1.5rem;
    }
    
    .profile-list {
        grid-template-columns: 1fr;
        padding: 1.5rem;
        gap: 1rem;
    }
    
    .profile-item {
        padding: 1rem;
    }
    
    .profile-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .profile-detail {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    .profile-detail strong {
        min-width: auto;
        font-size: 0.8rem;
    }
    
    .modal-footer {
        padding: 1rem 1.5rem 1.5rem 1.5rem;
    }
}

@media (max-width: 480px) {
    .modal-content {
        width: 98%;
        margin: 1%;
    }
    
    .profile-list {
        max-height: 300px;
    }
}

/* Scrollbar Styling */
.profile-list::-webkit-scrollbar {
    width: 6px;
}

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

.profile-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.profile-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .profile-item {
        border-width: 3px;
    }
    
    .role-badge {
        border: 2px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .modal-content {
        animation: none;
    }
    
    .profile-item {
        transition: none;
    }
    
    .profile-item::before {
        transition: none;
    }
    
    .spinner, .profile-spinner {
        animation: none;
    }
}
